Enhanced ShockBurst

Parsing Enhanced ShockBurst messages

When processing ESB messages sent to a compatible interface, the whad::esb::EsbMsg::getType() function returns the corresponding message type (whad::esb::MessageType). 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)
{
    NanoPbMsg *response = NULL;

    /* Wrap our NanoPbMsg into an EsbMsg. */
    whad::esb::EsbMsg esb_msg(message);

    switch (esb_msg.getType())
    {
        case whad::esb::MessageType::SniffMsg:
        {
            /* Configure our interface in sniff mode ... (custom code) */
            /* ... */

            /* Return a success message. */
            response = new whad::generic::Success();
        }
        break;

        case whad::esb::MessageType::StartMsg:
        {
            /* Start current mode. */
            /* ... */

            /* Return a success message. */
            response = new whad::generic::Success();
        }
        break;

        case whad::esb::MessageType::StopMsg:
        {
            /* Stop current mode. */
            /* ... */

            /* Return a success message. */
            response = new whad::generic::Success();
        }
        break;

        default:
        {
            /* Return an error message. */
            response = new whad::generic::Error();
        }
        break;
    }

    /* Send the response to the host. */
    whad::send(*response);
    delete response;
}

Enhanced ShockBurst API reference

namespace esb

Typedefs

typedef whad::Packet<255> Packet

Enums

enum MessageType

ESB Message type

Values:

enumerator UnknownMsg

Unknown message.

enumerator SetNodeAddrMsg

Set node address message.

enumerator SniffMsg

Set interface in sniffing mode.

enumerator JamMsg

Set interface in jamming mode.

enumerator SendMsg

Send PDU.

enumerator SendRawMsg

Send raw PDU.

enumerator PrxMsg

Set interface in Primary Receiver mode.

enumerator PtxMsg

Set interface in Primary Transmitter mode.

enumerator StartMsg

Start current mode.

enumerator StopMsg

Stop current mode.

enumerator JammedMsg

Jamming result notification.

enumerator RawPduReceivedMsg

Raw PDU received notification.

enumerator PduReceivedMsg

PDU received notification.

Variables

EsbAddress PromiscAddr
EsbAddress NullAddr
class EsbAddress
#include <address.hpp>

Public Functions

EsbAddress(void)

BD Address default constructor.

EsbAddress(uint8_t *pAddress, uint8_t size)

ESB Address constructor.

Parameters:
  • pAddress[in] ESB address byte buffer (5 bytes max)

  • size[in] Address size in bytes

uint8_t *getAddressBuf(void)

Get address buffer.

Returns:

Pointer to the BD address byte buffer (6 bytes)

uint8_t getLength(void)

Get address length.

Return values:

int – Address length in bytes

void setAddress(uint8_t *pAddress, uint8_t size)

Set ESB address.

Parameters:
  • pAddress[in] Pointer to a 6-byte BD address buffer

  • size[in] Address size in bytes (0-5 bytes)

class EsbMsg : public whad::NanoPbMsg
#include <base.hpp>

Subclassed by whad::esb::JamMode, whad::esb::Jammed, whad::esb::PrxMode, whad::esb::PtxMode, whad::esb::RawPacketReceived, whad::esb::SendPacket, whad::esb::SendPacketRaw, whad::esb::SetNodeAddress, whad::esb::SniffMode, whad::esb::Start, whad::esb::Stop

Public Functions

EsbMsg()

ESB message base class.

EsbMsg(NanoPbMsg &pMessage)

ESB message base class.

Parameters:

pMessage[in] NanoPbMsg object containing a discovery domain message

~EsbMsg()

ESB message base class destructor.

MessageType getType(void)

Identify the underlying discovery message.

This method can be used when parsing incoming Discovery domain message to identify the type of message it contains and process it later.

Returns:

Discovery message type.

class JamMode : public whad::esb::EsbMsg
#include <jam.hpp>

Public Functions

JamMode(EsbMsg &message)

Constructor, parses the given message.

Parameters:

message[in] Message to parse as a JamMode message.

JamMode(uint32_t channel)

Constructor, creates a new JamMode message.

