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

Committer:
ashleymills
Date:
Fri Aug 24 15:45:35 2012 +0000
Revision:
2:8cc63f7a24cf
Parent:
1:719c0f047c34
Child:
3:6b3ca3af97cf
Added eventlistener capability

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ashleymills 0:6c831cc49d22 1 #include "ATConsole.h"
ashleymills 2:8cc63f7a24cf 2 #include "ATCommandsInterface.h"
ashleymills 0:6c831cc49d22 3
ashleymills 1:719c0f047c34 4 ATConsole::ATConsole(Serial *terminal, int lineLength, int numLines, ATCommandsInterface* atInterface)
ashleymills 1:719c0f047c34 5 : Console(terminal,lineLength,numLines), _atInterface(atInterface) {
ashleymills 2:8cc63f7a24cf 6 //_atInterface->registerEventsHandler(this);
ashleymills 2:8cc63f7a24cf 7 _gettingSMSData = false;
ashleymills 0:6c831cc49d22 8 }
ashleymills 0:6c831cc49d22 9
ashleymills 0:6c831cc49d22 10 ATConsole::~ATConsole() {
ashleymills 0:6c831cc49d22 11
ashleymills 0:6c831cc49d22 12 }
ashleymills 0:6c831cc49d22 13
ashleymills 0:6c831cc49d22 14 void ATConsole::processCommand() {
ashleymills 2:8cc63f7a24cf 15 _terminal->printf("process command");
ashleymills 2:8cc63f7a24cf 16 if(_gettingSMSData) {
ashleymills 2:8cc63f7a24cf 17 _terminal->printf("process command");
ashleymills 2:8cc63f7a24cf 18 _gettingSMSData = false;
ashleymills 2:8cc63f7a24cf 19 return;
ashleymills 2:8cc63f7a24cf 20 }
ashleymills 2:8cc63f7a24cf 21
ashleymills 0:6c831cc49d22 22 if((strncmp(_lineBuffer,"h",_lineLength)==0)||
ashleymills 0:6c831cc49d22 23 (strncmp(_lineBuffer,"help",_lineLength)==0)) {
ashleymills 1:719c0f047c34 24 _terminal->printf("Help.\r\n");
ashleymills 1:719c0f047c34 25 _terminal->printf(" \"connect\": Connect to 3G network.\r\n");
ashleymills 1:719c0f047c34 26 _terminal->printf(" \"disconnect\": Disconnect from 3G network.\r\n");
ashleymills 0:6c831cc49d22 27 return;
ashleymills 0:6c831cc49d22 28 }
ashleymills 1:719c0f047c34 29 _terminal->printf("\r\ncmd: \"%s\"\r\n",_lineBuffer);
ashleymills 1:719c0f047c34 30 _atInterface->execute(_lineBuffer, this, &_cmdResult, 1000);
ashleymills 2:8cc63f7a24cf 31
ashleymills 2:8cc63f7a24cf 32 if(_cmdResult.result==ATCommandsInterface::ATResult::AT_OK) {
ashleymills 2:8cc63f7a24cf 33 clearBuffer();
ashleymills 2:8cc63f7a24cf 34 _terminal->printf("OK\r\n");
ashleymills 2:8cc63f7a24cf 35 }
ashleymills 0:6c831cc49d22 36 }
ashleymills 0:6c831cc49d22 37
ashleymills 0:6c831cc49d22 38 void ATConsole::update() {
ashleymills 0:6c831cc49d22 39 Console::update();
ashleymills 1:719c0f047c34 40 }
ashleymills 1:719c0f047c34 41
ashleymills 1:719c0f047c34 42 int ATConsole::onNewATResponseLine(ATCommandsInterface* pInst, const char* line) {
ashleymills 1:719c0f047c34 43 _terminal->printf("response: %s\r\n",line);
ashleymills 1:719c0f047c34 44 return OK;
ashleymills 1:719c0f047c34 45 }
ashleymills 1:719c0f047c34 46
ashleymills 1:719c0f047c34 47 int ATConsole::onNewEntryPrompt(ATCommandsInterface* pInst) {
ashleymills 2:8cc63f7a24cf 48 _terminal->printf("new entry prompt");
ashleymills 2:8cc63f7a24cf 49 _terminal->printf(">");
ashleymills 2:8cc63f7a24cf 50 _gettingSMSData = true;
ashleymills 2:8cc63f7a24cf 51 while(_gettingSMSData) {
ashleymills 2:8cc63f7a24cf 52 update();
ashleymills 2:8cc63f7a24cf 53 Thread::wait(10);
ashleymills 2:8cc63f7a24cf 54 }
ashleymills 2:8cc63f7a24cf 55 _atInterface->sendData(_lineBuffer);
ashleymills 1:719c0f047c34 56 return OK;
ashleymills 2:8cc63f7a24cf 57 }
ashleymills 2:8cc63f7a24cf 58
ashleymills 2:8cc63f7a24cf 59 void ATConsole::onEvent(const char* atCode, const char* evt) {
ashleymills 2:8cc63f7a24cf 60 DBG("Unsollicited result code: %s - %s", atCode, evt);
ashleymills 2:8cc63f7a24cf 61 }
ashleymills 2:8cc63f7a24cf 62
ashleymills 2:8cc63f7a24cf 63 /*virtual*/ void ATConsole::onDispatchStart() { }
ashleymills 2:8cc63f7a24cf 64
ashleymills 2:8cc63f7a24cf 65 /*virtual*/ void ATConsole::onDispatchStop() { }
ashleymills 2:8cc63f7a24cf 66
ashleymills 2:8cc63f7a24cf 67 bool ATConsole::isATCodeHandled(const char* atCode) { return false; }