Enhanced ShockBurst
Parsing Enhanced ShockBurst messages
When processing ESB messages sent to a compatible interface,
the whad_esb_get_message_type() function returns the corresponding
message type (whad_esb_msgtype_t). This message type is then used
to process and parse the incoming message.
The following example code shows a message processing function defined for a compatible interface that only supports ESB packet sniffing. The supported commands must also be indicated in the interface’s capabilities as described in Discovery of interface characteristics.
void process_esb_message(Message *p_message)
{
Message response;
switch (whad_esb_get_message_type(p_message))
{
case WHAD_ESB_SNIFF:
{
/* Configure our interface in sniff mode ... (custom code) */
/* ... */
/* Return a success message. */
whad_generic_cmd_result(&response, WHAD_RESULT_SUCCESS);
}
break;
case WHAD_ESB_START:
{
/* Start current mode. */
/* ... */
/* Return a success message. */
whad_generic_cmd_result(&response, WHAD_RESULT_SUCCESS);
}
break;
case WHAD_ESB_STOP:
{
/* Stop current mode. */
/* ... */
/* Return a success message. */
whad_generic_cmd_result(&response, WHAD_RESULT_SUCCESS);
}
break;
default:
{
/* Return an error message. */
whad_generic_cmd_result(&response, WHAD_RESULT_ERROR);
}
break;
}
/* Send the response to the host. */
whad_send_message(&response);
}
Enhanced ShockBurst API reference
Enums
-
enum whad_esb_msgtype_t
Supported commands.
This enum defines aliases for NanoPb commands bitmask in order to hide the NanoPb implementation.
This structure needs to be updated if a command is added or removed in WHAD protocol.
Values:
-
enumerator WHAD_ESB_UNKNOWN
-
enumerator WHAD_ESB_SET_NODE_ADDRESS
-
enumerator WHAD_ESB_SNIFF
-
enumerator WHAD_ESB_JAM
-
enumerator WHAD_ESB_SEND
-
enumerator WHAD_ESB_SEND_RAW
-
enumerator WHAD_ESB_PRX
-
enumerator WHAD_ESB_PTX
-
enumerator WHAD_ESB_START
-
enumerator WHAD_ESB_STOP
-
enumerator WHAD_ESB_JAMMED
-
enumerator WHAD_ESB_RAW_PDU_RECEIVED
-
enumerator WHAD_ESB_PDU_RECEIVED
-
enumerator WHAD_ESB_UNKNOWN
Functions
-
whad_esb_msgtype_t whad_esb_get_message_type(Message *p_message)
-
whad_result_t whad_esb_set_node_address(Message *p_message, whad_esb_address_t *p_addr)
Create a SetNodeAddrCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_addr – [in] Pointer to a whad_esb_addr_t structure containing the address
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or address pointer.
-
whad_result_t whad_esb_set_node_address_parse(Message *p_message, whad_esb_address_t *p_addr)
Parse a SetNodeAddrCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_addr – [inout] Pointer to a whad_esb_address_t structure
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or address pointer.
-
whad_result_t whad_esb_sniff(Message *p_message, whad_esb_address_t *p_addr, uint32_t channel, bool show_ack)
Create a SniffCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_addr – [in] Pointer to a buffer containing the address bytes
channel – [in] ESB channel to listen on
show_ack – [in] If set to true, acknowledgements will be reported.
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or address pointer.
-
whad_result_t whad_esb_sniff_parse(Message *p_message, whad_esb_sniff_params_t *p_params)
Parse a SniffCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_params – [inout] Pointer to a whad_esb_sniff_params_t structure
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or address pointer.
-
whad_result_t whad_esb_jam(Message *p_message, uint32_t channel)
Create a JamCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
channel – [in] ESB channel to listen on
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message pointer
-
whad_result_t whad_esb_jam_parse(Message *p_message, uint32_t *p_channel)
parse a JamCmd message
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_channel – [inout] Pointer to the ESB channel
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or channel pointer.
-
whad_result_t whad_esb_send(Message *p_message, uint32_t channel, int retr_count, uint8_t *p_packet, uint8_t packet_len)
Create a JamCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
channel – [in] ESB channel to listen on
retr_count – [in] Number of retransmissions
p_packet – [in] Pointer to the packet bytes to send
packet_len – [in] Packet length in bytes
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_send_parse(Message *p_message, whad_esb_send_params_t *p_params)
Parse a SendCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_params – [inout] Pointer to a
whad_esb_send_params_tstructure
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_send_raw(Message *p_message, uint32_t channel, int retr_count, uint8_t *p_packet, uint8_t packet_len)
Create a SendRawCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
channel – [in] ESB channel to listen on
retr_count – [in] Number of retransmissions
p_packet – [in] Pointer to the packet bytes to send
packet_len – [in] Packet length in bytes
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_send_raw_parse(Message *p_message, whad_esb_send_params_t *p_params)
Parse a SendRawCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_params – [inout] Pointer to a
whad_esb_send_params_tstructure
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_prx(Message *p_message, uint32_t channel)
Create a PrimaryRecevierModeCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
channel – [in] ESB channel to listen on
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_prx_parse(Message *p_message, uint32_t *p_channel)
parse a PrimaryReceiverModeCmd message
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_channel – [inout] Pointer to the ESB channel
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or channel pointer.
-
whad_result_t whad_esb_ptx(Message *p_message, uint32_t channel)
Create a PrimaryTransmitterModeCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
channel – [in] ESB channel to listen on
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_ptx_parse(Message *p_message, uint32_t *p_channel)
Parse a PrimaryTransmitterModeCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_channel – [inout] Pointer to the ESB channel
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or channel pointer.
-
whad_result_t whad_esb_start(Message *p_message)
Create a StartCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_stop(Message *p_message)
Create a StopCmd message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_jammed(Message *p_message, uint32_t timestamp)
Create a Jammed message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
timestamp – [in] Timestamp at which the jamming has been detected
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_jammed_parse(Message *p_message, uint32_t *p_timestamp)
Parse a Jammed message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_timestamp – [inout] Pointer to the timestamp
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or channel pointer.
-
whad_result_t whad_esb_raw_pdu_received(Message *p_message, whad_esb_recvd_packet_t *p_pdu)
Create a RawPduReceived message.
- Parameters:
p_message – [inout] Pointer to a NanoPb Message structure
p_pdu – [in] Pointer to a
whad_esb_recvd_packet_tstructure
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_raw_pdu_received_parse(Message *p_message, whad_esb_recvd_packet_t *p_pdu)
Parse a RawPduReceived message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_pdu – [inout] Pointer to a
whad_esb_recvd_packet_tstructure
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_pdu_received(Message *p_message, whad_esb_recvd_packet_t *p_pdu)
Create a PduReceived message.
- Parameters:
p_message – [inout] Pointer to a NanoPb Message structure
p_pdu – [in] Pointer to a
whad_esb_recvd_packet_tstructure
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.
-
whad_result_t whad_esb_pdu_received_parse(Message *p_message, whad_esb_recvd_packet_t *p_pdu)
Parse a PduReceived message.
- Parameters:
p_message – [in] Pointer to a NanoPb Message structure
p_pdu – [inout] Pointer to a
whad_esb_recvd_packet_tstructure
- Return values:
WHAD_SUCCESS – Success.
WHAD_ERROR – Invalid message or packet pointer.