Event management

group LWGSM_EVT

Event helper functions.

Reset event

Event helper functions for LWGSM_EVT_RESET event

lwgsmr_t lwgsm_evt_reset_get_result(lwgsm_evt_t *cc)

Get reset sequence operation status.

Parameters

cc[in] Event data

Returns

Member of lwgsmr_t enumeration

Restore event

Event helper functions for LWGSM_EVT_RESTORE event

lwgsmr_t lwgsm_evt_restore_get_result(lwgsm_evt_t *cc)

Get restore sequence operation status.

Parameters

cc[in] Event data

Returns

Member of lwgsmr_t enumeration

Current network operator

Event helper functions for LWGSM_EVT_NETWORK_OPERATOR_CURRENT event

const lwgsm_operator_curr_t *lwgsm_evt_network_operator_get_current(lwgsm_evt_t *cc)

Get current operator data from event.

Parameters

cc[in] Event data

Returns

Current operator handle

Connection data received

Event helper functions for LWGSM_EVT_CONN_RECV event

lwgsm_pbuf_p lwgsm_evt_conn_recv_get_buff(lwgsm_evt_t *cc)

Get buffer from received data.

Parameters

cc[in] Event handle

Returns

Buffer handle

lwgsm_conn_p lwgsm_evt_conn_recv_get_conn(lwgsm_evt_t *cc)

Get connection handle for receive.

Parameters

cc[in] Event handle

Returns

Connection handle

Connection data send

Event helper functions for LWGSM_EVT_CONN_SEND event

lwgsm_conn_p lwgsm_evt_conn_send_get_conn(lwgsm_evt_t *cc)

Get connection handle for data sent event.

Parameters

cc[in] Event handle

Returns

Connection handle

size_t lwgsm_evt_conn_send_get_length(lwgsm_evt_t *cc)

Get number of bytes sent on connection.

Parameters

cc[in] Event handle

Returns

Number of bytes sent

lwgsmr_t lwgsm_evt_conn_send_get_result(lwgsm_evt_t *cc)

Check if connection send was successful.

Parameters

cc[in] Event handle

Returns

Member of lwgsmr_t enumeration

Connection active

Event helper functions for LWGSM_EVT_CONN_ACTIVE event

lwgsm_conn_p lwgsm_evt_conn_active_get_conn(lwgsm_evt_t *cc)

Get connection handle.

Parameters

cc[in] Event handle

Returns

Connection handle

uint8_t lwgsm_evt_conn_active_is_client(lwgsm_evt_t *cc)

Check if new connection is client.

Parameters

cc[in] Event handle

Returns

1 if client, 0 otherwise

Connection close event

Event helper functions for LWGSM_EVT_CONN_CLOSE event

lwgsm_conn_p lwgsm_evt_conn_close_get_conn(lwgsm_evt_t *cc)

Get connection handle.

Parameters

cc[in] Event handle

Returns

Connection handle

uint8_t lwgsm_evt_conn_close_is_client(lwgsm_evt_t *cc)

Check if close connection was client.

Parameters

cc[in] Event handle

Returns

1 if client, 0 otherwise

uint8_t lwgsm_evt_conn_close_is_forced(lwgsm_evt_t *cc)

Check if connection close even was forced by user.

Parameters

cc[in] Event handle

Returns

1 if forced, 0 otherwise

lwgsmr_t lwgsm_evt_conn_close_get_result(lwgsm_evt_t *cc)

Get connection close event result.

Parameters

cc[in] Event handle

Returns

Member of lwgsmr_t enumeration

Connection poll

Event helper functions for LWGSM_EVT_CONN_POLL event

lwgsm_conn_p lwgsm_evt_conn_poll_get_conn(lwgsm_evt_t *cc)

Get connection handle.

Parameters

cc[in] Event handle

Returns

Connection handle

Connection error

Event helper functions for LWGSM_EVT_CONN_ERROR event

lwgsmr_t lwgsm_evt_conn_error_get_error(lwgsm_evt_t *cc)

Get connection error type.

Parameters

cc[in] Event handle

Returns

Member of lwgsmr_t enumeration

lwgsm_conn_type_t lwgsm_evt_conn_error_get_type(lwgsm_evt_t *cc)

Get connection type.

Parameters

cc[in] Event handle

Returns

Member of lwgsmr_t enumeration

const char *lwgsm_evt_conn_error_get_host(lwgsm_evt_t *cc)

Get connection host.

