locked
Controlling mobile device using C# and AT command set. RRS feed

  • Question

  • I would like to programmatically register my device on a UMTS network (and alternately register on GSM). I cannot use the RIL commands because they do not support register on network for UMTS. I gather that that leaves me using the AT command set. I have searched and searched for a C# example that successfully sends and receives AT commands and responses in C# but I have turned up nothing. I want to do this internally within a mobile C# application and not via a USB/hyperterminal.

     

    Can someone point me to a working example or give me the rough outline of the steps that would be involved to be successful?

    Thursday, April 7, 2011 10:47 PM

Answers

  • If you have the handle then it is already created and opened. All you have left to do is write to it and read from it. If you need a refresher in C# serial port communications, then take a look at this: "Serial Communication with the .NET Compact Framework" http://msdn.microsoft.com/en-us/library/aa446565.aspx

    If you have a native handle to the serial port, then you may need to P/Invoke WriteFile() and ReadFile() to communicate rather than using the built-in C# Serial Port BCL.
    WriteFile: http://msdn.microsoft.com/en-us/library/aa910675.aspx
    File I/O Reference: http://msdn.microsoft.com/en-us/library/aa914343.aspx

    -PaulH

    • Marked as answer by Jesse Jiang Friday, April 22, 2011 3:45 AM
    Friday, April 8, 2011 1:34 PM

All replies

  • Whether or not you can do this will depend on how your phone is designed. It will not be a universal solution.

    Try using CreateFile(OPEN_EXISTING, ...) / WriteFile() to open the WWAN driver and send AT commands to it. These posts should help:
    http://social.msdn.microsoft.com/Forums/en/vssmartdevicesnative/thread/aa102c36-aa86-45e9-9e27-01b926a207e7
    http://forum.xda-developers.com/archive/index.php/t-256646.html

    Or, if you're lucky, your OEM implemented RIL_GetSerialPortHandle(). That should let you send AT commands.
    http://msdn.microsoft.com/en-us/library/aa922359.aspx

    -PaulH

    • Proposed as answer by Jesse Jiang Wednesday, April 13, 2011 8:43 AM
    Friday, April 8, 2011 4:30 AM
  • I have the serial port handle. In all seriousness, given the handle, what can I do with it (in C#) to access and write/read from the port? I see no way to create/open the port from handle in C#.
    Friday, April 8, 2011 7:58 AM
  • If you have the handle then it is already created and opened. All you have left to do is write to it and read from it. If you need a refresher in C# serial port communications, then take a look at this: "Serial Communication with the .NET Compact Framework" http://msdn.microsoft.com/en-us/library/aa446565.aspx

    If you have a native handle to the serial port, then you may need to P/Invoke WriteFile() and ReadFile() to communicate rather than using the built-in C# Serial Port BCL.
    WriteFile: http://msdn.microsoft.com/en-us/library/aa910675.aspx
    File I/O Reference: http://msdn.microsoft.com/en-us/library/aa914343.aspx

    -PaulH

    • Marked as answer by Jesse Jiang Friday, April 22, 2011 3:45 AM
    Friday, April 8, 2011 1:34 PM
  •  

    Hello,

     

    I'm very interested in hearing more about your issue, did you solve your problem?

    If so please share the solution with us and mark the right answers.

    If not please let me know and I will tray to help you find further solutions.

     

    Have a nice day!

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, April 13, 2011 8:43 AM