![]() |
2012-08-30
, 18:31
|
|
Posts: 4,118 |
Thanked: 8,901 times |
Joined on Aug 2010
@ Ruhrgebiet, Germany
|
#32
|
![]() |
2012-08-31
, 07:39
|
Posts: 61 |
Thanked: 64 times |
Joined on Oct 2007
@ EU
|
#33
|
#!/bin/sh CONNECTED=false DROPCONN=false call_check () { # Check no call in progress oncall=`run-standalone.sh dbus-send --system --type=method_call --print-reply=literal --dest=com.nokia.csd.Call /com/nokia/csd/call/1 com.nokia.csd.Call.Instance.GetStatus` if [ $oncall != "uint32 0" ]; then dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"Sync dropped due to active call!" uint32:0 string:"OK" exit 1 fi } # check for existing wifi connectivity if [ "$(/sbin/route | awk '/au/ {print $1}')" == "default" ]; then CONNECTED=true else #Bring up WLAN sudo ifconfig wlan0 up for i in WLAN1 WLAN2 WLAN3 do # scan for SSIDs, if not found continue if [ -z `sudo iwlist wlan0 scan | grep -m 1 -o \"$i\"` ]; then continue; fi # find IAP_ID from SSID IAP_ID=`gconftool-2 -R /system/osso/connectivity/IAP | tac | awk "/name = $i/,/connectivity\/IAP/" | awk -F '/|:' '/connectivity\/IAP/{ print $6}'` # try to connect to known wifi dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"$IAP_ID" uint32:0 sleep 20 if [ "$(/sbin/route | awk '/au/ {print $1}')" == "default" ]; then CONNECTED=true DROPCONN=true break fi done # if no WLAN was found (i.e. outdoor), then put WLAN down if [ "$DROPCONN" == "false" ]; then sudo ifconfig wlan0 down fi fi # If no wifi try with GPRS if [ "$CONNECTED" == "false" ]; then opcode=`dbus-send --system --print-reply=literal --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.get_registration_status | tr '\n' ' ' | awk '{print $8,$10}' | cut -f1 -d' '` # Temporary disable SIM switch #opcode=10 # Check lock state of the phone and unlock lock=`dbus-send --system --type=method_call --dest="com.nokia.mce" --print-reply "/com/nokia/mce/request" com.nokia.mce.request.get_tklock_mode|awk -F "\"" '/g/ {print $2}'` call_check dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_tklock_mode_change string:"unlocked" # if operator code is (1) switch to SIM2 if [ $opcode == 1 ]; then sim-switcher SIM2 if [ $? -ne 0 ]; then exit 1 fi fi # Connect Internet dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"Internet" uint32:0 if [ $? -ne 0 ]; then exit 1 fi CONNECTED=true DROPCONN=true sleep 10 fi if [ "$CONNECTED" == "true" ]; then # sync erminig if having connectivity #/usr/bin/erminig -a # sync MfE dbus-send --print-reply --type=method_call --session --dest=com.nokia.asdbus /com/nokia/asdbus com.nokia.asdbus.sync sleep 90 # drop the wifi connection if it was initiated by this script (saves battery) if [ "$DROPCONN" == "true" ]; then call_check dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true fi fi # Switch back to SIM1 if [ $opcode == 1 ]; then sim-switcher SIM1 fi # Lock back if needed if [ "$lock" == "locked" ]; then call_check dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_tklock_mode_change string:"locked" fi
The Following 2 Users Say Thank You to yrannadx For This Useful Post: | ||
![]() |
2012-08-31
, 21:32
|
|
Posts: 4,118 |
Thanked: 8,901 times |
Joined on Aug 2010
@ Ruhrgebiet, Germany
|
#34
|
However, I still believe there is something wrong with saving data for both files:
/home/user/.config/sim-switcher/.tmp/currentSIM
/home/user/.config/sim-switcher/.tmp/home.plugins
sudo apt-get purge sim-switcher sudo apt-get install sim-switcher sudo apt-get purge sim-switcher sudo apt-get install sim-switcher
![]() |
2012-09-05
, 21:54
|
Posts: 138 |
Thanked: 90 times |
Joined on Mar 2012
|
#36
|
![]() |
2012-09-06
, 08:34
|
Posts: 138 |
Thanked: 90 times |
Joined on Mar 2012
|
#37
|
![]() |
2012-09-06
, 11:21
|
Posts: 61 |
Thanked: 64 times |
Joined on Oct 2007
@ EU
|
#38
|
![]() |
2012-09-06
, 13:15
|
Posts: 138 |
Thanked: 90 times |
Joined on Mar 2012
|
#39
|
You should try first the SIM switch by simply dialing the number 001 and 002 from phone application. It should work.
If not working, maybe you need to enable 007 mode by using another phone (N900 don't have SIM Toolkit support).
![]() |
2012-09-06
, 19:26
|
|
Posts: 4,118 |
Thanked: 8,901 times |
Joined on Aug 2010
@ Ruhrgebiet, Germany
|
#40
|
And finally I think I found the reason sim-switcher script is not always working as scheduled job, despite what I thought earlier that this was solved by increasing the delay between down and up. When running in this way (e.g. through Alarmed), the calls for switching the SIMs might be performed with the phone in some sleep or idle state and thus first switch succeed and switching back fails (due to "Calls not allowed" error). This highly depends on how many hours the phone was in idle state, so that is the explanation sometimes the script succeeded and sometimes fails and then I had to run killall csd to be able to switch back. In this situation, reactivate is not working.
Wondering if you have some idea how to wake up the phone in some state similar with the one when using the script through application icon and put that code in the script? I hope this makes sense.