Parameters

cc[in] Event handle

Returns

Host name for connection

lwgsm_port_t lwgsm_evt_conn_error_get_port(lwgsm_evt_t *cc)

Get connection port.

Parameters

cc[in] Event handle

Returns

Host port number

void *lwgsm_evt_conn_error_get_arg(lwgsm_evt_t *cc)

Get user argument.

Parameters

cc[in] Event handle

Returns

User argument

Signal strength

Event helper functions for LWGSM_EVT_CONN_RECV event

int16_t lwgsm_evt_signal_strength_get_rssi(lwgsm_evt_t *cc)

Get RSSi from CSQ command.

Parameters

cc[in] Event data

Returns

RSSI value in units of dBm

SMS received

Event helper functions for LWGSM_EVT_SMS_RECV event

size_t lwgsm_evt_sms_recv_get_pos(lwgsm_evt_t *cc)

Get SMS position in memory which has been saved on receive.

Parameters

cc[in] Event handle

Returns

SMS position in memory

lwgsm_mem_t lwgsm_evt_sms_recv_get_mem(lwgsm_evt_t *cc)

Get SMS memory used to save SMS on receive.

Parameters

cc[in] Event handle

Returns

SMS memory location

SMS content read

Event helper functions for LWGSM_EVT_SMS_READ event

lwgsm_sms_entry_t *lwgsm_evt_sms_read_get_entry(lwgsm_evt_t *cc)

Get SMS entry after successful read.

Parameters

cc[in] Event handle

Returns

SMS entry

lwgsmr_t lwgsm_evt_sms_read_get_result(lwgsm_evt_t *cc)

Get SMS read operation result.

Parameters

cc[in] Event handle

Returns

SMS entry

SMS send

Event helper functions for LWGSM_EVT_SMS_SEND event

lwgsmr_t lwgsm_evt_sms_send_get_result(lwgsm_evt_t *cc)

Get SMS send result status.

Parameters

cc[in] Event handle

Returns

Member of lwgsmr_t enumeration

size_t lwgsm_evt_sms_send_get_pos(lwgsm_evt_t *cc)

Get SMS send position in memory.

Note

Use only if SMS sent successfully

Parameters

cc[in] Event handle

Returns

Position in memory

SMS delete

Event helper functions for LWGSM_EVT_SMS_DELETE event

lwgsmr_t lwgsm_evt_sms_delete_get_result(lwgsm_evt_t *cc)

Get SMS delete result status.

Parameters

cc[in] Event handle

Returns

Member of lwgsmr_t enumeration

size_t lwgsm_evt_sms_delete_get_pos(lwgsm_evt_t *cc)

Get SMS delete memory position.

Parameters

cc[in] Event handle

Returns

Deleted position in memory

lwgsm_mem_t lwgsm_evt_sms_delete_get_mem(lwgsm_evt_t *cc)

Get SMS delete memory.

Parameters

cc[in] Event handle

Returns

SMS memory for delete operation

Call status changed

Event helper functions for LWGSM_EVT_CALL_CHANGED event

const lwgsm_call_t *lwgsm_evt_call_changed_get_call(lwgsm_evt_t *cc)

Get call information from changed event.

Parameters

cc[in] Event handle

Returns

Position in memory

Operator scan

Event helper functions for LWGSM_EVT_OPERATOR_SCAN event

lwgsmr_t lwgsm_evt_operator_scan_get_result(lwgsm_evt_t *cc)

Get operator scan operation status.

Parameters

cc[in] Event data

Returns

Member of lwgsmr_t enumeration

lwgsm_operator_t *lwgsm_evt_operator_scan_get_entries(lwgsm_evt_t *cc)

Get operator entries from scan.

Parameters

cc[in] Event data

Returns

Pointer to array of operator entries

size_t lwgsm_evt_operator_scan_get_length(lwgsm_evt_t *cc)

Get length of operators scanned.

Parameters

cc[in] Event data

Returns

Number of operators scanned

Typedefs

typedef lwgsmr_t (*lwgsm_evt_fn)(struct lwgsm_evt *evt)

Event function prototype.

Parameters

evt[in] Callback event data

Returns

lwgsmOK on success, member of lwgsmr_t otherwise

Enums

enum lwgsm_evt_type_t

List of possible callback types received to user.

Values:

enumerator LWGSM_EVT_INIT_FINISH

Initialization has been finished at this point

enumerator LWGSM_EVT_RESET

