Originally Posted by serialsamuri
joannvp , if you ever decided to check back here, i figured i owuld let you know that using my new found method i manged to stay conencted for nearly 10 hours. the only reason i logged off is cause i had to sleep.
- maximilian
I'm trying out your solution now. I've been so frustrated so far. I wrote an elaborate Applescript to toggle bluetooth and log in and start a terminal session that pings every 20 seconds...but I only had limited success. I'm hoping your solution (which seems to be working) works better for the long term. For the curious (because of the other elements in the script--btw, it should be saved as an application) my source follows. I'd certainly be interested in your server script, if you're willing to share it, too.
(* Connection state codes, got after many trials:
0 = Idle (not connected)
1 = Dialing...
2 = Connecting...
3 = Error
4 = Connected (antes da autenticacao)
5 = Disconnecting... (as reported by others)
7 = authenticating (?)
8 = Connected (on my system)
9 = Disconnecting... (on my system)
10 = Could not connect (on my system)
*)
on TurnOnBluetooth()
-- Check the current bluetooth status and turn it on if necessary.
tell application "System Events" to tell the front menu bar of process "SystemUIServer"
set menuExtras to value of attribute "AXDescription" of menu bar items
repeat with mExtras from 1 to the length of menuExtras
if item mExtras of menuExtras is "bluetooth menu extra" then exit repeat
end repeat
tell menu bar item mExtras
click
tell 2nd menu item of front menu
if name ends with "Off" then
-- Current status is on; it says "turn bluetooth off"
set prevBluetoothState to "on"
else if name ends with "On" then
-- Current status is off; it says "turn bluetooth on"
set prevBluetoothState to "off"
click
end if
end tell
-- Unclick if it was on (do nothing but make the menu disappear)
if prevBluetoothState is "on" then
click
end if
end tell
end tell
return prevBluetoothState
end TurnOnBluetooth
on TurnOffBluetooth()
-- Set the bluetooth status off
tell application "System Events" to tell the front menu bar of process "SystemUIServer"
set menuExtras to value of attribute "AXDescription" of menu bar items
repeat with mExtras from 1 to the length of menuExtras
if item mExtras of menuExtras is "bluetooth menu extra" then exit repeat
end repeat
tell menu bar item mExtras
click
click 2nd menu item of front menu
end tell
end tell
end TurnOffBluetooth
set prevBluetoothState to TurnOnBluetooth()
tell application "Internet Connect"
launch
connect configuration "BlueTooth"
repeat
delay 1
set the current configuration to configuration "BlueTooth"
set theState to the state of status of configuration "BlueTooth"
if theState = 0 or theState > 2 then
exit repeat
end if
end repeat
quit
end tell
delay 3
if theState is not 8 and theState is not 4 then
if theState is not 0 and theState is not 3 and theState is not 10 then
activate
display dialog ¬
"Unexpected state: " & theState as text ¬
buttons "OK" default button "OK"
end if
if prevBluetoothState is "off" then
TurnOffBluetooth()
end if
return
end if
set pid to do shell script "ping -i20 my.yahoo.com &> /dev/null &echo $!"
display dialog ¬
"Pinging my.yahoo.com every 20 seconds." & return & ¬
"Waiting to kill process ID: " & pid ¬
with title "Bluetooth Internet Connection" buttons ¬
"Disconnect" default button "Disconnect"
do shell script "kill " & pid
tell application "Internet Connect"
set theState to the state of status of configuration "BlueTooth"
if theState = 8 then
disconnect configuration "BlueTooth"
quit
end if
end tell
delay 5
if prevBluetoothState is "off" then
TurnOffBluetooth()
end if
----------------
Addendum...damn...didn't work much better for me. Wonder what other problems there could be....