View Single Post
Posts: 60 | Thanked: 61 times | Joined on Oct 2007 @ EU
#17
@peterleinchen

Maybe it depends of SIM adapter. My one is Magicsim 28th and the switch actually works fine just by using CallRelease without calling phonet0 down and up. But of course the SIM switch works also with your method, phonet0 down and up, as well as with killall csd.

I tried different timings and so on and it was not working. The new code that seems to work is to use CallRelease after calling the switch code and using once the phonet0 down and up after "Disconnect SIM2 Internet" command. Maybe connecting and disconnecting the internet is the problem that prevented the switch back to SIM1 after that.

if opcode1 is 10 and opcode2 is 10 also, then that is the intended behavior of the script, to remain with SIM2 and not to switch back, so I think the script is OK.

I will try for few days the new code to see if it works after several switches combined with normal phone usage.

Code:
  # Try with SIM2
  opcode1=`run-standalone.sh 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' '`
  #echo $opcode
  # if operator code is SIM1 (1) switch to SIM2 (10)
  if [ $opcode1 == 1 ]; then
    run-standalone.sh dbus-send --system --dest=com.nokia.csd.Call --type=method_call --print-reply /com/nokia/csd/call com.nokia.csd.Call.CreateWith string:"002" uint32:0
    sleep 1
    run-standalone.sh dbus-send --system --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call com.nokia.csd.Call.Release
    sleep 20
  fi
  opcode2=`run-standalone.sh 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' '`
  # if operator code is SIM2 (10)
  if [ $opcode2 == 10 ]; then
    # Connect to SIM2 Internet
    echo "Connect SIM2 Internet"
    run-standalone.sh dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"SIM2 Internet" uint32:0
    sleep 30
    # Sync emails
    echo "Start Sync"
    run-standalone.sh dbus-send --print-reply --type=method_call --session --dest=com.nokia.asdbus /com/nokia/asdbus com.nokia.asdbus.sync
    sleep 104
    # Disconnect SIM2 Internet
    echo "Disconnect SIM2 Internet"
    run-standalone.sh dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true
    sleep 1
    sudo /opt/sim-switcher/phonet-helper down
    sleep 7
    sudo /opt/sim-switcher/phonet-helper up
    sleep 20
  
    # Switch to SIM1
    if [ $opcode1 == 1 ]; then
      run-standalone.sh dbus-send --system --dest=com.nokia.csd.Call --type=method_call --print-reply /com/nokia/csd/call com.nokia.csd.Call.CreateWith string:"001" uint32:0
      sleep 1
      run-standalone.sh dbus-send --system --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call com.nokia.csd.Call.Release
    fi
  fi
fi