Electron: Direct Access to Cellular Module through USART

Can I directly access the cellular module through the attached USART Interface from the MCU? If so, how do I address the USART Interface?
Background: Due to buffer limitations I would like to bypass the Cellular.Command interface and write my own parser.


“The u-blox cellular module talks to the microcontroller over a full-duplex USART interface using a standard set of AT commands” - Taken from the Electron Specifications

You could have a look in the respective source file(s)
e.g.

Thant’s great!

I tried to do some initial testing but don’t get any feedback from the electronserial after sending any AT command.

Any advice on below code to give me a jumpstart?

#include "cellular_hal.h"
#include "electronserialpipe_hal.h"

SYSTEM_MODE(MANUAL);

ElectronSerialPipe ePipe(1024, 1024);

void setup()
{
  Serial.begin(9600);
    Serial.println("Turn Modem On");
    Cellular.on();
    ePipe.begin(19200);
}

void loop()
{
  int i = 0;
  char c;
  char commandbuffer[100];
  int out;
  if (Serial.available()) {
    delay(100);
    while ( Serial.available() && i < 99) {
      commandbuffer[i++] = Serial.read();
    }
    commandbuffer[i-1]='\r';
    commandbuffer[i]='\n';
    commandbuffer[i+1]='\0';
    //Serial.println("Got CR");
    out=ePipe.put(commandbuffer,i+1, true);
    Serial.print("Command issued:");
    Serial.print(commandbuffer);
    Serial.print("Bytes written:");
    Serial.println(out, DEC);
  }
  //if (ePipe.readable()){
    //Serial.println("sth is there");
    c = ePipe.getc();
    if (c < 99) Serial.print(c);
  //}
}

That’s probably because there is already an object of that kind.
That link was mainly to show how it’s done in the framework and not to instantiate an object of that kind.

If you want to write your own parser, you might want to consider local building and looking at the full repo
e.g.
https://github.com/spark/firmware/blob/develop/hal/src/electron/parser.cpp

That’s the fun with open source, you can do whatever you want with the code

2 Likes