Rainer
June 30, 2016, 9:05am
1
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.
/*
******************************************************************************
* Copyright (c) 2015 Particle Industries, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
******************************************************************************
*/
#ifndef HAL_CELLULAR_EXCLUDE
This file has been truncated. show original
Rainer
June 30, 2016, 11:38am
3
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