GSM AT Lib

group GSM

GSM stack.

Functions

gsmr_t gsm_init(gsm_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

gsmOK on success, member of gsmr_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 GSM_CFG_RESET_ON_INIT is enabled.

gsmr_t gsm_reset(const gsm_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Execute reset and send default commands.

Return

gsmOK on success, member of gsmr_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

gsmr_t gsm_reset_with_delay(uint32_t delay, const gsm_api_cmd_evt_fn evt_fn, void *const evt_arg, const uint32_t blocking)

Execute reset and send default commands with delay.

Return

gsmOK on success, member of gsmr_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

gsmr_t gsm_set_func_mode(uint8_t mode, const gsm_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

gsmOK on success, member of gsmr_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

gsmr_t gsm_core_lock(void)

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

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

Note

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

Return

gsmOK on success, member of gsmr_t enumeration otherwise

gsmr_t gsm_core_unlock(void)

Unlock stack for multi-thread access.

Used in conjunction with gsm_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

gsmOK on success, member of gsmr_t enumeration otherwise

gsmr_t gsm_device_set_present(uint8_t present, const gsm_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

gsmOK on success, member of gsmr_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 gsm_device_is_present(void)

Check if device is present.

Return

1 on success, 0 otherwise

uint8_t gsm_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