Moxa ioPAC 8500-2-M12-C-T [31/66] Cellular api

Moxa ioPAC 8020-9-RJ45-C-T [31/66] Cellular api
Developer's Guide for Moxa RTU Controllers Programmer's Guide
2-23
Cellular API
Cellular API functions communicate with the internal cellular modem via two device nodes located at
/dev/ttyACM and /dev/ttyUSB0. Users must include libmoxa_pgm.h. Cellular API functions work in two
operating modes: Auto Reconnect as enabled or disabled. If Auto Reconnect is enabled, it automatically detects
the cellular connection failure via a ping command to a user-specified remote host periodically. Once a cellular
connection failure is detected, it will try to re-establish the cellular network without any interaction with the
users program. If auto Reconnect is disabled, the users program has total control of cellular connection and
disconnection; on the other hand, the program must detect the cellular network failure by itself. To apply these
two modes, cellular API functions are implemented as a state machine. The states of these two modes are
described in figures below.
#define MODEM_STATE_INIT 0
#define MODEM_STATE_READY 1
#define MODEM_STATE_CONNECTING 2
#define MODEM_STATE_CONNECTED 3
#define MODEM_STATE_DISCONNECT 4
Return values of cellular API functions are shown below; they can also be found at libmoxa_pgm.h.
#define MODEM_ERR_OK 0//successful
#define MODEM_ERR_INIT 1//not init
#define MODEM_ERR_PARAM 2//invalid parameter
#define MODEM_ERR_OPEN 3//open device error
#define MODEM_ERR_SIM 4//SIM card error
#define MODEM_ERR_PIN 5//PIN code error
#define MODEM_ERR_BAND 6//Set band error
#define MODEM_ERR_ECHO_OFF 7//turn off echo error
#define MODEM_ERR_CELLULAR_DENIED 8//register to cellular network is denied
#define MODEM_ERR_RESET 9//reset modem error
#define MODEM_ERR_THREAD 10//create thread error
#define MODEM_ERR_APN 11//set APN error
#define MODEM_ERR_CREDENTIAL 12//generate PPP credential file error
#define MODEM_ERR_ATTACH 13//attach to 3G network error
#define MODEM_ERR_IF 14//ppp interface is not established
#define MODEM_ERR_CMD 15//err command (wrong state, or previous cmd is executing)
#define MODEM_ERR_TIMEOUT 16//connect to 3G timeout (PPP)
#define MODEM_ERR_STATE 17//invalid cmd state
#define MODEM_ERR_BREAK 18//user break
#define MODEM_ERR_SEM 19//create named semaphore for modem failed

Содержание

Скачать