Parameters:

channel[in] ESB channel to jam

uint32_t getChannel(void)

Get current channel.

Return values:

Channel – number

class Jammed : public whad::esb::EsbMsg
#include <jammed.hpp>

Public Functions

Jammed(EsbMsg &message)

Constructor, parses an EsbMsg as a Jammed message.

Parameters:

message[in] Message to parse

Jammed(uint32_t timestamp)

Constructor, create a new Jammed message.

Parameters:

timestamp[in] Timestamp at which the target has been successfully jammed.

uint32_t getTimestamp()

Retrieve the corresponding timestamp.

Return values:

Timestamp – in milliseconds

class RawPacketReceived : public whad::esb::EsbMsg
#include <pktrecv.hpp>

Subclassed by whad::esb::PacketReceived

Public Functions

RawPacketReceived(EsbMsg &message)

Constructor, parses an EsbMsg object as a RawPacketReceived message.

Parameters:

message[in] Message to parse

RawPacketReceived(uint32_t channel, Packet &packet)

Constructor, create a RawPacketReceived message.

Parameters:
  • channel[in] ESB channel on which the packet has been captured

  • packet[in] Received packet

void setChannel(uint32_t channel)

Set channel.

Parameters:

channel[in] ESB channel

void setPacket(Packet &packet)

Set packet.

Parameters:

packet[in] Received packet

void setRssi(int32_t rssi)

Set RSSI.

Parameters:

rssi[in] Received Signal Strength Indicator

void setTimestamp(uint32_t timestamp)

Set packet reception timestamp.

Parameters:

timestamp[in] Timestamp (milliseconds)

void setAddress(EsbAddress &address)

Set destination address.

Parameters:

address[in] ESB address

void setCrcValidity(bool validity)

Set CRC validity.

Parameters:

validity[in] True if CRC is valid, false otherwise

uint32_t getChannel()

Get the channel number this packet has been captured on.

Return values:

Channel – number

bool hasRssi()

Determine if RSSI is available.

Return values:

True – if available, false otherwise.

int32_t getRssi()

Retrieve the RSSI level.

Return values:

RSSI

bool hasTimestamp()

Determine if a timestamp is available.

Return values:

True – if available, false otherwise

uint32_t getTimestamp()

Retrieve the associated timestamp.

Return values:

Timestamp – in milliseconds

bool hasCrcValidity()

Determine if CRC validity is available.

Return values:

True – if available, false otherwise

bool isCrcValid()

Check if CRC is valid (provided if CRC validity is true)

Return values:

True – if CRC is valid, false otherwise

bool hasAddress()

Determine if the destination address is available.

Return values:

True – if available, false otherwise

EsbAddress &getAddress()

Retrieve the destination address.

Return values:

Destination – address

Packet &getPacket()

Retrieve the captured packet bytes.

Return values:

Captured – packet

class PacketReceived : public whad::esb::RawPacketReceived
#include <pktrecv.hpp>

Public Functions

PacketReceived(EsbMsg &message)

Constructor, parse a message as a PacketReceived message.

PacketReceived(uint32_t channel, Packet &packet)

Constructor, create a new PacketReceived message.

Parameters:
  • channel[in] ESB channel the packet has been captured on

  • packet[in] Captured packet

class PrxMode : public whad::esb::EsbMsg
#include <prx.hpp>

Public Functions

PrxMode(EsbMsg &message)

Constructor, parse an EsbMsg as a PrxMode message.

Parameters:

message[in] Message to parse

PrxMode(uint32_t channel)

Constructor, create a PrxMode message.

Parameters:

channel[in] ESB channel to listen on

uint32_t getChannel()

Retrieve the associated channel.

Return values:

Channel – number

class PtxMode : public whad::esb::EsbMsg
#include <ptx.hpp>

Public Functions

PtxMode(EsbMsg &message)

Constructor, parse a message as a PtxMode message.

Parameters:

message[in] Message to parse

PtxMode(uint32_t channel)

Constructor, create a PtxMode message.

Parameters:

channel[in] ESB channel on which messages will be sent

uint32_t getChannel()

