Notices


Reply
Thread Tools
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#11
Nice work, peterleinchen! It just *begs* for being in repositories
__________________
N900's aluminum backcover / body replacement
-
N900's HDMI-Out
-
Camera cover MOD
-
Measure battery's real capacity on-device
-
TrueCrypt 7.1 | ereswap | bnf
-
Hardware's mods research is costly. To support my work, please consider donating. Thank You!
 

The Following 2 Users Say Thank You to Estel For This Useful Post:
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#12
Added following comment (forgotten on OP):

Giveaway functionality:
- saving and restoring plugins/widgets/desktop
sometimes necessary after crash/kill of hildon-home (seldom hildon-desktop). In x-term call
Code:
sim-switcher savehome
to save your layout (automatically done on installation) and
Code:
sim-switcher restorehome
to restore your layout after sth has gone wrong badly.


There may follow more ...
 

The Following 3 Users Say Thank You to peterleinchen For This Useful Post:
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#13
Originally Posted by Estel View Post
Nice work, peterleinchen! It just *begs* for being in repositories
Your wish is my command !

You may find it now in the repos (atm devel, promoted to testing).

Last edited by peterleinchen; 2012-08-07 at 17:51.
 

The Following 4 Users Say Thank You to peterleinchen For This Useful Post:
Posts: 61 | Thanked: 64 times | Joined on Oct 2007 @ EU
#14
@peterleinchen, thanks your application works fine.

However, if you have some experience with switching SIMs, maybe you can help with the following use case: I want to switch to SIM2, synchronize Exchange and then switch back to SIM1, all of this with Alarmed application that runs regularly the below script.

For some reason, if I am using in script the code "sudo /opt/sim-switcher/phonet-helper down and then up", the phone remains with SIM2, and when I am trying some call I get "Call not allowed" message. Only after I am running from command line "sudo killall csd" I can switch back to SIM1.

If instead of phonet0 down I am using "run-standalone.sh dbus-send --system --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call com.nokia.csd.Call.Release", the script switches fine to SIM2, sync and back to SIM1, but after a few runs, I still get to the above situation.

Any help with this would be appreciated. Thanks.

Code:
#!/bin/sh

CONNECTED=false
DROPCONN=false

# 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
    run-standalone.sh 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 [ "$CONNECTED" == "true" ]; then
  # sync erminig if having connectivity
  #/usr/bin/erminig -a

  # sync MfE
  run-standalone.sh 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
    run-standalone.sh dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true
  fi
else
  # 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
    sudo /opt/sim-switcher/phonet-helper down
    sleep 7
    sudo /opt/sim-switcher/phonet-helper up
    sleep 22
  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 8
  
    # 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
      sudo /opt/sim-switcher/phonet-helper down
      sleep 7
      sudo /opt/sim-switcher/phonet-helper up
    fi
  fi
fi
 

The Following User Says Thank You to yrannadx For This Useful Post:
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#15
New version in testing.
Added parameter "oper" in config file to add the operator name for specific SIM. Will be shown as name for desktop icon.
Keep it short, less than 9 chars, and please do NOT use blanks (but put underlines or such, e.g. "VF_de" instead of "VF de") in that parameter.
 

The Following 2 Users Say Thank You to peterleinchen For This Useful Post:
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#16
@yrannadx
Nice one, too.

I can only think of timing problems, maybe the 7 seconds is not enough between down and up. I had same problesm, but after setting to 7 seconds it always worked out for me. Do you have high loads?

And the CallRelease just ends the call, no more. It may be there, but it is not needed, as shutting down phonet0 is doing the same (OK, almost).
Shutting down the telephony system (and enabling again) will bring up the switch. So I am curious how you are able to switch without bringing down?

Oh and one more about timing. Maybe also increase he sleep between bringing up the call and shutting down. Maybe your adapter needs more time to detect ...

Either way let me know, to make mine more stable, please.
But you said my method works for you?


Oh and about 'killall csd': that was my first very early approach and it worked out. But after a few switches I ran into troubles also (do not remember exactly, but I think it was about internet connectivity / telephony unavailable).

--
Maybe found your issue: imagine going into your script with SIM2 active! Then opcode1 will be 10 and opcode2 will be 10 also. So at the end of script there is no instruction to switch back to SIM1 ...

Last edited by peterleinchen; 2012-08-11 at 00:18.
 

The Following 2 Users Say Thank You to peterleinchen For This Useful Post:
Posts: 61 | Thanked: 64 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
 
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#18
@yrannadx

If it is intended (not go back to SIM1, if started withSIM2) then it seems OK.

Let me guess: you do not have PIN code enabled on second SIM, but you do have on SIM1?
In that case the switching to SIM2 occurs immediately after the call release. And a phonet down/up is not necessary (but do not harm either).
So in that/your case just omit down/ups for switch to second SIM and it should work. But it should work also with my approach. What about using command line 'sim-switcher SIM1' in your script (in config file only the switch code)?

So in short:
Never use killall csd, it will create internet (access point) problems.
If there is no PIN code query enabled, switching occurs without any interaction (but it works with my method, too).

-- more edit
I have some extension ready to let my script wait if there is no cell radio connection available. In my case I do need the SIM to be online to successfully switch. Please let me know if that is valid for your adapter too (go into offline mode and dial 002 and see if the SIM switches, I expect not).

Last edited by peterleinchen; 2012-08-22 at 21:54.
 
Posts: 61 | Thanked: 64 times | Joined on Oct 2007 @ EU
#19
@peterleinchen

Actually none of the SIMs have PIN code enable so that's the explanation.

On the other hand, it seems none of the methods are working after all. Nor my above attempts, nor calling 'sim-switcher SIM1 and 2' in the script. It is strange why first attempt of running the script succeeded (when using sim-switcher) and second attempt fail with SIM2 remaining active and when I am trying a normal call with SIM2 I get call not allowed (although your script display wrongly the message of successfully switch). This means also that switching back to SIM1 is not possible without using killall csd or reboot. Maybe the sync is causing this strange behavior, otherwise I see no logical explanation for this.

The next method I will try is to separate totally the actions of switch SIM and sync, i.e. to switch first the SIM 3 minutes before the sync with Alarmed, do the sync and switch back 3 minutes after the sync with Alarmed as totally independent actions.

Regarding your note, I cannot dial 002 in offline mode to switch SIM.
 
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#20
Hey yrannadx,

one question at first:
my app is working for you? So using sim-switcher switches from SIM1 to SIM2 and vice versa?

How do you verify your script dows not switch back to SIM1?
Do not rely on operator name shown on hildon-home!


In your script there is some flaw, which should not cause your behaviour, but who knows?

Switch your code to:
Code:
.
.
.
    # 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
  
    # 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
    sleep 1
    sudo /opt/sim-switcher/phonet-helper down
    sleep 7
    sudo /opt/sim-switcher/phonet-helper up
    sleep 20
    fi
  fi
fi
or maybe:
Code:
.
.
.
    # 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
  
    # 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
#    sleep 1
#    sudo /opt/sim-switcher/phonet-helper down
#    sleep 7
#    sudo /opt/sim-switcher/phonet-helper up
#    sleep 20
    fi
  fi
fi
 

The Following 2 Users Say Thank You to peterleinchen For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 07:48.