C027_Support library plus AT Comand for dialing.
Fork of C027_Support_New by
MDMSerial Class Reference
modem class which uses a serial port as physical interface. More...
#include <MDM.h>
Inherits SerialPipe, and MDMParser.
Public Types | |
enum | Dev |
MT Device Types. More... | |
enum | Sim |
SIM Status. More... | |
enum | Lpm |
SIM Status. More... | |
enum | Reg |
Registration Status. More... | |
enum | AcT |
Access Technology. More... | |
enum | IpProtocol |
Type of IP protocol. 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 | |
MDMSerial (PinName tx MDM_IF(=MDMTXD,=D1), PinName rx MDM_IF(=MDMRXD,=D0), int baudrate MDM_IF(=MDMBAUD,=115200),#if DEVICE_SERIAL_FC PinName rts MDM_IF(=MDMRTS,=NC), PinName cts MDM_IF(=MDMCTS,=NC),#endif int rxSize=256, int txSize=128) | |
Constructor. | |
virtual | ~MDMSerial (void) |
Destructor. | |
virtual int | getLine (char *buffer, int length) |
Get a line from the physical interface. | |
int | writeable (void) |
check if writable return the number of free bytes | |
int | putc (int c) |
send a character (blocking) | |
int | put (const void *buffer, int length, bool blocking) |
send a buffer | |
int | readable (void) |
check if readable | |
int | getc (void) |
receive one character from the serial port (blocking) | |
int | get (void *buffer, int length, bool blocking) |
read a buffer from the serial port | |
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. | |
bool | init (const char *simpin=NULL, DevStatus *status=NULL, PinName pn MDM_IF(=MDMPWRON,=D4)) |
register (Attach) the MT to the GPRS service. | |
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. | |
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 | 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 | dialStart (const char *num) |
Start Dial Phone Number. | |
bool | dialStop () |
Stop Dial Phone Number. | |
bool | dialAns () |
Answer Dial from Other Phone 't have param for this query. | |
bool | dialStatus (const char *num) |
Check Dial Status if Have Call list. | |
int | chkSig (MDMParser::NetStatus *status) |
Check signal quality. | |
bool | readDbg (int *status, char *num, int *signal, int *idx) |
Chek status of debug for set the next action. | |
bool | mute (bool mut) |
make all uplink and downlink are mute | |
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. | |
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 | 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 | |
Protected Member Functions | |
virtual int | _send (const void *buf, int len) |
Write bytes to the physical interface. | |
void | rxIrqBuf (void) |
receive interrupt routine | |
void | txIrqBuf (void) |
transmit interrupt woutine | |
void | txStart (void) |
start transmission helper | |
void | txCopy (void) |
move bytes to hardware | |
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 | |
Pipe< char > | _pipeRx |
receive pipe | |
Pipe< char > | _pipeTx |
transmit pipe | |
DevStatus | _dev |
collected device information | |
NetStatus | _net |
collected network information | |
IP | _ip |
assigned ip address |
Detailed Description
modem class which uses a serial port as physical interface.
Definition at line 650 of file MDM.h.
Member Typedef Documentation
typedef int(* _CALLBACKPTR)(int type, const char *buf, int len, void *param) [inherited] |
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,...) [inherited] |
Member Enumeration Documentation
enum IpProtocol [inherited] |
Constructor & Destructor Documentation
MDMSerial | ( | PinName tx | MDM_IF=MDMTXD,=D1, |
PinName rx | MDM_IF=MDMRXD,=D0, | ||
int baudrate | MDM_IF=MDMBAUD,=115200, | ||
#if DEVICE_SERIAL_FC PinName rts | MDM_IF=MDMRTS,=NC, | ||
PinName cts | MDM_IF=MDMCTS,=NC, | ||
#endif int | rxSize = 256 , |
||
int | txSize = 128 |
||
) |
Constructor.
- Parameters:
-
tx is the serial ports transmit pin (modem to CPU) rx is the serial ports receive pin (CPU to modem) baudrate the baudrate of the modem use 115200 rts is the serial ports ready to send pin (CPU to modem) this pin is optional cts is the serial ports clear to send pin (modem to CPU) this pin is optional, but required for power saving to be enabled rxSize the size of the serial rx buffer txSize the size of the serial tx buffer
Member Function Documentation
_DUMP_TEMPLATE | ( | dumpDevStatus | , |
MDMParser::DevStatus * | , | ||
status | |||
) | [inherited] |
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 | |||
) | [inherited] |
int _getLine | ( | Pipe< char > * | pipe, |
char * | buffer, | ||
int | length | ||
) | [static, protected, inherited] |
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, inherited] |
int _parseMatch | ( | Pipe< char > * | pipe, |
int | len, | ||
const char * | sta, | ||
const char * | end | ||
) | [static, protected, inherited] |
int _send | ( | const void * | buf, |
int | len | ||
) | [protected, virtual] |
bool checkNetStatus | ( | NetStatus * | status = NULL ) |
[inherited] |
int chkSig | ( | MDMParser::NetStatus * | status ) | [inherited] |
Check signal quality.
- Parameters:
-
signal strenght
- Returns:
- value of signal strenght
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 | ||
) | [inherited] |
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 ) | [inherited] |
bool dialAns | ( | ) | [inherited] |
bool dialStart | ( | const char * | num ) | [inherited] |
bool dialStatus | ( | const char * | num ) | [inherited] |
bool dialStop | ( | ) | [inherited] |
bool disconnect | ( | void | ) | [inherited] |
int get | ( | void * | buffer, |
int | length, | ||
bool | blocking | ||
) | [inherited] |
read a buffer from the serial port
- Parameters:
-
pointer to the buffer to read. length number of bytes to read blocking true if all bytes shall be read. false if only the available bytes.
- Returns:
- the number of bytes read.
Definition at line 94 of file SerialPipe.cpp.
int getc | ( | void | ) | [inherited] |
receive one character from the serial port (blocking)
- Parameters:
-
the character received
Definition at line 87 of file SerialPipe.cpp.
MDMParser::IP gethostbyname | ( | const char * | host ) | [inherited] |
static MDMParser* getInstance | ( | ) | [static, inherited] |
int getLine | ( | char * | buffer, |
int | length | ||
) | [virtual] |
bool init | ( | const char * | simpin = NULL , |
DevStatus * | status = NULL , |
||
PinName pn | MDM_IF=MDMPWRON,=D4 | ||
) | [inherited] |
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 |
||
) | [inherited] |
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, inherited] |
bool mute | ( | bool | mut ) | [inherited] |
bool powerOff | ( | void | ) | [inherited] |
int put | ( | const void * | buffer, |
int | length, | ||
bool | blocking | ||
) | [inherited] |
send a buffer
- Parameters:
-
buffer the buffer to send length the size of the buffer to send blocking,if true this function will block until all bytes placed in the buffer.
- Returns:
- the number of bytes written
Definition at line 31 of file SerialPipe.cpp.
int putc | ( | int | c ) | [inherited] |
send a character (blocking)
- Parameters:
-
c the character to send
- Returns:
- c
Definition at line 24 of file SerialPipe.cpp.
int readable | ( | void | ) | [inherited] |
check if readable
- Returns:
- the size available in the buffer.
Definition at line 82 of file SerialPipe.cpp.
bool readDbg | ( | int * | status, |
char * | num, | ||
int * | signal, | ||
int * | idx | ||
) | [inherited] |
int readFile | ( | const char * | filename, |
char * | buf, | ||
int | len | ||
) | [inherited] |
bool registerNet | ( | NetStatus * | status = NULL , |
int | timeout_ms = 180000 |
||
) | [inherited] |
void rxIrqBuf | ( | void | ) | [protected, inherited] |
receive interrupt routine
Definition at line 99 of file SerialPipe.cpp.
int send | ( | const char * | buf, |
int | len | ||
) | [virtual, inherited] |
int sendFormated | ( | const char * | format, |
... | |||
) | [inherited] |
bool setDebug | ( | int | level ) | [inherited] |
bool smsDelete | ( | int | ix ) | [inherited] |
int smsList | ( | const char * | stat = "ALL" , |
int * | ix = NULL , |
||
int | num = 0 |
||
) | [inherited] |
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 | ||
) | [inherited] |
bool smsSend | ( | const char * | num, |
const char * | buf | ||
) | [inherited] |
bool socketClose | ( | int | socket ) | [inherited] |
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 | ||
) | [inherited] |
bool socketFree | ( | int | socket ) | [inherited] |
Free the socket (that was allocated before by socketSocket)
- Parameters:
-
socket the socket handle
- Returns:
- true if successfully, false otherwise
bool socketIsConnected | ( | int | socket ) | [inherited] |
int socketReadable | ( | int | socket ) | [inherited] |
int socketRecv | ( | int | socket, |
char * | buf, | ||
int | len | ||
) | [inherited] |
int socketRecvFrom | ( | int | socket, |
IP * | ip, | ||
int * | port, | ||
char * | buf, | ||
int | len | ||
) | [inherited] |
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 | ||
) | [inherited] |
int socketSendTo | ( | int | socket, |
IP | ip, | ||
int | port, | ||
const char * | buf, | ||
int | len | ||
) | [inherited] |
bool socketSetBlocking | ( | int | socket, |
int | timeout_ms | ||
) | [inherited] |
int socketSocket | ( | IpProtocol | ipproto, |
int | port = -1 |
||
) | [inherited] |
void txCopy | ( | void | ) | [protected, inherited] |
move bytes to hardware
Definition at line 54 of file SerialPipe.cpp.
void txIrqBuf | ( | void | ) | [protected, inherited] |
transmit interrupt woutine
Definition at line 63 of file SerialPipe.cpp.
void txStart | ( | void | ) | [protected, inherited] |
start transmission helper
Definition at line 71 of file SerialPipe.cpp.
virtual void unlock | ( | void | ) | [protected, virtual, inherited] |
bool ussdCommand | ( | const char * | cmd, |
char * | buf | ||
) | [inherited] |
virtual void wait_ms | ( | int | ms ) | [protected, virtual, inherited] |
int waitFinalResp | ( | _CALLBACKPTR | cb = NULL , |
void * | param = NULL , |
||
int | timeout_ms = 10000 |
||
) | [inherited] |
int waitFinalResp | ( | int(*)(int type, const char *buf, int len, T *param) | cb, |
T * | param, | ||
int | timeout_ms = 10000 |
||
) | [inherited] |
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 writeable | ( | void | ) | [inherited] |
check if writable return the number of free bytes
Definition at line 19 of file SerialPipe.cpp.
int writeFile | ( | const char * | filename, |
const char * | buf, | ||
int | len | ||
) | [inherited] |
Field Documentation
receive pipe
Definition at line 78 of file SerialPipe.h.
transmit pipe
Definition at line 79 of file SerialPipe.h.
Generated on Sat Jul 23 2022 11:16:21 by 1.7.2