Community discussions

MikroTik App
 
bashtux
just joined
Topic Author
Posts: 3
Joined: Sat Jan 29, 2011 1:25 pm

Send AT Commands to modem via script

Sat Jan 29, 2011 1:31 pm

I want to do something but have no idea how....

I am familiar with MikroTik scripting but what I want to do is, have a script that will be able to send an AT command to the modem connected on the board and parse the output given for the command to a variable.

I want to for instance send a USSD (AT+CUSD) command to the modem which will check the account balance of the SIM card in the modem and then use it to email the balance given. I have absolutely no idea how to access the modem and interactively do this via a script.

Any help or pointers in the correct direction will be appreciated.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Send AT Commands to modem via script

Mon Jan 31, 2011 12:34 pm

please see '/interface ppp-client' menu where you can add ppp client for some port, like serial, or, if you have connected some USB port so you can do dial out.
 
bashtux
just joined
Topic Author
Posts: 3
Joined: Sat Jan 29, 2011 1:25 pm

Re: Send AT Commands to modem via script

Mon Jan 31, 2011 9:10 pm

I don't think this is what I am asking....

I want to send a command to the modem via interface connected e.g. usb2

The command is something like this:
AT+CUSD=1,"*101#",15

If I do this command in a terminal on the RouterBoard connected to the modem it works fine. The command is a USSD command that returns the current account balance of the 3G card.

What I want to do now is to do this command via a script and the output of the command must then be parsed and stored in a variable so I can email the contents to someone. How to do the rest, e.g. send the email etc I know how but I do not know how to parse this command's output that is returned from the ISP back to a variable.
 
bashtux
just joined
Topic Author
Posts: 3
Joined: Sat Jan 29, 2011 1:25 pm

Re: Send AT Commands to modem via script

Thu Feb 03, 2011 11:20 pm

Any Possible help?
 
kawaters
just joined
Posts: 4
Joined: Fri Sep 16, 2011 4:31 pm

Re: Send AT Commands to modem via script

Wed Sep 21, 2011 4:20 pm

USSD, even in a limited form, like for simple queries (balance lookup) would be a GREAT feature to have.

I can imagine it must be possible to talk to the modem as it presents multiple virtual serial ports to the router.

Please note that a similar feature: sending and receiving an SMS, is already supported: http://wiki.mikrotik.com/wiki/Manual:Tools/Sms

To talk to the modem directly, you can use /system serial-terminal usb2 channel=

Tags: mikrotik, USSD, pre-paid, prepaid, airtime, balance, *100#, *101#
 
kawaters
just joined
Posts: 4
Joined: Fri Sep 16, 2011 4:31 pm

Re: Send AT Commands to modem via script

Wed Sep 21, 2011 4:36 pm

I quote from http://mybroadband.co.za/vb/archive/ind ... 271fc81707
What you do is redirect the terminal to one of the secondary serial ports on the modem (diagnostic or UI ports) as follows:

/system serial-terminal usb2 channel=2
Your usb port and channel may be different, follow the above link for the procedure to list the ports and channels.

You then can send USSD commands directly over the terminal, for example to check your Vodacom balance:

AT+CUSD=1,"*111*500#",15

When you are done, disconnect from the modem's serial port by pressing Ctrl-A followed by Q.
 
konerld
just joined
Posts: 2
Joined: Fri Feb 23, 2018 1:31 pm

Re: Send AT Commands to modem via script

Sat Feb 24, 2018 10:40 pm

I want to do something but have no idea how....

I am familiar with MikroTik scripting but what I want to do is, have a script that will be able to send an AT command to the modem connected on the board and parse the output given for the command to a variable.

I want to for instance send a USSD (AT+CUSD) command to the modem which will check the account balance of the SIM card in the modem and then use it to email the balance given. I have absolutely no idea how to access the modem and interactively do this via a script.

Any help or pointers in the correct direction will be appreciated.
Hi did you find the solution of your question?
thanks

Who is online

Users browsing this forum: sch and 71 guests