GSM & GPRS API¶
API Reference¶
Header File¶
Functions¶
-
int
network_getparam(struct netparam_t *param)¶ Get Network parameters
- Return
always return 0
- Parameters
param: [out] Pointer to parameter structure filled on return see netparam_t
-
int
network_getapn(char *apn, char *user, char *pwd)¶ Get APN configuration stored in memory
- Return
0 on success, negative value on error
- Parameters
apn: [out] Access point name (APN)user: [out] APN user (optional, can be null)pwd: [out] APN Password (optional, can be null)
-
int
network_setapn(const char *apn, const char *user, const char *pwd)¶ Configure APN and store in memory. New setting will be applied only after reboot
- Return
0 on success, negative value on error
- Parameters
apn: [in] Access point name (APN)user: [in] APN user (optional, can be null)pwd: [in] APN password (optional, can be null)
-
int
network_getdns(char *pri, char *sec)¶ Get DNS servers
- Return
0 on success, negative value on error
- Parameters
pri: [out] Primary DNS serversec: [out] Secondary DNS server
-
int
network_setdns(const char *pri, const char *sec)¶ Set DNS servers
- Return
0 on success, negative value on error
- Parameters
pri: [in] Primary DNS server to setsec: [in] Secondary DNS server to set
-
int
network_resetdns(void)¶ Reset DNS servers to network default
- Return
0 on success, negative value on error
-
int
network_getstatus(int sockfd)¶ Get network status. If socket descriptor is provided, extended network status will be provided with socket status
- Return
network status see _net_state
- Parameters
sockfd: [in] Socket descriptor (optional, 0 if not used)
-
int
network_isready(void)¶ Get status of network, if its ready or not for IP data transmission
- Return
returns 1 if network ready, 0 otherwise
-
void
network_reset(void)¶ Reset and restart network
-
int
network_gprsenable(int enable)¶ Enable/Disable GPRS. GPRS is enabled by default
- Return
0 on success, negative value on error
- Parameters
enable: [in] 1 to enable, 0 to disable
-
int
network_isgprsenable(void)¶ Get GPRS enable/disable status
- Return
GPRS status
-
unsigned char *
network_getlocalip(void)¶ Get IP address assigned to module
- Return
IP Address octets
-
const char *
network_getcurrapn(void)¶ Get currently used APN
- Return
currently used APN (Do not free the buffer)
-
int
network_setup_statusled(int gpionum)¶ Setup Network status LED. Attach GPIO line managed by network thread for status LED.
IO Drive Logic: Positive (1 - High, 0 - Low)
No Network/No Sim: LED Off Searching Network: 50/500 GSM/GPRS Registered: 50/1000 Socket Connecting: 500/500 Network Idle: 50/2000 Data Sending: 100/100 Unknow error: 50/50
- Return
0 on success, negative value on error
- Parameters
gpionum: [in] GPIO Number to use
Structures¶
-
struct
netparam_t¶ Network parameter structure
Public Members
-
uint8_t
simstate¶ SIM CPIN status simstate_e
-
uint8_t
creg¶ GSM status networkstate_e
-
uint8_t
cgreg¶ EPS Network (4G/NB-Iot)/GPRS status networkstate_e
-
uint8_t
state¶ Internal state (for debugging)
-
uint8_t
signal¶ Signal level
For GSM; RSSI Value - 0:-113dBm or less to 31:-55dBm or more,
For 4G/NB-IoT; RSRP Value - 0:-140dBm or less to 97:-44dBm or more,
99: Not detectable
-
const char *
apn¶ Currently used APN as null terminted string
-
uint8_t
Enumerations¶
-
enum
_net_state¶ Network state
Values:
-
enumerator
NET_STATE_INVALID¶ Network status unknown/invalid
-
enumerator
NET_STATE_NO_NETWORK¶ Network status no signal
-
enumerator
NET_STATE_GSM¶ Network status GSM registered
-
enumerator
NET_STATE_GPRS¶ Network status GPRS registered
-
enumerator
NET_STATE_SOC_CONNECTING¶ Network status socket connection in progress
-
enumerator
NET_STATE_SOC_CONNECTED¶ Network status socket connected
-
enumerator
NET_STATE_SOC_SENDING¶ Network status sending data over socket
-
enumerator
