Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

GSM Modem Interface?

  • 25-05-2009 6:34pm
    #1
    Registered Users, Registered Users 2 Posts: 8,004 ✭✭✭


    HI Folks,

    Been messing around with a new GSM terminal I got (Siemens TC35i) with HyperTerminal AT commands and it got me thinking. Is there script that one could write where by:

    It could recieve an SMS to interrogate a Serial Port to determine if a switch is closed or open, and then report this by reply SMS?

    A predetermined SMS sent to it could switch a relay attached to a Serial Port?

    Any ideas?

    Thanks,

    ironclaw


Comments

  • Registered Users, Registered Users 2 Posts: 23,212 ✭✭✭✭Tom Dunne


    ironclaw wrote: »
    HI Folks,

    Been messing around with a new GSM terminal I got (Siemens TC35i) with HyperTerminal AT commands and it got me thinking. Is there script that one could write where by:

    It could recieve an SMS to interrogate a Serial Port to determine if a switch is closed or open, and then report this by reply SMS?

    A predetermined SMS sent to it could switch a relay attached to a Serial Port?

    Any ideas?

    What languages do you know, and can they interact with the serial port?

    By the sounds of it, you need code to send/receive the SMS, code to interpret the contents of the SMS and code to send/receive to/from the serial port.

    Easy. :)


  • Registered Users, Registered Users 2 Posts: 8,004 ✭✭✭ironclaw


    Tom Dunne wrote: »
    What languages do you know, and can they interact with the serial port?

    By the sounds of it, you need code to send/receive the SMS, code to interpret the contents of the SMS and code to send/receive to/from the serial port.

    Easy. :)

    Have a rough idea of a few languages. What would be best in your opinion? Its going to be running on an XP machine.


  • Registered Users, Registered Users 2 Posts: 23,212 ✭✭✭✭Tom Dunne


    ironclaw wrote: »
    Have a rough idea of a few languages. What would be best in your opinion? Its going to be running on an XP machine.

    C++ would be the obvious one.

    I don't know enough about Java/C# to say if they would be any good for something like this.


  • Registered Users, Registered Users 2 Posts: 8,004 ✭✭✭ironclaw


    Tom Dunne wrote: »
    C++ would be the obvious one.

    I don't know enough about Java/C# to say if they would be any good for something like this.

    Thats the road I was sorta taking myself. Summer project so :)


  • Registered Users, Registered Users 2 Posts: 7,518 ✭✭✭matrim


    You could check out an opensource project called kannel which is an SMS gateway.

    It would probably be a good place to get some info on the SMS processing


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 8,004 ✭✭✭ironclaw


    matrim wrote: »
    You could check out an opensource project called kannel which is an SMS gateway.

    It would probably be a good place to get some info on the SMS processing

    I looked into it but it seemed more web based. I'm looking for something that will read a text and perform a command based on the content e.g. Close a relay.

    Thanks for the info though!


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    ironclaw wrote: »
    I looked into it but it seemed more web based. I'm looking for something that will read a text and perform a command based on the content e.g. Close a relay.

    Thanks for the info though!

    The Telus GSM modules will allow you to write/run scripts on them, to read/write i/o pins etc....

    Most GSM modules are dumb devices, which you need to control over the serial port (using AT commands), typically from an embedded micro controller, which would do the reading of I/O etc...


  • Registered Users, Registered Users 2 Posts: 456 ✭✭onedmc


    Does it not ship with an Active Expert API. I think that other Siemens terminals used to.


  • Registered Users, Registered Users 2 Posts: 8,004 ✭✭✭ironclaw


    onedmc wrote: »
    Does it not ship with an Active Expert API. I think that other Siemens terminals used to.

    I think thats extra. I got it off a mate who was throwing it out funnily enough.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    You could get a small microchip/atmel dev kit and write a bit of C-code to spit out the AT commands etc.... If your not familiar with that side of things, it would be a good way to learn.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,426 ✭✭✭ressem


    .Net would probably be easiest now that there exists System.IO.Ports.SerialPort , havn't tried it though.

    ----
    Alternatives
    In unix/linux you can do this sort of thing using CU, part of the UUCP package.

    #install the cu program
    yum install uucp
    #set serial parameters
    stty 19200 cs8 -parenb -cstopb crtscts echo -F /dev/ttyS0
    #open terminal for scripting
    cu -l ttyS0

    There might be a version written for cygwin/ windows, or not.
    ----

    In Java you can use the javax.comm library.
    Sun have an old sample program SerialConnection.java which will help with the basics of setting up listeners
    You set up the device to notify you when it gets a message. You just need to make sure to keep deleting out the old messages as there is a limit of about 10 stored on the device.

    AT Commands you might make use of...
    // Request Notification from TC35
       write("AT+CNMI=2,1,0,0\n");
       // Used to be AT+CNMI=2,1,0,0,0 but TC35 does not support last char = 0. Only 1
    		
    // List SMSes and their content from buffer
        write("AT+CMGL=\"ALL\"");
    
    
    // @param message -- SMS Message content to send to the terminal
    // @param destination -- destination number
    
        AT+CMGS=\""+destination+"\"\n
        // There should be a > response from the terminal, after which you write
        "message"+"\032"
    
    
    //  Write the GSM AT+CMGF=1 command to the terminal.
    // This is necessary after any start or restart of the terminal. 
    // Otherwise texts will be returned in a machine readable GSM PDU format.
    
    	AT+CMGF=1
    			
    // Delete Message
    	AT+CMGD=<number>
    
    


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    I did this in VB way back in 2001... Will see if I can dig up the code...

    It was originally for the Siemens GSM modem, then I modded it for IR and Nokia phones..


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Oki doki dug out the code

    2 simple VB functions

    First one is the one reposible for setting up the modem and creating the commands.

    This function just sends an SMS to a particlar number (using the Meteor exchange) change that number for yourself. Needs the modem to be on Com port 1

    The main things to notice are the AT commands for sending the SMS message. You need to first establish the connection and then set the outgoing exchange number followed by the recipients number.

    After that this is the doozy you need to send teh modem the SMS followed by ^z followed by the final command which will initiate the send to the number.
    
    
    Public Function SendSMS(strRecipient, strSMS) As Boolean
    
    MSComm1.CommPort = 1
    MSComm1.Settings = "9600,N,8,1"
       
    MSComm1.PortOpen = True
        
    If Err Then
           SendSMS = False
           Exit Function
    End If
        
    Dim strCommandSet As String
      
    strCommandSet = "AT+CMGF=1;" + vbCr
        
    If (RunATCommand(MSComm1, strCommandSet, "OK")) Then
        strCommandSet = "AT+CSCA=" & Chr(34) & "+353857000000" & Chr(34) & ";" & vbCr
        If (RunATCommand(MSComm1, strCommandSet, "OK")) Then
            strCommandSet = "AT+CMGS=" & Chr(34) & strRecipient & Chr(34) & ";" & vbCr
            If (RunATCommand(MSComm1, strCommandSet, ">")) Then
                strCommandSet = strSMS & Chr(26)
                If (RunATCommand(MSComm1, strCommandSet, "OK")) Then
                    SendSMS = True
                Else
                    SendSMS = False
                End If
            Else
                SendSMS = False
            End If
        Else
            SendSMS = False
        End If
    Else
        SendSMS = False
    End If
    
    MSComm1.PortOpen = False
    
    End Function
    
    

    This next function sends the command to the modem and checks the returns etc...
    Function RunATCommand(objModem As MSComm, strCommand As String, strCompare As String) As Boolean
        
    Dim blExitLoop          As Boolean
    Dim varEvents           As Variant
    Dim strModemString      As String
    
    blExitLoop = False
        
    If Len(strCommand) <= 0 Or Len(strCompare) <= 0 Then
        RunATCommand = False
        Exit Function
    End If
        
    objModem.InBufferCount = 0
    objModem.Output = strCommand
        
    Do While Not (blExitLoop)
        'varEvents = DoEvents
        
        If objModem.InBufferCount Then
            strModemString = strModemString + objModem.Input
                     
            If InStr(1, strModemString, "ERROR", vbTextCompare) Then
                blExitLoop = True
                RunATCommand = False
            End If
            
            If InStr(1, strModemString, strCompare, vbTextCompare) Then
                blExitLoop = True
                RunATCommand = True
            End If
        
        End If
    
    Loop
        
    End Function
    
    

    Hope it helps


Advertisement