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:
Tue Aug 28 12:47:45 2012 +0000
Revision:
3:6b3ca3af97cf
Parent:
2:8cc63f7a24cf
Child:
4:6971bded3ebd
Modified SMS sending ability.

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 3:6b3ca3af97cf 15 if(strlen(_lineBuffer)==0)
ashleymills 3:6b3ca3af97cf 16 return;
ashleymills 3:6b3ca3af97cf 17 _terminal->printf("ATConsole::processCommand()\r\n");
ashleymills 2:8cc63f7a24cf 18 if(_gettingSMSData) {
ashleymills 3:6b3ca3af97cf 19 _terminal->printf("_gettingSMSData %s\r\n",_lineBuffer);
ashleymills 3:6b3ca3af97cf 20 strcpy(_smsMessage,_lineBuffer);
ashleymills 2:8cc63f7a24cf 21 _gettingSMSData = false;
ashleymills 2:8cc63f7a24cf 22 return;
ashleymills 2:8cc63f7a24cf 23 }
ashleymills 2:8cc63f7a24cf 24
ashleymills 0:6c831cc49d22 25 if((strncmp(_lineBuffer,"h",_lineLength)==0)||
ashleymills 0:6c831cc49d22 26 (strncmp(_lineBuffer,"help",_lineLength)==0)) {
ashleymills 1:719c0f047c34 27 _terminal->printf("Help.\r\n");
ashleymills 1:719c0f047c34 28 _terminal->printf(" \"connect\": Connect to 3G network.\r\n");
ashleymills 1:719c0f047c34 29 _terminal->printf(" \"disconnect\": Disconnect from 3G network.\r\n");
ashleymills 0:6c831cc49d22 30 return;
ashleymills 0:6c831cc49d22 31 }
ashleymills 3:6b3ca3af97cf 32
ashleymills 3:6b3ca3af97cf 33 _terminal->printf("\r\ncmd: \"%s\"(%d)\r\n",_lineBuffer,strlen(_lineBuffer));
ashleymills 1:719c0f047c34 34 _atInterface->execute(_lineBuffer, this, &_cmdResult, 1000);
ashleymills 2:8cc63f7a24cf 35
ashleymills 3:6b3ca3af97cf 36 if(_cmdResult.result==ATCommandsInterface::ATResult::AT_OK&&!_gettingSMSData) {
ashleymills 2:8cc63f7a24cf 37 clearBuffer();
ashleymills 2:8cc63f7a24cf 38 _terminal->printf("OK\r\n");
ashleymills 2:8cc63f7a24cf 39 }
ashleymills 0:6c831cc49d22 40 }
ashleymills 0:6c831cc49d22 41
ashleymills 0:6c831cc49d22 42 void ATConsole::update() {
ashleymills 0:6c831cc49d22 43 Console::update();
ashleymills 1:719c0f047c34 44 }
ashleymills 1:719c0f047c34 45
ashleymills 1:719c0f047c34 46 int ATConsole::onNewATResponseLine(ATCommandsInterface* pInst, const char* line) {
ashleymills 3:6b3ca3af97cf 47 _terminal->printf("new AT response: %s\r\n",line);
ashleymills 1:719c0f047c34 48 return OK;
ashleymills 1:719c0f047c34 49 }
ashleymills 1:719c0f047c34 50
ashleymills 1:719c0f047c34 51 int ATConsole::onNewEntryPrompt(ATCommandsInterface* pInst) {
ashleymills 3:6b3ca3af97cf 52 _terminal->printf("new entry prompt\r\n");
ashleymills 3:6b3ca3af97cf 53 _terminal->printf(">\r\n");
ashleymills 2:8cc63f7a24cf 54 _gettingSMSData = true;
ashleymills 2:8cc63f7a24cf 55 while(_gettingSMSData) {
ashleymills 2:8cc63f7a24cf 56 update();
ashleymills 2:8cc63f7a24cf 57 Thread::wait(10);
ashleymills 2:8cc63f7a24cf 58 }
ashleymills 3:6b3ca3af97cf 59 _terminal->printf("about to send: \"%s\"\r\n",_smsMessage);
ashleymills 3:6b3ca3af97cf 60 _atInterface->sendData(_smsMessage);
ashleymills 1:719c0f047c34 61 return OK;
ashleymills 2:8cc63f7a24cf 62 }
ashleymills 2:8cc63f7a24cf 63
ashleymills 2:8cc63f7a24cf 64 void ATConsole::onEvent(const char* atCode, const char* evt) {
ashleymills 2:8cc63f7a24cf 65 DBG("Unsollicited result code: %s - %s", atCode, evt);
ashleymills 2:8cc63f7a24cf 66 }
ashleymills 2:8cc63f7a24cf 67
ashleymills 2:8cc63f7a24cf 68 /*virtual*/ void ATConsole::onDispatchStart() { }
ashleymills 2:8cc63f7a24cf 69
ashleymills 2:8cc63f7a24cf 70 /*virtual*/ void ATConsole::onDispatchStop() { }
ashleymills 2:8cc63f7a24cf 71
ashleymills 2:8cc63f7a24cf 72 bool ATConsole::isATCodeHandled(const char* atCode) { return false; }