Device reset operation finished

enumerator LWGSM_EVT_RESTORE

Device restore operation finished

enumerator LWGSM_EVT_CMD_TIMEOUT

Timeout on command. When application receives this event, it may reset system as there was (maybe) a problem in device

enumerator LWGSM_EVT_DEVICE_PRESENT

Notification when device present status changes

enumerator LWGSM_EVT_DEVICE_IDENTIFIED

Device identified event

enumerator LWGSM_EVT_SIGNAL_STRENGTH

Signal strength event

enumerator LWGSM_EVT_SIM_STATE_CHANGED

SIM card state changed

enumerator LWGSM_EVT_OPERATOR_SCAN

Operator scan finished event

enumerator LWGSM_EVT_NETWORK_OPERATOR_CURRENT

Current operator event

enumerator LWGSM_EVT_NETWORK_REG_CHANGED

Network registration changed. Available even when LWGSM_CFG_NETWORK is disabled

enumerator LWGSM_EVT_NETWORK_ATTACHED

Attached to network, PDP context active and ready for TCP/IP application

enumerator LWGSM_EVT_NETWORK_DETACHED

Detached from network, PDP context not active anymore

enumerator LWGSM_EVT_CONN_RECV

Connection data received

enumerator LWGSM_EVT_CONN_SEND

Connection data send

enumerator LWGSM_EVT_CONN_ACTIVE

Connection just became active

enumerator LWGSM_EVT_CONN_ERROR

Client connection start was not successful

enumerator LWGSM_EVT_CONN_CLOSE

Connection close event. Check status if successful

enumerator LWGSM_EVT_CONN_POLL

Poll for connection if there are any changes

enumerator LWGSM_EVT_SMS_ENABLE

SMS enable event

enumerator LWGSM_EVT_SMS_READY

SMS ready event

enumerator LWGSM_EVT_SMS_SEND

SMS send event

enumerator LWGSM_EVT_SMS_RECV

SMS received

enumerator LWGSM_EVT_SMS_READ

SMS read

enumerator LWGSM_EVT_SMS_DELETE

SMS delete

enumerator LWGSM_EVT_SMS_LIST

SMS list

enumerator LWGSM_EVT_CALL_ENABLE

Call enable event

enumerator LWGSM_EVT_CALL_READY

Call ready event

enumerator LWGSM_EVT_CALL_CHANGED

Call info changed, +CLCK statement received

enumerator LWGSM_EVT_CALL_RING

Call is ringing event

enumerator LWGSM_EVT_CALL_BUSY

Call is busy

enumerator LWGSM_EVT_CALL_NO_CARRIER

No carrier to make a call

enumerator LWGSM_EVT_PB_ENABLE

Phonebook enable event

enumerator LWGSM_EVT_PB_LIST

Phonebook list event

enumerator LWGSM_EVT_PB_SEARCH

Phonebook search event

Functions

lwgsmr_t lwgsm_evt_register(lwgsm_evt_fn fn)

Register callback function for global (non-connection based) events.

Parameters

fn[in] Callback function to call on specific event

Returns

lwgsmOK on success, member of lwgsmr_t enumeration otherwise

lwgsmr_t lwgsm_evt_unregister(lwgsm_evt_fn fn)

Unregister callback function for global (non-connection based) events.

Note

Function must be first registered using lwgsm_evt_register

Parameters

fn[in] Callback function to remove from event list

Returns

lwgsmOK on success, member of lwgsmr_t enumeration otherwise

lwgsm_evt_type_t lwgsm_evt_get_type(lwgsm_evt_t *cc)

Get event type.

Parameters

cc[in] Event handle

Returns

Event type. Member of lwgsm_evt_type_t enumeration

struct lwgsm_evt_t
#include <lwgsm_typedefs.h>

Global callback structure to pass as parameter to callback function.

Public Members

lwgsm_evt_type_t type

Callback type

lwgsmr_t res

Reset operation result

Restore operation result

Scan operation result

Send data result

Result of close event. Set to lwgsmOK on success.

SMS send result information

SMS read result information

Operation success

Result on command

Enable status

struct lwgsm_evt_t::[anonymous]::[anonymous] reset

Reset sequence finish. Use with LWGSM_EVT_RESET event

struct lwgsm_evt_t::[anonymous]::[anonymous] restore

Restore sequence finish. Use with LWGSM_EVT_RESTORE event

lwgsm_sim_state_t state

SIM state

