BGAPI Functions#

Functions provided by the BGAPI protocol.

Functions#

sl_status_t

Lock the BGAPI for exclusive access.

void

Release the lock obtained by sl_bgapi_lock.

void
sl_bgapi_handle_command(uint32_t hdr, const void *data)

Handle a BGAPI command in binary format.

void *

Get the response of a handled BGAPI command.

Function Documentation#

sl_bgapi_lock#

sl_status_t sl_bgapi_lock (void )

Lock the BGAPI for exclusive access.

Parameters
N/A

NOTE: This function is provided for NCP/CPC components that need to handle BGAPI commands and responses in their binary format in an application that uses an RTOS. Normal application code that issues BGAPI commands by calling API functions defined by protocol stacks must never call this function directly.

See the documentation of sl_bgapi_handle_command for the full sequence that must be followed when processing commands in their binary format.

Returns

  • SL_STATUS_OK if the lock has been obtained, otherwise an error code


Definition at line 228 of file include/sl_bgapi.h

sl_bgapi_unlock#

void sl_bgapi_unlock (void )

Release the lock obtained by sl_bgapi_lock.

Parameters
N/A

NOTE: This function is provided for NCP/CPC components that need to handle BGAPI commands and responses in their binary format in an application that uses an RTOS. Normal application code that issues BGAPI commands by calling API functions defined by protocol stacks must never call this function directly.

See the documentation of sl_bgapi_handle_command for the full sequence that must be followed when processing commands in their binary format.


Definition at line 242 of file include/sl_bgapi.h

sl_bgapi_handle_command#

void sl_bgapi_handle_command (uint32_t hdr, const void * data)

Handle a BGAPI command in binary format.

Parameters
[in]hdr

The BGAPI command header

[in]data

The payload data associated with the command

NOTE: This function is provided for NCP/CPC components that need to handle BGAPI commands and responses in their binary format. Normal application code that issues BGAPI commands by calling API functions defined by protocol stacks must never call this function directly.

If the application uses an RTOS, the caller must protect the BGAPI handling by obtaining the BGAPI lock with sl_bgapi_lock, handle the command with sl_bgapi_handle_command, read the response from the buffer returned by sl_bgapi_get_command_response, and then release the lock with sl_bgapi_unlock. Here's an example of the full sequence that's required:

// Lock BGAPI for exclusive access
sl_status_t status = sl_bgapi_lock();
if (status != SL_STATUS_OK) {
  // Locking will only fail if there are fatal unrecoverable errors with the
  // RTOS primitives, so caller may choose to just assert in case of errors.
}

// Process the command
sl_bgapi_handle_command(hdr, data);

// Read the response
void *rsp = sl_bgapi_get_command_response();
uint32_t rsp_header = *((uint32_t *)rsp);
size_t rsp_len = SL_BGAPI_MSG_LEN(rsp_header) + SL_BGAPI_MSG_HEADER_LEN;
// Send the `rsp_len` bytes of response starting from `rsp`

// Finally unlock the BGAPI to allow other commands to proceed
sl_bgapi_unlock();

Empty stub implementations are provided for sl_bgapi_lock and sl_bgapi_unlock, so the same sequence can be used for all NCP/CPC implementations even if an RTOS is not present.


Definition at line 286 of file include/sl_bgapi.h

sl_bgapi_get_command_response#

void * sl_bgapi_get_command_response (void )

Get the response of a handled BGAPI command.

Parameters
N/A

NOTE: This function is provided for NCP/CPC components that need to handle BGAPI commands and responses in their binary format. Normal application code that issues BGAPI commands by calling API functions defined by protocol stacks must never call this function directly.

See the documentation of sl_bgapi_handle_command for the full sequence that must be followed when processing commands in their binary format.

Returns


Definition at line 302 of file include/sl_bgapi.h