How to use a mobile provider's UUSD code service via an automated process?

吃可爱长大的小学妹 提交于 2020-01-06 05:26:15

问题


If I have a SIM card from a mobile operator - for example, Vodacom in South Africa, I can use their USSD services via dialling *111#. Then I can navigate the options via using my mobile phone keyboard.

I would like to create a script that does this in an automated way. Is there a way to do this?

I see this is possible on an Android application (Make USSD call in android). Is there a way to consume a specific mobile operator's UUSD service without first purchasing a SIM card from that operator? (i.e. running this from a server over http/tcp).


回答1:


To access the USSD menu you need to be on the mobile network. USSD is not internet, nor even data network. USSD is transported on mobile signaling network. Thus you need to have a SIM.

To navigate on a USSD menu via scripts, you may need few steps.

  • You need a GSM device connected to your computer. A USB Modem is OK but all modems don't have this functionality. I have been using a Huawei 180E model.

  • You'll need to talk to your modem over a serial line. On Linux, USB Modems can be reached as tty devices, typically on /dev/ttyUSB0 (there is no absolute rule: some models only define 2 devices, some models define 4). For tests, you can use some terminal software. I use miniterm.py, a Python program, but minicom is OK as probably many others. For automation you may need a serial library for your preferred language. On the command line, there is atinout but I didn't manage to make it work properly, socat - /dev/ttyUSB0 should also work.

  • Finally, to talk to your modem, you need to use the Hayes Modem AT commands. You can read the AT command reference [3GPP 27.007][1], chapter 7.15 for a formal documentation, but basically, sent to the modem (without the #... part):

    ATZ                     # to reset the modem
    AT+CUST=2               # to close any ongoing USSD session
    AT+CUSD=1,"#111#",15    # to initiate the navigation
    

    and if you get the menu, you're fine; if not, well, things are not desperate, but it may be more difficult as you'll probably need to play with character encoding.

    [1]: https://www.etsi.org/deliver/etsi_ts/127000_127099/127007/10.03.00_60 (/ts_127007v100300p.pdf



来源:https://stackoverflow.com/questions/52290487/how-to-use-a-mobile-providers-uusd-code-service-via-an-automated-process

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!