Retrieve the channel in use.

Return values:

Channel – number

class SendPacket : public whad::esb::EsbMsg
#include <sendpkt.hpp>

Public Functions

SendPacket(EsbMsg &message)

Constructor, parse an EsbMsg as a SendPacket message.

SendPacket(uint32_t channel, uint32_t retries, Packet &packet)

Constructor, create a SendPacket message.

Parameters:
  • channel[in] Channel on which the packet has to be sent

  • retries[in] Number of max retransmission retries

  • packet[in] Packet to send

uint32_t getChannel()

Get the channel number.

Return values:

Channel – number

uint32_t getRetrCount()

Get the maximum retransmission count.

Return values:

Maximum – number of retransmissions

Packet &getPacket()

Get the packet to send.

Return values:

Packet – to send

class SendPacketRaw : public whad::esb::EsbMsg
#include <sendpkt.hpp>

Public Functions

SendPacketRaw(EsbMsg &message)

Constructor, parse an EsbMsg into a SendPacketRaw message.

Parameters:

message[in] Message to parse

SendPacketRaw(uint32_t channel, uint32_t retries, Packet &packet)

Constructor, create a SendPacketRaw message.

Parameters:
  • channel[in] Channel on which the packet has to be sent

  • retries[in] Number of max retransmission retries

  • packet[in] Packet to send

uint32_t getChannel()

Get the channel number.

Return values:

Channel – number

uint32_t getRetrCount()

Get the maximum retransmission count.

Return values:

Maximum – number of retransmissions

Packet &getPacket()

Get the packet to send.

Return values:

Packet – to send

class SetNodeAddress : public whad::esb::EsbMsg
#include <setnodeaddr.hpp>

Public Functions

SetNodeAddress(EsbMsg &message)

Constructor, parse a message as a SetNodeAddress message.

Parameters:

message[in] Message to parse

SetNodeAddress(EsbAddress &address)

Constructor, create a SetNodeAddress.

Parameters:

address[in] ESB address to set

EsbAddress &getAddress()

Retrieve the ESB address.

Return values:

Node – address

class SniffMode : public whad::esb::EsbMsg
#include <sniff.hpp>

Public Functions

SniffMode(EsbMsg &message)

Constructor, parse message as a SniffMode message.

Parameters:

message[in] Message to parse

SniffMode()

Constructor, create a SniffMode message to sniff all packets on. all channels. Acks are not reported.

Parameters:

address[in] Target ESB address

SniffMode(uint32_t channel, EsbAddress &address, bool showAcks)

Constructor, create a SniffMode message.

Parameters:
  • channel[in] ESB channel to sniff

  • address[in] Target ESB address

  • showAcks[in] Report acknowledgements

SniffMode(uint32_t channel)

Constructor, create a SniffMode message to sniff a specific channel. Acks are not reported.

Parameters:

channel[in] Channel to sniff

SniffMode(uint32_t channel, EsbAddress &address)

Constructor, create a SniffMode message to sniff a specific target on a specific channel. Acks are not reported.

Parameters:
  • channel[in] ESB channel to sniff

  • address[in] Target ESB address

SniffMode(EsbAddress &address)

Constructor, create a SniffMode message to sniff a specific target. Acks are not reported.

Parameters:

address[in] Target ESB address

uint32_t getChannel(void)

Get the channel number.

Return values:

Channel – number

EsbAddress &getAddress(void)

Get the target address.

Return values:

Target – ESB address

bool mustShowAcks(void)

Determine if acks must be reported.

Return values:

True – if acks must be reported, false otherwise.

class Start : public whad::esb::EsbMsg
#include <start.hpp>

Public Functions

Start(EsbMsg &message)

Constructor, parse an EsbMsg as a Start message.

Parameters:

message[in] Message to parse

Start()

Constructor, create a Start message.

class Stop : public whad::esb::EsbMsg
#include <stop.hpp>

Public Functions

Stop(EsbMsg &message)

Constructor, parse an EsbMsg as a Stop message.

Parameters:

message[in] Message to parse

Stop()

Constructor, create a Stop message.