support library for C027 helper functions for Buffer Pipes, Buffered Serial Port (rtos capable) and GPS parsing. It includes modem APIs for USSD, SMS and Sockets.
Dependents: HTTPClient_Cellular_HelloWorld Cellular_HelloMQTT MbedSmartRestMain Car_Bon_car_module ... more
MDMParser Class Reference
basic modem parser class More...
#include <MDM.h>
Inherited by MDMSerial, and MDMUsb.
Data Structures | |
struct | CellLocData |
Cell Locate Data. More... | |
struct | DevStatus |
Device status. More... | |
struct | NetStatus |
Network Status. More... | |
Public Types | |
enum | Dev |
MT Device Types. More... | |
enum | Sim |
SIM Status. More... | |
enum | Lpm |
SIM Status. More... | |
enum | CopsMode |
COPS status. More... | |
enum | Reg |
Registration Status. More... | |
enum | AcT |
Access Technology. More... | |
enum | IpProtocol |
Type of IP protocol. More... | |
enum | HttpOpCode |
Type of HTTP Operational Codes (reference to HTTP control +UHTTP) More... | |
enum | HttpCmd |
Type of HTTP Commands (reference to HTTP command +UHTTPC) More... | |
typedef uint32_t | IP |
An IP v4 address. | |
typedef int(* | _DPRINT )(void *param, char const *format,...) |
helper type for DPRINT | |
typedef int(* | _CALLBACKPTR )(int type, const char *buf, int len, void *param) |
callback function for waitFinalResp with void* as argument | |
Public Member Functions | |
MDMParser (void) | |
Constructor. | |
bool | connect (const char *simpin=NULL, const char *apn=NULL, const char *username=NULL, const char *password=NULL, Auth auth=AUTH_DETECT, PinName pn MDM_IF(=MDMPWRON,=D4)) |
Combined Init, checkNetStatus, join suitable for simple applications. | |
virtual bool | init (const char *simpin=NULL, DevStatus *status=NULL, PinName pn MDM_IF(=MDMPWRON,=D4)) |
register (Attach) the MT to the GPRS service. | |
void | getDevStatus (MDMParser::DevStatus *dev) |
get the current device status | |
bool | registerNet (NetStatus *status=NULL, int timeout_ms=180000) |
register to the network | |
bool | checkNetStatus (NetStatus *status=NULL) |
check if the network is available | |
bool | powerOff (void) |
Power off the MT, This function has to be called prior to switching off the supply. | |
MDMParser::IP | join (const char *apn=NULL, const char *username=NULL, const char *password=NULL, Auth auth=AUTH_DETECT) |
register (Attach) the MT to the GPRS service. | |
bool | disconnect (void) |
deregister (detach) the MT from the GPRS service. | |
MDMParser::IP | gethostbyname (const char *host) |
Translates a domain name to an IP address. | |
MDMParser::IP | getIpAddress (void) |
get the current assigned IP address | |
int | socketSocket (IpProtocol ipproto, int port=-1) |
Create a socket for a ip protocol (and optionaly bind) | |
bool | socketConnect (int socket, const char *host, int port) |
make a socket connection | |
bool | socketIsConnected (int socket) |
make a socket connection | |
bool | socketSetBlocking (int socket, int timeout_ms) |
Get the number of bytes pending for reading for this socket. | |
int | socketSend (int socket, const char *buf, int len) |
Write socket data. | |
int | socketSendTo (int socket, IP ip, int port, const char *buf, int len) |
Write socket data to a IP. | |
int | socketReadable (int socket) |
Get the number of bytes pending for reading for this socket. | |
int | socketRecv (int socket, char *buf, int len) |
Read this socket. | |
int | socketRecvFrom (int socket, IP *ip, int *port, char *buf, int len) |
Read from this socket. | |
bool | socketClose (int socket) |
Close a connectied socket (that was connected with socketConnect) | |
bool | socketFree (int socket) |
Free the socket (that was allocated before by socketSocket) | |
int | httpFindProfile () |
find HTTP profile | |
bool | httpSetBlocking (int profile, int timeout_ms) |
get the number of bytes pending for reading for this HTTP profile | |
bool | httpSetProfileForCmdMng (int profile) |
set the HTTP profile for commands management | |
bool | httpFreeProfile (int profile) |
free the HTTP profile | |
bool | httpResetProfile (int httpProfile) |
reset HTTP profile | |
bool | httpSetPar (int httpProfile, HttpOpCode httpOpCode, const char *httpInPar) |
set HTTP parameters | |
bool | httpCommand (int httpProfile, HttpCmd httpCmdCode, const char *httpPath,\const char *httpOut, const char *httpIn, int httpContentType,\const char *httpCustomPar, char *buf, int len) |
HTTP commands management. | |
const char * | getHTTPcmd (int httpCmdCode) |
get HTTP commands | |
int | smsList (const char *stat="ALL", int *ix=NULL, int num=0) |
count the number of sms in the device and optionally return a list with indexes from the storage locations in the device. | |
bool | smsRead (int ix, char *num, char *buf, int len) |
Read a Message from a storage position. | |
bool | smsDelete (int ix) |
Send a message to a recipient. | |
bool | smsSend (const char *num, const char *buf) |
Send a message to a recipient. | |
bool | ussdCommand (const char *cmd, char *buf) |
Read a Message from a storage position. | |
bool | delFile (const char *filename) |
Delete a file in the local file system. | |
int | writeFile (const char *filename, const char *buf, int len) |
Write some data to a file in the local file system. | |
int | readFile (const char *filename, char *buf, int len) |
Read a file from the local file system. | |
int | readFileNew (const char *filename, char *buf, int len) |
Read a file from the local file system (the file size is greater than MAX_SIZE bytes) | |
int | infoFile (const char *filename) |
Retrieve information about the dimension of a file from the local FFS. | |
int | cellLocSrvTcp (const char *token, const char *server_1="cell-live1.services.u-blox.com",\const char *server_2="cell-live2.services.u-blox.com", int days=14, int period=4, int resolution=1) |
Configures CellLocate Tcp Aiding server Host name of the primary MGA server Host name of the secondary MGA server Authentication Token for MGA server access The number of days into the future the Offline data for the u-blox 7 The number of weeks into the future the Offline data for u-blox M8 Resolution of offline data for u-blox M8: 1 everyday, 0 every other day. | |
int | cellLocSrvUdp (const char *server_1="cell-live1.services.u-blox.com", int port=46434, int latency=1000, int mode=0) |
Configures CellLocate Udp Aiding server Host name of the primary MGA server Server port Expected network latency in seconds from 0 to 10000ms Assist now management, mode of operation: 0 data downloaded at GNSS power up, 1 automatically kept alive, manual download. | |
int | cellLocUnsol (int mode) |
Configures CellLocate URCs in the case of +ULOC operations Urc configuration: 0 disabled, 1 enabled. | |
int | cellLocConfig (int scanMode) |
Configures CellLocate location sensor Network scan mode: 0 normal, 1 deep scan. | |
int | cellLocRequest (CellSensType sensor, int timeout, int accuracy, CellRespType type=CELL_DETAILED, int hypotesis=1) |
Request CellLocate This function is not blocking, the result has to be retrived using cellLocGet Sensor selection: Timeout period in seconds (1 - 999) Target accuracy in meters (1 - 999999) Maximum desired number of responses from CellLocate® (up to 16) | |
int | cellLocGetData (CellLocData *data, int index=0) |
Get a position record pointer to a CellLocData struct where the location will be copied in of the position to retrive. | |
int | cellLocGetRes () |
Get number of position records received. | |
int | cellLocGetExpRes () |
Get expected number of position to be received. | |
bool | setDebug (int level) |
_DUMP_TEMPLATE (dumpDevStatus, MDMParser::DevStatus *, status) _DUMP_TEMPLATE(dumpNetStatus | |
dump the device status to stdout using printf | |
MDMParser::NetStatus status | _DUMP_TEMPLATE (dumpIp, MDMParser::IP, ip) enum |
dump the ip address to stdout using printf | |
virtual int | getLine (char *buf, int len)=0 |
Get a line from the physical interface. | |
virtual int | send (const char *buf, int len) |
Write data to the device. | |
int | sendFormated (const char *format,...) |
Write formated date to the physical interface (printf style) | |
int | waitFinalResp (_CALLBACKPTR cb=NULL, void *param=NULL, int timeout_ms=10000) |
Wait for a final respons. | |
template<class T > | |
int | waitFinalResp (int(*cb)(int type, const char *buf, int len, T *param), T *param, int timeout_ms=10000) |
template version of waitFinalResp when using callbacks, This template will allow the compiler to do type cheking but internally symply casts the arguments and call the (void*) version of waitFinalResp. | |
Static Public Member Functions | |
static MDMParser * | getInstance () |
get static instance | |
Data Fields | |
int | _locRcvPos |
Received positions. | |
int | _locExpPos |
Expected positions. | |
Protected Member Functions | |
virtual int | _send (const void *buf, int len)=0 |
Write bytes to the physical interface. | |
virtual void | wait_ms (int ms) |
override in a rtos system, you us the wait function of a Thread | |
virtual void | lock (void) |
override the lock in a rtos system | |
virtual void | unlock (void) |
override the unlock in a rtos system | |
Static Protected Member Functions | |
static int | _getLine (Pipe< char > *pipe, char *buffer, int length) |
Helper: Parse a line from the receiving buffered pipe. | |
static int | _parseMatch (Pipe< char > *pipe, int len, const char *sta, const char *end) |
Helper: Parse a match from the pipe. | |
static int | _parseFormated (Pipe< char > *pipe, int len, const char *fmt) |
Helper: Parse a match from the pipe. | |
Protected Attributes | |
DevStatus | _dev |
collected device information | |
NetStatus | _net |
collected network information | |
IP | _ip |
assigned ip address | |
CellLocData | _loc [CELL_MAX_HYP] |
CellLocate data. |
Detailed Description
basic modem parser class
Definition at line 23 of file MDM.h.
Member Typedef Documentation
typedef int(* _CALLBACKPTR)(int type, const char *buf, int len, void *param) |
callback function for waitFinalResp with void* as argument
- Parameters:
-
type the getLine response buf the parsed line len the size of the parsed line param the optional argument passed to waitFinalResp
- Returns:
- WAIT if processing should continue, any other value aborts waitFinalResp and this retunr value retuned
typedef int(* _DPRINT)(void *param, char const *format,...) |
Member Enumeration Documentation
enum HttpCmd |
enum HttpOpCode |
enum IpProtocol |
Constructor & Destructor Documentation
Member Function Documentation
_DUMP_TEMPLATE | ( | dumpDevStatus | , |
MDMParser::DevStatus * | , | ||
status | |||
) |
dump the device status to stdout using printf
- Parameters:
-
status the status to convert to textual form, unavailable fields are ommited (not printed) dprint a function pointer param the irst argument passed to dprint dump the network status to stdout using printf status the status to convert to textual form, unavailable fields are ommited (not printed) dprint a function pointer param the irst argument passed to dprint
MDMParser::NetStatus status _DUMP_TEMPLATE | ( | dumpIp | , |
MDMParser::IP | , | ||
ip | |||
) |
int _getLine | ( | Pipe< char > * | pipe, |
char * | buffer, | ||
int | length | ||
) | [static, protected] |
Helper: Parse a line from the receiving buffered pipe.
- Parameters:
-
pipe the receiving buffer pipe buf the parsed line len the size of the parsed line
- Returns:
- type and length if something was found, WAIT if not enough data is available NOT_FOUND if nothing was found
int _parseFormated | ( | Pipe< char > * | pipe, |
int | len, | ||
const char * | fmt | ||
) | [static, protected] |
int _parseMatch | ( | Pipe< char > * | pipe, |
int | len, | ||
const char * | sta, | ||
const char * | end | ||
) | [static, protected] |
virtual int _send | ( | const void * | buf, |
int | len | ||
) | [protected, pure virtual] |
Write bytes to the physical interface.
This function should be implemented in a inherited class.
- Parameters:
-
buf the buffer to write buf size of the buffer to write
- Returns:
- bytes written
Implemented in MDMSerial.
int cellLocConfig | ( | int | scanMode ) |
int cellLocGetData | ( | CellLocData * | data, |
int | index = 0 |
||
) |
Get a position record pointer to a CellLocData struct where the location will be copied in of the position to retrive.
- Returns:
- 1 if data has been retrived and copied, 0 otherwise
int cellLocGetExpRes | ( | ) |
int cellLocGetRes | ( | ) |
int cellLocRequest | ( | CellSensType | sensor, |
int | timeout, | ||
int | accuracy, | ||
CellRespType | type = CELL_DETAILED , |
||
int | hypotesis = 1 |
||
) |
int cellLocSrvTcp | ( | const char * | token, |
const char * | server_1 = "cell-live1.services.u-blox.com" , |
||
\const char * | server_2 = "cell-live2.services.u-blox.com" , |
||
int | days = 14 , |
||
int | period = 4 , |
||
int | resolution = 1 |
||
) |
Configures CellLocate Tcp Aiding server Host name of the primary MGA server Host name of the secondary MGA server Authentication Token for MGA server access The number of days into the future the Offline data for the u-blox 7 The number of weeks into the future the Offline data for u-blox M8 Resolution of offline data for u-blox M8: 1 everyday, 0 every other day.
int cellLocSrvUdp | ( | const char * | server_1 = "cell-live1.services.u-blox.com" , |
int | port = 46434 , |
||
int | latency = 1000 , |
||
int | mode = 0 |
||
) |
Configures CellLocate Udp Aiding server Host name of the primary MGA server Server port Expected network latency in seconds from 0 to 10000ms Assist now management, mode of operation: 0 data downloaded at GNSS power up, 1 automatically kept alive, manual download.
int cellLocUnsol | ( | int | mode ) |
bool checkNetStatus | ( | NetStatus * | status = NULL ) |
bool connect | ( | const char * | simpin = NULL , |
const char * | apn = NULL , |
||
const char * | username = NULL , |
||
const char * | password = NULL , |
||
Auth | auth = AUTH_DETECT , |
||
PinName pn | MDM_IF=MDMPWRON,=D4 | ||
) |
Combined Init, checkNetStatus, join suitable for simple applications.
- Parameters:
-
simpin a optional pin of the SIM card apn the of the network provider e.g. "internet" or "apn.provider.com" username is the user name text string for the authentication phase password is the password text string for the authentication phase auth is the authentication mode (CHAP,PAP,NONE or DETECT)
- Returns:
- true if successful, false otherwise
bool delFile | ( | const char * | filename ) |
bool disconnect | ( | void | ) |
void getDevStatus | ( | MDMParser::DevStatus * | dev ) |
MDMParser::IP gethostbyname | ( | const char * | host ) |
const char * getHTTPcmd | ( | int | httpCmdCode ) |
MDMParser::IP getIpAddress | ( | void | ) |
virtual int getLine | ( | char * | buf, |
int | len | ||
) | [pure virtual] |
Get a line from the physical interface.
This function need to be implemented in a inherited class. Usually just calls _getLine on the rx buffer pipe.
- Parameters:
-
buf the buffer to store it buf size of the buffer
- Returns:
- type and length if something was found, WAIT if not enough data is available NOT_FOUND if nothing was found
Implemented in MDMSerial.
bool httpCommand | ( | int | httpProfile, |
HttpCmd | httpCmdCode, | ||
const char * | httpPath, | ||
\const char * | httpOut, | ||
const char * | httpIn, | ||
int | httpContentType, | ||
\const char * | httpCustomPar, | ||
char * | buf, | ||
int | len | ||
) |
HTTP commands management.
- Parameters:
-
httpProfile the HTTP profile identifier httpCmdCode the HTTP command code httpPath the path of HTTP server resource httpOut the filename where the HTTP server response will be stored httpIn the input data (filename or string) to be sent to the HTTP server with the command request httpContentType the HTTP Content-Type identifier httpCustomPar the parameter for an user defined HTTP Content-Type buf the buffer to read into len the size of the buffer to read into
- Returns:
- true if successfully, false otherwise
int httpFindProfile | ( | ) |
bool httpFreeProfile | ( | int | profile ) |
bool httpResetProfile | ( | int | httpProfile ) |
bool httpSetBlocking | ( | int | profile, |
int | timeout_ms | ||
) |
bool httpSetPar | ( | int | httpProfile, |
HttpOpCode | httpOpCode, | ||
const char * | httpInPar | ||
) |
bool httpSetProfileForCmdMng | ( | int | profile ) |
int infoFile | ( | const char * | filename ) |
virtual bool init | ( | const char * | simpin = NULL , |
DevStatus * | status = NULL , |
||
PinName pn | MDM_IF=MDMPWRON,=D4 | ||
) | [virtual] |
register (Attach) the MT to the GPRS service.
- Parameters:
-
simpin a optional pin of the SIM card status an optional struture to with device information
- Returns:
- true if successful, false otherwise
MDMParser::IP join | ( | const char * | apn = NULL , |
const char * | username = NULL , |
||
const char * | password = NULL , |
||
Auth | auth = AUTH_DETECT |
||
) |
register (Attach) the MT to the GPRS service.
- Parameters:
-
apn the of the network provider e.g. "internet" or "apn.provider.com" username is the user name text string for the authentication phase password is the password text string for the authentication phase auth is the authentication mode (CHAP,PAP,NONE or DETECT)
- Returns:
- the ip that is assigned
virtual void lock | ( | void | ) | [protected, virtual] |
bool powerOff | ( | void | ) |
int readFile | ( | const char * | filename, |
char * | buf, | ||
int | len | ||
) |
int readFileNew | ( | const char * | filename, |
char * | buf, | ||
int | len | ||
) |
bool registerNet | ( | NetStatus * | status = NULL , |
int | timeout_ms = 180000 |
||
) |
int send | ( | const char * | buf, |
int | len | ||
) | [virtual] |
int sendFormated | ( | const char * | format, |
... | |||
) |
bool setDebug | ( | int | level ) |
bool smsDelete | ( | int | ix ) |
int smsList | ( | const char * | stat = "ALL" , |
int * | ix = NULL , |
||
int | num = 0 |
||
) |
count the number of sms in the device and optionally return a list with indexes from the storage locations in the device.
- Parameters:
-
stat what type of messages you can use use "REC UNREAD", "REC READ", "STO UNSENT", "STO SENT", "ALL" ix list where to save the storage positions num number of elements in the list
- Returns:
- the number of messages, this can be bigger than num, -1 on failure
bool smsRead | ( | int | ix, |
char * | num, | ||
char * | buf, | ||
int | len | ||
) |
bool smsSend | ( | const char * | num, |
const char * | buf | ||
) |
bool socketClose | ( | int | socket ) |
Close a connectied socket (that was connected with socketConnect)
- Parameters:
-
socket the socket handle
- Returns:
- true if successfully, false otherwise
bool socketConnect | ( | int | socket, |
const char * | host, | ||
int | port | ||
) |
bool socketFree | ( | int | socket ) |
Free the socket (that was allocated before by socketSocket)
- Parameters:
-
socket the socket handle
- Returns:
- true if successfully, false otherwise
bool socketIsConnected | ( | int | socket ) |
int socketReadable | ( | int | socket ) |
int socketRecv | ( | int | socket, |
char * | buf, | ||
int | len | ||
) |
int socketRecvFrom | ( | int | socket, |
IP * | ip, | ||
int * | port, | ||
char * | buf, | ||
int | len | ||
) |
Read from this socket.
- Parameters:
-
socket the socket handle ip the ip of host where the data originates from port the port where the data originates from buf the buffer to read into len the size of the buffer to read into
- Returns:
- the number of bytes read or SOCKET_ERROR on failure
int socketSend | ( | int | socket, |
const char * | buf, | ||
int | len | ||
) |
int socketSendTo | ( | int | socket, |
IP | ip, | ||
int | port, | ||
const char * | buf, | ||
int | len | ||
) |
bool socketSetBlocking | ( | int | socket, |
int | timeout_ms | ||
) |
int socketSocket | ( | IpProtocol | ipproto, |
int | port = -1 |
||
) |
virtual void unlock | ( | void | ) | [protected, virtual] |
bool ussdCommand | ( | const char * | cmd, |
char * | buf | ||
) |
virtual void wait_ms | ( | int | ms ) | [protected, virtual] |
int waitFinalResp | ( | _CALLBACKPTR | cb = NULL , |
void * | param = NULL , |
||
int | timeout_ms = 10000 |
||
) |
int waitFinalResp | ( | int(*)(int type, const char *buf, int len, T *param) | cb, |
T * | param, | ||
int | timeout_ms = 10000 |
||
) |
template version of waitFinalResp when using callbacks, This template will allow the compiler to do type cheking but internally symply casts the arguments and call the (void*) version of waitFinalResp.
- See also:
- waitFinalResp
int writeFile | ( | const char * | filename, |
const char * | buf, | ||
int | len | ||
) |
Field Documentation
CellLocData _loc[CELL_MAX_HYP] [protected] |
int _locExpPos |
int _locRcvPos |
Generated on Tue Jul 12 2022 16:30:03 by 1.7.2