struct lwgsm_evt_t::[anonymous]::[anonymous] cpin

CPIN event

const lwgsm_operator_curr_t *operator_current

Current operator info

struct lwgsm_evt_t::[anonymous]::[anonymous] operator_current

Current operator event. Use with LWGSM_EVT_NETWORK_OPERATOR_CURRENT event

lwgsm_operator_t *ops

Pointer to operators

size_t opf

Number of operators found

struct lwgsm_evt_t::[anonymous]::[anonymous] operator_scan

Operator scan event. Use with LWGSM_EVT_OPERATOR_SCAN event

int16_t rssi

Strength in units of dBm

struct lwgsm_evt_t::[anonymous]::[anonymous] rssi

Signal strength event. Use with LWGSM_EVT_SIGNAL_STRENGTH event

lwgsm_conn_p conn

Connection where data were received

Connection where data were sent

Pointer to connection

Set connection pointer

lwgsm_pbuf_p buff

Pointer to received data

struct lwgsm_evt_t::[anonymous]::[anonymous] conn_data_recv

Network data received. Use with LWGSM_EVT_CONN_RECV event

size_t sent

Number of bytes sent on connection

struct lwgsm_evt_t::[anonymous]::[anonymous] conn_data_send

Data successfully sent. Use with LWGSM_EVT_CONN_SEND event

const char *host

Host to use for connection

lwgsm_port_t port

Remote port used for connection

lwgsm_conn_type_t type

Connection type

void *arg

Connection argument used on connection

lwgsmr_t err

Error value

struct lwgsm_evt_t::[anonymous]::[anonymous] conn_error

Client connection start error. Use with LWGSM_EVT_CONN_ERROR event

uint8_t client

Set to 1 if connection is/was client mode

uint8_t forced

Set to 1 if connection action was forced

struct lwgsm_evt_t::[anonymous]::[anonymous] conn_active_close

Process active and closed statuses at the same time. Use with LWGSM_EVT_CONN_ACTIVE or LWGSM_EVT_CONN_CLOSE events

struct lwgsm_evt_t::[anonymous]::[anonymous] conn_poll

Polling active connection to check for timeouts. Use with LWGSM_EVT_CONN_POLL event

lwgsmr_t status

Enable status

struct lwgsm_evt_t::[anonymous]::[anonymous] sms_enable

SMS enable event. Use with LWGSM_EVT_SMS_ENABLE event

size_t pos

Position in memory

Received position in memory for sent SMS

Deleted position in memory for sent SMS

struct lwgsm_evt_t::[anonymous]::[anonymous] sms_send

SMS sent info. Use with LWGSM_EVT_SMS_SEND event

lwgsm_mem_t mem

Memory of received message

Memory of deleted message

Memory used for scan

struct lwgsm_evt_t::[anonymous]::[anonymous] sms_recv

SMS received info. Use with LWGSM_EVT_SMS_RECV event

lwgsm_sms_entry_t *entry

SMS entry

struct lwgsm_evt_t::[anonymous]::[anonymous] sms_read

SMS read. Use with LWGSM_EVT_SMS_READ event

struct lwgsm_evt_t::[anonymous]::[anonymous] sms_delete

SMS delete. Use with LWGSM_EVT_SMS_DELETE event

lwgsm_sms_entry_t *entries

Pointer to entries

size_t size

Number of valid entries

struct lwgsm_evt_t::[anonymous]::[anonymous] sms_list

SMS list. Use with LWGSM_EVT_SMS_LIST event

struct lwgsm_evt_t::[anonymous]::[anonymous] call_enable

Call enable event. Use with LWGSM_EVT_CALL_ENABLE event

const lwgsm_call_t *call

Call information

struct lwgsm_evt_t::[anonymous]::[anonymous] call_changed

Call changed info. Use with LWGSM_EVT_CALL_CHANGED event

struct lwgsm_evt_t::[anonymous]::[anonymous] pb_enable

Phonebook enable event. Use with LWGSM_EVT_PB_ENABLE event

lwgsm_pb_entry_t *entries

Pointer to entries

struct lwgsm_evt_t::[anonymous]::[anonymous] pb_list

Phonebok list. Use with LWGSM_EVT_PB_LIST event

const char *search

Search string

struct lwgsm_evt_t::[anonymous]::[anonymous] pb_search

Phonebok search list. Use with LWGSM_EVT_PB_SEARCH event

union lwgsm_evt_t::[anonymous] evt

Callback event union