I have been using scampers library to send and receive SMS through a GSM modem. It is working pretty much the way I wanted. But the problem I stuck with is I can not issue command like *101# or similar, after doing some research I found these command are called USSD command. So my question is, has anyone been able to issue USSD command through Scampers library.
GsmComm USSD command
USSD is a different protocol than SMS so you can't use an SMS centric library to send USMD messages. It would be like trying to send http requests from an ftp client library.
Here's an example using SMSLib for .net (hope that's what you wanted) groups.google.com/group/smslib-dotnet/browse_thread/thread/… smslib.org/doc/smslib/dotnet –
Euphemism
@Euphemism , the group link appears to be broken. can you provide any other reference? –
Kirkpatrick
This worked quite nicely for me using GsmComm:
public string SendUssdRequest(string request)
{
string data = TextDataConverter.StringTo7Bit(request);
var asPDUencoded = Calc.IntToHex(TextDataConverter.SeptetsToOctetsInt(data));
try
{
IProtocol protocol = _comm.GetProtocol();
string gottenString = protocol.ExecAndReceiveMultiple("AT+CUSD=1," + asPDUencoded + ",15");
var re = new Regex("\".*?\"");
int i = 0;
if (!re.IsMatch(gottenString))
{
do
{
protocol.Receive(out gottenString);
++i;
} while (!(i >= 5
|| re.IsMatch(gottenString)
|| gottenString.Contains("\r\nOK")
|| gottenString.Contains("\r\nERROR")
|| gottenString.Contains("\r\nDONE"))); //additional tests "just in case"
}
string m = re.Match(gottenString).Value.Trim('"');
return PduParts.Decode7BitText(Calc.HexToInt(m));
}
catch { }
finally
{
_comm.ReleaseProtocol();
}
return "";
}
How can i find port number for _comm and if i set default port number by GsmComm.defaultportnumber then i only received that exception "Communication thread isn't running". –
Alessi
What is the type of
_comm
? –
Kirkpatrick hi, when i use your code i get this exception: "Message = "Mobile equipment error 50 occurred." what's the problem? i think you change some settings for _comm object before sending request. –
Assegai
the type of _comm is a GsmCommMain
using GsmComm.GsmCommunication;
using GsmComm.PduConverter;
using GsmComm.PduConverter.SmartMessaging;
GsmCommMain _comm;
You should post a comment, not just plain code in order to make a good answer. –
Allveta
© 2022 - 2024 — McMap. All rights reserved.