.. ModemDriver documentation master file, created by sphinx-quickstart on Sun Jul 14 21:02:34 2013. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. ModemDriver's documentation! ============================ A GSM modem has three main functions: SMS, USSD, and the SIM Toolkit. Special modem for CDMA can only receive and send SMS. Send SMS ======== Let's create a text file named ``sms.txt`` to send SMS:: msisdn: +628123456789 Reply this message please. Thank you. then run this command:: python ModemDriver.py -d /dev/ttyUSB0 -p sms.txt and the output like this:: -> AT+CMGS="+628123456789" -> Reply this message please. Thank you. <- +CMGS: 22 <- OK 22 Number 22 indicates memory chip index. The range is 0-255 that indicates the message was successfully sent. Receive SMS =========== You can read and store SMS in ``/tmp`` directory using this command:: python ModemDriver.py -d /dev/ttyUSB0 -g /tmp The result like this:: -> AT+CNMI=0,1,1,1,0 <- AT+CNMI=0,1,1,1,0 <- OK -> AT+CMGF=0 <- AT+CMGF=0 <- OK -> AT+CIMI <- AT+CIMI <- 510012541218911 <- OK -> AT+CMGL=4 <- AT+CMGL=4 <- +CMGL: 1,0,,44 <- 06912618010000240C912618911966690000317051503000231CCF350B94048DC36E90BC1C2683F2EFBA1CD42ECFE7E173D905 <- OK Receive {'msisdn': '+628123456789', 'message': u'Ok, I can read your message.', 'group': 0, 'time': '2013-07-14 21:03:00+0'} Save to /tmp/510012541218911_+628123456789_201307142103000.txt -> AT+CMGD=1 <- AT+CMGD=1 <- OK File is stored with name format ``IMEI_MSISDN_DATETIME.txt`` where IMEI is a SIM card identification number. The file contains like this:: imei: 510012541218911 group: 0 time: 2013-07-14 21:03:00+0 msisdn: +628119916696 Ok, I can read your message. Message is deleted from the SIM card when the file was successfully saved. Send USSD ========= Send USSD request like this example:: python ModemDriver.py -d /dev/ttyUSB0 -u "*388#" The output like this:: -> AT+CUSD=1 <- AT+CUSD=1 <- OK -> AT+CUSD=1,"*388#" <- AT+CUSD=1,"*388#" <- OK <- +CUSD: 2,"PulsaUTAMA Rp.4402. Aktif 12/08/13, Tenggang 11/09/13. SMS Harian 0 SMS ke ISAT & 0 SMS ke Oprtr lain. Ktk GRATIS ke123,GRATIS Nelp+SMS+Data",15 message: PulsaUTAMA Rp.4402. Aktif 12/08/13, Tenggang 11/09/13. SMS Harian 0 SMS ke ISAT & 0 SMS ke Oprtr lain. Ktk GRATIS ke123,GRATIS Nelp+SMS+Data Using SIM Toolkit Application ============================= In GSM modem we can use SIM toolkit application on the SIM card. To display the main menu use this command:: python ModemDriver.py -d /dev/ttyUSB0 -a "" and the output is:: -> AT+CFUN=1 <- AT+CFUN=1 <- OK -> AT+CMGF=0 <- AT+CMGF=0 <- OK <- +STIN: 0 -> AT+STSF=1 <- AT+STSF=1 <- OK -> AT+STGI=0 <- AT+STGI=0 <- +STGI: "M3-Access" <- +STGI: 254,10,"Registrasi",0 <- +STGI: 1,10,"M-Info&News",0 <- +STGI: 2,10,"M-Banking",0 <- +STGI: 3,10,"M-Travel",0 <- +STGI: 4,10,"M-Fun",0 <- +STGI: 5,10,"M-Office",0 <- +STGI: 6,10,"My GSM",0 <- +STGI: 7,10,"My Favourite",0 <- +STGI: 8,10,"Menu Edit",0 <- +STGI: 9,10,"My GSM",0 <- OK M3-Access,M-Info&News,M-Banking,M-Travel,M-Fun,M-Office,My Favourite,Menu Edit,My GSM,Registrasi Suppose you will go to ``M-Banking`` menu then the command becomes:: python ModemDriver.py -d /dev/ttyUSB0 -a "M-Banking" The result is:: -> AT+STSF=? <- AT+STSF=? <- +STSF: (0-2),(160060C01F-5FFFFFFF7F),(1-255),(0-1) <- OK -> AT+STSF=2,"5FFFFFFF7F",3,0 <- AT+STSF=2,"5FFFFFFF7F",3,0 <- OK -> AT+CFUN=1 <- AT+CFUN=1 <- OK -> AT+CMGF=0 <- AT+CMGF=0 <- OK <- +STIN: 0 -> AT+STSF=1 <- AT+STSF=1 <- OK -> AT+STGI=0 <- AT+STGI=0 <- +STGI: "M3-Access" <- +STGI: 254,10,"Registrasi",0 <- +STGI: 1,10,"M-Info&News",0 <- +STGI: 2,10,"M-Banking",0 <- +STGI: 3,10,"M-Travel",0 <- +STGI: 4,10,"M-Fun",0 <- +STGI: 5,10,"M-Office",0 <- +STGI: 6,10,"My GSM",0 <- +STGI: 7,10,"My Favourite",0 <- +STGI: 8,10,"Menu Edit",0 <- +STGI: 9,10,"My GSM",0 <- OK -> AT+STGR=0,1,2 <- AT+STGR=0,1,2 <- OK <- +STIN: 6 -> AT+STGI=6 <- AT+STGI=6 <- +STGI: 0,"M-Banking" <- +STGI: 1,5,"m-BCA",0 <- +STGI: 2,5,"m-Permata",0 <- +STGI: 3,5,"m-B_Mandiri",0 <- +STGI: 4,5,"m-MEGA",0 <- +STGI: 5,5,"Matrix-BNI",0 <- OK M-Banking,m-BCA,m-Permata,m-B_Mandiri,m-MEGA,Matrix-BNI Then we will go to ``m-BCA`` sub-menu. Use comma as separator between menus:: python ModemDriver.py -d /dev/ttyUSB0 -a "M-Banking,m-BCA" you get:: ... ... <- +STGI: 0,"M-Banking" <- +STGI: 1,5,"m-BCA",0 <- +STGI: 2,5,"m-Permata",0 <- +STGI: 3,5,"m-B_Mandiri",0 <- +STGI: 4,5,"m-MEGA",0 <- +STGI: 5,5,"Matrix-BNI",0 <- OK -> AT+STGR=6,1,1 <- AT+STGR=6,1,1 <- OK <- +STIN: 6 -> AT+STGI=6 <- AT+STGI=6 <- +STGI: 0 <- +STGI: 1,5,"m-Info",0 <- +STGI: 2,5,"m-Transfer",0 <- +STGI: 3,5,"m-Payment",0 <- +STGI: 4,5,"m-Commerce",0 <- +STGI: 5,5,"m-Admin",0 <- OK m-Info,m-Transfer,m-Payment,m-Commerce,m-Admin When the application asks you to put something like a PIN ``123456``:: python ModemDriver.py -d /dev/ttyUSB0 -a "M-Banking,m-BCA,m-Info,Info Saldo,123456" the output is:: ... ... <- +STGI: 0,"m-Info:" <- +STGI: 1,5,"Info Saldo",0 <- +STGI: 2,5,"Mutasi Rek",0 <- +STGI: 3,5,"Info K-Kredit",0 <- +STGI: 4,5,"Info Kurs",0 <- +STGI: 5,5,"Lainnya",0 <- OK -> AT+STGR=6,1,1 <- AT+STGR=6,1,1 <- OK <- +STIN: 3 -> AT+STGI=3 <- AT+STGI=3 <- +STGI: 0,0,1,6,0,"PIN:" <- OK -> AT+STGR=3,1 <- AT+STGR=3,1 <- > -> 123456 <- 123456 <- OK <- +STIN: 9 -> AT+STGI=9 <- AT+STGI=9 <- +STGI: "Sending..." <- OK Send SMS Another type of input is confirmation. You can use reserved word ``OK`` to do this.