This is a console for interacting with Vodafone dongles.

Dependencies:   mbed-rtos VodafoneUSBModem mbed

This is a bridge between a serial driven console and a serial driven cellular modem or modem interface. This was written to complement our collaboration with mbed: See https://mbed.org/users/mbed_official/code/VodafoneUSBModem/ for further information.

For example, one can use GNU screen or PuTTY (two popular consoles) to interact with a Vodafone K3770 USB dongle. In the image below I used the UNIX version of PuTTY:

/media/uploads/ashleymills/atcons.png

Support is provided for line-based consoles, which send one line at a time, and for character based consoles.

For character based consoles, the following line-editing features are provided:

  • In-line editing (deletion, left/right arrow keys, insertion)
  • Command history (via up/down arrow keys)

Line buffer length, and command history depth, are compile-time options.

--

How to use:

Compile and save to mbed.

Connect PuTTY or GNU screen to serial port.

If you use GNU screen you probably already know what you are doing.

If you use PuTTY, you need to set the options to specify the serial device and, set the baud rate, and set the "Connection Type" to "Serial":

/media/uploads/ashleymills/putty0.png

You need to set the keyboard to send Control-H for backspace, and use "Linux" function keys and keypad:

/media/uploads/ashleymills/putty1.png

ATConsole.h

Committer:
ashleymills
Date:
2013-09-25
Revision:
14:3f5fd1d95f5f
Parent:
11:76ecb8799b0d

File content as of revision 14:3f5fd1d95f5f:

/* ATConsole.h */
/* Copyright (C) 2012 Ashley Mills, MIT License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
 * and associated documentation files (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#pragma once
#include "Console.h"
#include "VodafoneUSBModem.h"
/** Console for interacting with Vodafone USB (K3770/K3772-Z) dongles.
 */
class ATConsole : public Console, public IATCommandsProcessor, protected IATEventsHandler  {
    public:
    
        /** Constructor
         * @param terminal Console interface to the driving computer.
         * @param lineLength The maximum length of line supported (character console only).
         * @param numLines Number of lines of history to keep (character console only).
         * @param characterBased true if the driving console is character based, false if line based.
         * @param atInterface A Pointer to the ATInterface of the modem. 
         * @return An ATConsole
         */
        ATConsole(
           Serial *terminal,
           int lineLength,
           int numLines,
           bool characterBased,
           ATCommandsInterface* atInterface
        );
        ~ATConsole();
        virtual void update();
        
    private:  
        ATCommandsInterface *_atInterface;
        ATCommandsInterface::ATResult _cmdResult;
        virtual void processCommand();
        virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line);
        virtual int onNewEntryPrompt(ATCommandsInterface* pInst);
        bool _gettingSMSData;
        char _smsMessage[256];
        
    protected:
        virtual void onEvent(const char* atCode, const char* evt);
        virtual void onDispatchStart();
        virtual void onDispatchStop();
        virtual bool isATCodeHandled(const char* atCode);
        virtual char* getEventsEnableCommand();
        virtual char* getEventsDisableCommand();
        
};