This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Check the amount of mobile account!
#1
Heart 
Has anyone done this before, I need help from you Sad.
I have a prepaid phone sim (In sim have money), inserted in USB3G. And try to use the message through LM3.
One time, I wanted to check in sim phone how much money? Please help me write a script to check this?
I got this idea because I've seen at Alert notification messages to sim phone( pic 1)
I was in Vietnam, I use Viettel sim. Syntax to check the remaining amount is : *101#       or        *102#
Thanks everyone!
Reply
#2
Hi,

I don't think this data is available on the SIM itself.

Normaly you send sms to provider and you reveive the
value back by SMS.

It is possible to receive this reply sms and gsub the data from the received string.

You have to check out what string you need to send to , and what number to use for, your provider to receive the reply.

If you know those 2 items it's easy to create your wish.

BR,

Erwin

Sorry, i see now that you already receive the SMS with the reply.

You can fetch the saldo from the received string by using:

amount = receiveddata:match("stringbeforedatapart(.-)stringafterdatapart")

BR,
Erwin
Reply
#3
you can specify how to do it?
in SmsHander, I need to add this code somewhere. and what to do next.
I'm new employees, should also have little trouble.
thank you very much!
--------
amount = receiveddata:match("stringbeforedatapart(.-)stringafterdatapart")
--------
Reply
#4
Hi,

It should be something like this inside the SMS handler:

Code:
-- incoming sms handler
handler = function(sms)
 alert('incoming sms: [%s] %s', tostring(sms.sender), tostring(sms.data))
  --******************************************
 -- PUT HERE YOUR MATCH TO GET SMS PREPAID VALUE FROM SMS MESSAGE
 local amount = sms.data:match([[va (.-) SMS]])
 if amount ~= nil then
   amount = tonumber(amount)
   -- do something with amount
 end
 -- END MATCH TO GET SMS PREPAID VALUE FROM SMS MESSAGE
 --******************************************
 -- sms from known number, call parser
 if table.contains(numbers, sms.sender) then
   parser(sms.data, sms.sender)
 end
end

Now i fetch the value from the part of text ''va 550 SMS', now the match function grabs the 550 value out of the string, after that i make it a number instead of a string and you can do whatever you want with it.

BR,

Erwin van der Zwart
Reply
#5
Thank you much! Erwin van der Zwart
But I still do not get it.
Now I want to dial * 101 # and then click OK. Then the phone will return "Your account was original 1900 VND" ;It notified the form of a pop-up.
Then, we create an object type:
sendsms ('* 101 #', 'amount of value')
Is it right? Sad
Please teach me, how to check the number
Reply
#6
Hi,

The pop-up is simple, just use inside the handler code i posted the
command alert('current sim value is: ' .. amount) 

The other question is harder, as you want to dail a number to request
the reply SMS. i never tried that before, maybe admin has script for that.

I would check if you can send SMS to request the value reply, if your provider support that
then you can use current sms script to send the request.

BR,

Erwin
Reply
#7
Yes ! as I want to dail a number ( ext *101#) to request
the reply SMS. My provider support that ! Smile
Please help me !
Thank so much Erwin , and every one!
Reply
#8
Hi,

Dail a number can be done by the command ATD*101#

Currently the script is build for SMS and the script uses now the command
AT+CMGS

You need to change the script by using the ATD command. 
If you lookup documentation for AT commands for GSM modem you 
can get all needed info.

I see no usecase for this and are not going to build this myself, so i won't spend
my time on re-writing the sms handler to a dailer.

See: https://www.sparkfun.com/datasheets/Cell...ide_r0.pdf

With this info you have the direction to go for (:

Good luck!
Reply
#9
Please help me! I have some problems.
I see ! When a message arrives (as shown below)
I want to retrieve the message sequence, what should I do?
The purpose is to take that string, to control something (control the lights by SMS).
Can someone help me?

Thank all!
Reply


Forum Jump: