LwGSM

group LWGSM

Lightweight GSM-AT parser library.

Functions

lwgsmr_t lwgsm_init(lwgsm_evt_fn evt_func, const uint32_t blocking)

Init and prepare GSM stack for device operation.

Note

Function must be called from operating system thread context. It creates necessary threads and waits them to start, thus running operating system is important.

Return

lwgsmOK on success, member of lwgsmr_t enumeration otherwise

Parameters
  • [in] evt_func: Global event callback function for all major events

  • [in] blocking: Status whether command should be blocking or not. Used when LWGSM_CFG_RESET_ON_INIT is enabled.

lwgsmr_t lwgsm_reset(const lwgsm_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Execute reset and send default commands.

Return

lwgsmOK on success, member of lwgsmr_t enumeration otherwise

Parameters
  • [in] evt_fn: Callback function called when command is finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

lwgsmr_t lwgsm_reset_with_delay(uint32_t delay, const lwgsm_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Execute reset and send default commands with delay.

Return

lwgsmOK on success, member of lwgsmr_t enumeration otherwise

Parameters
  • [in] delay: Number of milliseconds to wait before initiating first command to device

  • [in] evt_fn: Callback function called when command is finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

lwgsmr_t lwgsm_set_func_mode(uint8_t mode, const lwgsm_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Set modem function mode.

Note

Use this function to set modem to normal or low-power mode

Return

lwgsmOK on success, member of lwgsmr_t enumeration otherwise

Parameters
  • [in] mode: Mode status. Set to 1 for full functionality or 0 for low-power mode (no functionality)

  • [in] evt_fn: Callback function called when command is finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

lwgsmr_t lwgsm_core_lock(void)

Lock stack from multi-thread access, enable atomic access to core.

If lock was 0 prior function call, lock is enabled and increased

Note

Function may be called multiple times to increase locks. Application must take care to call lwgsm_core_unlock the same amount of time to make sure lock gets back to 0

Return

lwgsmOK on success, member of lwgsmr_t enumeration otherwise

lwgsmr_t lwgsm_core_unlock(void)

Unlock stack for multi-thread access.

Used in conjunction with lwgsm_core_lock function

If lock was non-zero before function call, lock is decreased. When lock == 0, protection is disabled and other threads may access to core

Return

lwgsmOK on success, member of lwgsmr_t enumeration otherwise

lwgsmr_t lwgsm_device_set_present(uint8_t present, const lwgsm_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Notify stack if device is present or not.

Use this function to notify stack that device is not physically connected and not ready to communicate with host device

Return

lwgsmOK on success, member of lwgsmr_t enumeration otherwise

Parameters
  • [in] present: Flag indicating device is present

  • [in] evt_fn: Callback function called when command is finished. Set to NULL when not used

  • [in] evt_arg: Custom argument for event callback function

  • [in] blocking: Status whether command should be blocking or not

uint8_t lwgsm_device_is_present(void)

Check if device is present.

Return

1 on success, 0 otherwise

uint8_t lwgsm_delay(uint32_t ms)

Delay for amount of milliseconds.

Delay is based on operating system semaphores. It locks semaphore and waits for timeout in ms time. Based on operating system, thread may be put to blocked list during delay and may improve execution speed

Return

1 on success, 0 otherwise

Parameters
  • [in] ms: Milliseconds to delay