Bluetooth Low Energy

Parsing BLE messages

When processing Bluetooth Low Energy messages sent to a compatible interface, the whad::ble::BleMsg::getType() function returns the corresponding message type (whad::ble::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 BLE device scanning. The supported commands must also be indicated in the interface’s capabilities as described in Discovery of interface characteristics.

void process_ble_message(NanoPbMsg message)
{
    NanoPbMsg *response = NULL;

    /* Wrap our NanoPbMsg into a BleMsg. */
    whad::ble::BleMsg ble_msg(message);

    switch (ble_msg.getType())
    {
        case whad::ble::MessageType::ScanModeMsg:
        {
            /* Configure our interface in scan mode ... (custom code) */
            /* ... */

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

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

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

        case whad::ble::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;
}

Bluetooth Low Energy API reference

namespace ble

Typedefs

typedef whad::Packet<255> PDU

Enums

enum AddressType

Bluetooth Device address type.

Values:

enumerator AddressRandom

Device address is random.

enumerator AddressPublic

Device address is public.

enum AdvType

Advertisement type.

Values:

enumerator AdvUnknown

Unknown advertisement type.

enumerator AdvInd

Indirected advertisement.

enumerator AdvDirectInd

Directed advertisement.

enumerator AdvNonConnInd

Non-connectable indirected advertised.

enumerator AdvScanInd

Scan request.

enumerator AdvScanRsp

Scan response.

enum Direction

Indicate BLE direction.

Values:

enumerator DirectionUnknown

Direction is unknown.

enumerator DirectionMasterToSlave

From “master” device to “slave” device.

enumerator DirectionSlaveToMaster

From “slave” device to “master” device.

enumerator DirectionInjectionToSlave

Inject data towards “slave” device.

enumerator DirectionInjectionToMaster

Inject data towards “master” device.

enum MessageType

BLE message types.

Values:

enumerator UnknownMsg
enumerator SetBdAddressMsg

Set interface BD address.

enumerator SetAdvDataMsg

Set advertising data.

enumerator SetEncryptionMsg

Set encryption.

enumerator SniffAAMsg

Sniff BLE access address.

enumerator SniffAdvMsg

Sniff advertisements.

enumerator SniffConnReqMsg

Sniff connection requests.

enumerator SniffActConnMsg

Sniff active connection.

enumerator ScanModeMsg

Set scanning mode.

enumerator AdvModeMsg

Set advertising mode.

enumerator PeriphModeMsg

Set peripheral mode.

enumerator CentralModeMsg

Set central mode.

enumerator StartMsg

Start current mode.

enumerator StopMsg

Stop current mode.

enumerator ConnectToMsg

Initiate a connection to a device.

enumerator SendRawPduMsg

Send raw BLE PDU.

enumerator SendPduMsg

Send BLE PDU.

enumerator DisconnectMsg

Disconnect from device.

enumerator PrepareSeqMsg

Prepare a sequence of packets.

enumerator PrepareSeqTriggerMsg

Manually trigger a prepared sequence.

enumerator PrepareSeqDeleteMsg

Delete a prepared sequence.

enumerator JamAdvMsg

Set advertisement jamming mode.

enumerator JamAdvChannelMsg

Set single-channel advertisement jamming mode.

enumerator JamActConnMsg

Set active connection jamming mode.

enumerator HijackMasterMsg

Hijack “master” device mode.

enumerator HijackSlaveMsg

Hijack “slave” device mode

enumerator HijackBothMsg

Hijack both “master” and “slave” devices.

enumerator ReactiveJamMsg

Set reactive jamming mode.

enumerator NotifyConnectedMsg

Notify host about a successful connection.

enumerator NotifyDisconnectedMsg

Notify host of a disconnection.

enumerator RawPduMsg

Notify host about a received raw BLE PDU.

enumerator PduMsg

Notify host about a received BLE PDU.

enumerator TriggeredMsg

Notify host about a triggered prepared sequence.

enumerator AccessAddressDiscoveredMsg

Notify host of a discovered access address.

enumerator AdvPduMsg

Notify host about a received advertising PDU.

enumerator SynchronizedMsg

Notify host of a connection sync.

enumerator DesynchronizedMsg

Notify host of a connection desync.

enumerator HijackedMsg

Notify host of an hijacking status update.

enumerator InjectedMsg

Notify host of an injection status update.

enum SequenceType

Values:

enumerator SequencePattern
enumerator SequenceManual
enumerator SequenceConnEvt
class BDAddress
#include <address.hpp>

Public Functions

BDAddress(void)

BD Address default constructor.

BDAddress(AddressType type, uint8_t *p_bdaddr)

BD Address constructor.

Parameters:
  • type[in] Address type

  • p_bdaddr[in] BD address byte buffer (6 bytes)

AddressType getType(void)

Get address type.

Return values:
  • AddressPublic – Address type is public

  • AddressRandom – Address type is random

uint8_t *getAddressBuf(void)

Get address buffer.

Returns:

Pointer to the BD address byte buffer (6 bytes)

void setType(AddressType type)

Set address type.

Parameters:

type[in] Address type to set

void setAddress(uint8_t *pBdAddress)

Set BD address.

Parameters:

pBdAddress[in] Pointer to a 6-byte BD address buffer

class AdvMode : public whad::ble::BleMsg
#include <adv.hpp>

Public Functions

AdvMode(BleMsg &message)

AdvMode message constructor, parse an existing message.

Parameters:

message[in] Message to parse.

AdvMode(uint8_t *pAdvData, unsigned int advDataLength, uint8_t *pScanRsp, unsigned int scanRspLength)

AdvMode message constructor.

Parameters:
  • pAdvData[in] Pointer to a byte buffer containing the device advertising data

  • advDataLength[in] Size in bytes of the advertising data

  • pScanRsp[in] Pointer to a byte buffer containing the device scan response data

  • scanRspLength[in] Size in bytes of the scan response data

unsigned int getAdvDataLength()

Get advertising data length.

Return values:

Length – of advertising data

unsigned int getScanRspLength()

Get scan response data length.

Return values:

Length – of scan response data

uint8_t *getAdvData()

Get pointer to the advertising data.

Return values:

Pointer – to the advertising data

uint8_t *getScanRsp()

Get pointer to the scan response data.

Return values:

Pointer – to the scan response data

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

Subclassed by whad::ble::AccessAddressDiscovered, whad::ble::AdvMode, whad::ble::AdvPdu, whad::ble::CentralMode, whad::ble::ConnectTo, whad::ble::Connected, whad::ble::DeleteSequence, whad::ble::Desynchronized, whad::ble::Disconnect, whad::ble::Disconnected, whad::ble::HijackBoth, whad::ble::HijackMaster, whad::ble::HijackSlave, whad::ble::Hijacked, whad::ble::Injected, whad::ble::JamActiveConn, whad::ble::JamAdv, whad::ble::LinkLayerPdu, whad::ble::ManualTrigger, whad::ble::PeripheralMode, whad::ble::PrepareSequenceConnEvt, whad::ble::PrepareSequenceManual, whad::ble::RawPdu, whad::ble::ReactiveJam, whad::ble::ScanMode, whad::ble::SendPdu, whad::ble::SendRawPdu, whad::ble::SequenceTriggered, whad::ble::SetAdvData, whad::ble::SetBdAddress, whad::ble::SetEncryption, whad::ble::SniffAccessAddress, whad::ble::SniffActiveConn, whad::ble::SniffAdv, whad::ble::SniffConnReq, whad::ble::Start, whad::ble::Stop, whad::ble::Synchronized, whad::ble::Triggered

Public Functions

BleMsg()

BLE message base class.

BleMsg(NanoPbMsg pMessage)

BLE message base class.

Parameters:

pMessage[in] NanoPbMsg object containing a ble domain message

~BleMsg()

BLE message base class destructor.

MessageType getType(void)

Identify the underlying discovery message.

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

Returns:

BLE message type.

class CentralMode : public whad::ble::BleMsg
#include <central.hpp>

Public Functions

CentralMode(BleMsg &message)

Parse a CentralMode message.

CentralMode(void)

CentralMode message constructor.

class ChannelMap
#include <channelmap.hpp>
class ConnEventTrigger
#include <conn_evt_trigger.hpp>

Public Functions

ConnEventTrigger(uint32_t connEvent)

Connection Event trigger constructor.

Parameters:

connEvent[in] Connection event at which a set of packets must be sent

uint32_t getConnEvent(void)

Get trigger connection event.

Returns:

Connection event

class ConnectTo : public whad::ble::BleMsg
#include <connect.hpp>

Public Functions

ConnectTo(BleMsg &message)

Parse a message as a ConnectTo message.

ConnectTo(BDAddress targetAddr, uint32_t accessAddress, ChannelMap channelMap, uint32_t hopInterval, uint32_t hopIncrement, uint32_t crcInit)

ConnectTo message constructor.

Parameters:
  • targetAddr[in] Target device BD address

  • accessAddress[in] Specify the access address to use for this connection, if supported by the adapter

  • channelMap[in] Specify the channel map to use for this connection, if supported by the adapter

  • hopInterval[in] Connection hop interval

  • hopIncrement[in] Connection hop increment

  • crcInit[in] CRC initial value (seed)

BDAddress &getTargetAddr()

Retrieve the target BD address.

Return values:

Target – BD Address

uint32_t getAccessAddr()

Retrieve the target Access Address.

Return values:

Target – Access Address

ChannelMap &getChannelMap()

Retrieve the channel map.

Return values:

Channel – Map

uint32_t getHopInterval()

Retrieve the hop interval.

Return values:

Hop – interval value

uint32_t getHopIncrement()

Retrieve the hop increment.

Return values:

Hop – increment value

uint32_t getCrcInit()

Retrieve the CRC seed.

Return values:

CRC – init value

class Connected : public whad::ble::BleMsg
#include <connected.hpp>

Public Functions

Connected(uint32_t connHandle, BDAddress advAddr, BDAddress initAddr)

Connection notification constructor.

Parameters:
  • connHandle[in] Connection handle assigned to this connection

  • advAddr[in] Advertiser BD address

  • initAddr[in] Initiator BD address

uint32_t getConnHandle()

Get connection handle.

Return values:

Connection – handle value

BDAddress &getAdvertiserAddr()

Get advertiser BD address.

Return values:

Advertiser – BD address.

BDAddress &getInitiatorAddr()

Get initiator BD address.

Return values:

Initiator – BD address.

class DeleteSequence : public whad::ble::BleMsg
#include <del_sequence.hpp>

Public Functions

DeleteSequence(uint32_t id)

Delete a prepared sequence.

Parameters:

id[in] Sequence ID

uint32_t getId()

Retrieve the sequence Id.

Return values:

Sequence – Id

class Disconnect : public whad::ble::BleMsg
#include <disconnect.hpp>

Public Functions

Disconnect(BleMsg &message)

Parse a BleMsg as a Disconnect message.

Disconnect(uint32_t connHandle)

Disconnect message constructor.

Parameters:

connHandle[in] Connection handle

class Disconnected : public whad::ble::BleMsg
#include <disconnected.hpp>

Public Functions

Disconnected(BleMsg &message)

Parse a BleMsg as a Disconnected message.

Parameters:

message[in] Message to parse

Disconnected(uint32_t conn_handle, uint32_t reason)

Disconnection notification constructor.

Parameters:
  • connHandle[in] Connection handle assigned to this connection

  • reason[in] Disconnection reason (see BLE specs.)

uint32_t getConnHandle()

Retrieve the connection handle.

Return values:

Connection – handle value

uint32_t getReasonCode()

Retrieve the reason code.

Return values:

Reason – code

class HijackBase
#include <hijack_base.hpp>

Subclassed by whad::ble::HijackBoth, whad::ble::HijackMaster, whad::ble::HijackSlave, whad::ble::Hijacked, whad::ble::JamActiveConn

Public Functions

HijackBase()

Default constructor.

HijackBase(uint32_t accessAddress)

Constructor, specifies the access address to use.

Parameters:

accessAddress[in] Access address to use

uint32_t getAccessAddress()

Retrieve the access address.

Return values:

Access – Address value

class HijackBoth : public whad::ble::BleMsg, public whad::ble::HijackBase
#include <hijack_both.hpp>

Public Functions

HijackBoth(BleMsg &message)

Parse a BleMsg message as a HijackBoth message.

HijackBoth(uint32_t accessAddress)

HijackBoth message constructor.

Parameters:

accessAddress[in] Target connection access address

class HijackMaster : public whad::ble::BleMsg, public whad::ble::HijackBase
#include <hijack_master.hpp>

Public Functions

HijackMaster(BleMsg &message)

Parse a BleMsg as a HijackMaster message.

Parameters:

message[in] Message to parse

HijackMaster(uint32_t accessAddress)

HijackMaster message constructor.

Parameters:

accessAddress[in] Target connection access address

class HijackSlave : public whad::ble::BleMsg, public whad::ble::HijackBase
#include <hijack_slave.hpp>

Public Functions

HijackSlave(BleMsg &message)

Parse a BleMsg as a HijackSlave message.

Parameters:

message[in] Message to parse

HijackSlave(uint32_t accessAddress)

HijackSlave message constructor.

Parameters:

accessAddress[in] Target connection access address

class Hijacked : public whad::ble::BleMsg, public whad::ble::HijackBase
#include <hijacked.hpp>

Public Functions

Hijacked(BleMsg &message)

Parse a BleMsg as an Hijacked message.

Parameters:

message[in] Message to parse

Hijacked(uint32_t accessAddress, bool success)

Notify a successful/unsuccessful connection hijacking.

Parameters:
  • accessAddress[in] Connection access address

  • success[in] If true hijacking was successful, unsuccessful otherwise

class Injected : public whad::ble::BleMsg
#include <injected.hpp>

Public Functions

Injected(uint32_t accessAddress, uint32_t attempts, bool success)

Notify a successful/unsuccessful PDU injection.

Parameters:
  • accessAddress[in] Connection access address

  • attempts[in] Number of attempts

  • success[in] If true injection was successful, unsuccessful otherwise

uint32_t getAccessAddress()

Retrieve the access address.

Return values:

Access – address

uint32_t getAttempts()

Retrieve the number of attempts.

Return values:

Number – of attempts

bool isSuccessful()

Determine if the injection attack has been successful.

Return values:

True – if sucessful, false otherwise

class JamActiveConn : public whad::ble::BleMsg, public whad::ble::HijackBase
#include <jam_act_conn.hpp>

Public Functions

JamActiveConn(BleMsg &message)

Parse a BleMsg as JamActiveConn message.

JamActiveConn(uint32_t accessAddress)

JamActiveConn message constructor.

Parameters:

accessAddress[in] Connection access address

class JamAdv : public whad::ble::BleMsg
#include <jam_adv.hpp>

Public Functions

JamAdv(BleMsg &message)

JamAdv message constructor.

JamAdv()

Default advertisement jamming message.

JamAdv(uint32_t channel)

JamAdv message constructor.

Parameters:

channel[in] Channel to jam.

bool hasChannel()

Determine if message has a channel specified.

Return values:

True – if channel has been specified, false otherwise.

uint32_t getChannel()

Retrieve the channel set in the message.

Return values:

Channel – number

class ReactiveJam : public whad::ble::BleMsg
#include <jam_reactive.hpp>

Public Functions

ReactiveJam(BleMsg &message)

Parse a BleMsg into a ReactiveJam message.

ReactiveJam(uint32_t channel, uint8_t *pPattern, unsigned int length, uint32_t position)

ReactiveJam message constructor.

Parameters:
  • channel[in] Channel to listen on

  • pPattern[in] Byte buffer containing the byte pattern to match

  • length[in] Pattern length in bytes

  • position[in] Start position for pattern search

uint32_t getChannel()

Retrieve the channel number.

Return values:

Channel – number

uint8_t *getPattern()

Retrieve a pointer to the pattern.

Return values:

Pointer – to the pattern

unsigned int getPatternLength()

Retrieve the pattern length.

Return values:

Pattern – length

uint32_t getPosition()

Retrieve the pattern position.

Return values:

Pattern – position (offset) in bytes

class LinkLayerPdu : public whad::ble::BleMsg
#include <ll_pdu.hpp>

Public Functions

LinkLayerPdu(uint32_t conn_handle, PDU pdu, Direction direction, bool processed, bool decrypted)

Create a LinkLayerPdu object from a BLE PDU.

Parameters:
  • conn_handle[in] Connection handle

  • pdu[in] BLE PDU

  • direction[in] Direction of the PDU (host to slave, slave to host, …)

  • processed[in] Set to true if this PDU has already been processed

  • decrypted[in] Set to true if PDU has been decrypted

uint32_t getConnHandle()

Get the connection handle.

Return values:

Connection – handle value

PDU &getPdu()

Get the PDU.

Return values:

Reference – to the received PDU

Direction getDirection()

Get the PDU direction.

Return values:

Direction

bool isProcessed()

Determine if this PDU has already been processed or not by the firmware.

Return values:
  • True – PDU has been processed

  • False – PDU has not been processed

bool isDecrypted()

Determine if the PDU has been decrypted by the firmware.

Return values:
  • True – PDU has been decrypted on-the-fly by the adapter firmware

  • False – PDU has not been decrypted

class ManualTrigger : public whad::ble::BleMsg
#include <manual_trigger.hpp>

Public Functions

ManualTrigger(BleMsg &message)

Parse a BleMsg as a ManualTrigger message.

ManualTrigger(uint32_t id)

Manually triggers a packet sequence.

Parameters:

id[in] Sequence ID

uint32_t getId()

Get the trigger ID.

Return values:

Trigger – ID

class PatternTrigger
#include <pattern_trigger.hpp>

Public Functions

PatternTrigger(uint8_t *pPattern, uint8_t *pMask, int length, uint32_t offset)

PatternTrigger constructor.

Parameters:
  • pPattern[in] Byte buffer containing the byte pattern to match

  • pMask[in] Byte buffer containing a bitmask to apply with the pattern

  • length[in] Pattern and mask size in bytes

  • offset[in] Offset at which the pattern must be applied

int getLength(void)

Get pattern and mask length.

Returns:

Pattern and mask length in bytes

uint8_t *getPattern(void)

Get trigger pattern.

Returns:

Pointer to the trigger’s pattern byte buffer

uint8_t *getMask(void)

Get trigger mask.

Returns:

Pointer to the trigger’s mask byte buffer

uint32_t getOffset(void)

Get trigger pattern offset.

Returns:

Pattern offset

class PeripheralMode : public whad::ble::BleMsg
#include <peripheral.hpp>

Public Functions

PeripheralMode(BleMsg &message)

Parse a BleMsg as a PeripheralMode message.

Parameters:

message[in] Message to parse

PeripheralMode(uint8_t *pAdvData, unsigned int advDataLength, uint8_t *pScanRsp, unsigned int scanRspLength)

Create a PeripheralMode message.

Parameters:
  • pAdvData[in] Pointer to a buffer containing the advertising data

  • advDataLength[in] Size of the advertising data in bytes

  • pScanRsp[in] Pointer to a buffer containing the scan response data

  • scanRspLength[in] Size of the scan response data in bytes

uint8_t *getAdvData()

Get the advertising data.

Return values:

Pointer – to the advertising data buffer

unsigned int getAdvDataLength()

Get the size of advertising data.

Return values:

Size – of advertising data in bytes

uint8_t *getScanRsp()

Get the scan response data.

Return values:

Pointer – to the scan response data buffer

unsigned int getScanRspLength()

Get the size of scan response data.

Return values:

Size – of scan response data in bytes

class PrepareSequence
#include <prep_sequence.hpp>

PrepareSequence base class.

This class provides the basic features to store a sequence ID, direction and a list of PDUs.

Subclassed by whad::ble::PrepareSequenceConnEvt, whad::ble::PrepareSequenceManual

Public Functions

PrepareSequence()

Default constructor.

PrepareSequence(uint32_t id, Direction direction, std::vector<PDU> packets)

Create a prepared sequence.

Parameters:
  • id[in] Sequence ID

  • direction[in] Packet(s) direction

  • packets[in] List of packets

uint32_t getId()

Get the sequence ID.

Return values:

Sequence – ID

Direction getDirection()

Get packets direction.

Return values:

Packets – direction

std::vector<PDU> &getPackets()

Get packet list.

Return values:

Reference – to packet list

Public Static Functions

static SequenceType getType(BleMsg &message)

Determine the type of trigger for this sequence.

Return values:

Type – of trigger

class PrepareSequenceManual : public whad::ble::BleMsg, public whad::ble::PrepareSequence
#include <prep_sequence.hpp>

PrepareSequence with manual trigger

Public Functions

PrepareSequenceManual(BleMsg &message)

Parse a BleMsg as a PrepareSequenceManual object.

Parameters:

message[in] Message to parse

PrepareSequenceManual(uint32_t id, Direction direction, std::vector<PDU> packets)

Create a PrepareSequenceManual message.

Parameters:
  • id[in] Sequence ID

  • direction[in] Packets direction

  • packets[in] List of packets to send when a manual trigger is issued

class PrepareSequenceConnEvt : public whad::ble::BleMsg, public whad::ble::PrepareSequence
#include <prep_sequence.hpp>

PrepareSequence with a connection event based trigger.

Public Functions

PrepareSequenceConnEvt(BleMsg &message)

Parse a BleMsg as a PrepareSequenceConnEvt message.

Parameters:

message[in] Message to parse

PrepareSequenceConnEvt(uint32_t id, Direction direction, std::vector<PDU> packets, uint32_t connEvt)

Create a PrepareSequenceConnEvt message.

Parameters:
  • id[in] Sequence ID

  • direction[in] Packets direction

  • packets[in] List of packets to send when a manual trigger is issued

  • connEvt[in] Connection Event at which these packets must be sent

uint32_t getConnEvt()

Get the connection event value.

Return values:

Connection – event value

class RawPdu : public whad::ble::BleMsg
#include <rawpdu.hpp>

Public Functions

RawPdu(uint32_t channel, int32_t rssi, uint32_t conn_handle, uint32_t access_address, PDU pdu, uint32_t crc, bool crc_validity, uint32_t timestamp, uint32_t relative_timestamp, Direction direction, bool processed, bool decrypted)

Raw PDU constructor, including timestamp.

Parameters:
  • channel[in] Channel on which this PDU has been received

  • rssi[in] Received Signal Strength Indicator

  • conn_handle[in] Connection handle

  • access_address[in] Access Address of the connection

  • pdu[in] PDU received

  • crc[in] PDU CRC value

  • crc_validity[in] Set to true if CRC matches the expected value, false otherwise

  • timestamp[in] PDU timestamp (in micro-seconds)

  • relative_timestamp[in] PDU relative timestamp (number of micro-seconds in the last connection event)

  • direction[in] Direction of the PDU (master -> slave / slave -> master)

  • processed[in] Set to true if PDU has been processed by the device, false otherwise

  • decrypted[in] Set to true if PDU has been decrypted, false otherwise

RawPdu(uint32_t channel, int32_t rssi, uint32_t conn_handle, uint32_t access_address, PDU pdu, uint32_t crc, bool crc_validity, Direction direction, bool processed, bool decrypted)

Raw PDU constructor, no timestamp.

Parameters:
  • channel[in] Channel on which this PDU has been received

  • rssi[in] Received Signal Strength Indicator

  • conn_handle[in] Connection handle

  • access_address[in] Access Address of the connection

  • pdu[in] Received PDU

  • crc[in] PDU CRC value

  • crc_validity[in] Set to true if CRC matches the expected value, false otherwise

  • direction[in] Direction of the PDU (master -> slave / slave -> master)

  • processed[in] Set to true if PDU has been processed by the device, false otherwise

  • decrypted[in] Set to true if PDU has been decrypted, false otherwise

class ScanMode : public whad::ble::BleMsg
#include <scan.hpp>

Public Functions

ScanMode(BleMsg &message)

Parse a BleMsg as a ScanMode message.

ScanMode(bool active)

ScanMode message constructor.

Parameters:

active[in] If set to true, adapter will perform an active scan

bool isActiveModeEnabled()

Determine if an active scan is requested or not.

Return values:

True – if active scan is requested, False otherwise.

class AdvPdu : public whad::ble::BleMsg
#include <scan.hpp>

Public Functions

AdvPdu(BleMsg &message)

Parse a BleMsg as an AdvPdu message.

Parameters:

message[in] Message to parse

AdvPdu(AdvType advType, int32_t rssi, BDAddress address, uint8_t *pAdvData, unsigned int advDataLength)

Notify an advertising PDU.

Parameters:
  • advType[in] Advertisement type

  • rssi[in] Received signal strength indicator

  • address[in] Advertiser BD address

  • pAdvData[in] Pointer to the advertising data byte buffer

  • advDataLength[in] Advertising data length in bytes

class SendPdu : public whad::ble::BleMsg
#include <send_pdu.hpp>

Public Functions

SendPdu(BleMsg &message)

Parse a BleMsg as a SendPdu message.

Parameters:

message[in] Message to parse

SendPdu(Direction direction, uint32_t connHandle, uint8_t *pPdu, int length, bool encrypt)

SendPdu message constructor.

Parameters:
  • direction[in] PDU direction

  • connHandle[in] Connection handle in which the PDU is to be sent

  • pPdu[in] Pointer to a byte buffer containing the PDU

  • length[in] PDU size in bytes (cannot exceed 250 bytes)

  • encrypt[in] If set to true and encryption enabled, adapter will encrypt the PDU

Direction getDirection()

Get PDU direction.

Return values:

PDU – direction

uint32_t getConnHandle()

Get connection handle.

Return values:

Connection – handle value

PDU &getPdu()

Get PDU.

Return values:

Reference – of the PDU to send.

bool isEncrypted()

Determine if PDU has to be encrypted.

Return values:

True – if encryption is required, false otherwise.

class SendRawPdu : public whad::ble::BleMsg
#include <send_raw_pdu.hpp>

Public Functions

SendRawPdu(BleMsg &message)

Parse a BleMsg as a SendRawPdu.

Parameters:

message[in] Message to parse

SendRawPdu(Direction direction, uint32_t connHandle, uint32_t accessAddress, uint8_t *pPdu, int length, uint32_t crc, bool encrypt)

SendRawPdu message constructor.

Parameters:
  • direction[in] PDU direction

  • connHandle[in] Connection handle in which the PDU is to be sent

  • accessAddress[in] Connection access address

  • pPdu[in] Pointer to a byte buffer containing the PDU

  • length[in] PDU size in bytes (cannot exceed 250 bytes)

  • crc[in] PDU CRC value

  • encrypt[in] If set to true and encryption enabled, adapter will encrypt the PDU

Direction getDirection()

Get PDU direction.

Returns:

PDU direction (see enum Direction)

uint32_t getConnHandle()

Retrieve the associated connection handle.

Returns:

Connection handle

uint32_t getAccessAddress()

Retrieve the PDU access address.

Returns:

Access address

uint32_t getCrc()

Retrieve the PDU CRC.

Returns:

CRC value for the PDU

bool isEncrypted()

Determine if the PDU is encrypted.

Return values:
  • True – PDU must be sent encrypted

  • False – PDU must not be sent encrypted

class SequenceTriggered : public whad::ble::BleMsg
#include <sequence_trig.hpp>

Public Functions

SequenceTriggered(BleMsg &message)

Parse a BleMsg as a SequenceTriggered message.

Parameters:

message[in] Message to parse

SequenceTriggered(uint32_t id)

Prepared sequence has been triggered.

Parameters:

id[in] Sequence ID

class SetEncryption : public whad::ble::BleMsg
#include <set_encryption.hpp>

Public Functions

SetEncryption(uint32_t connHandle, uint8_t pLLKey[16], uint8_t llIv[8], uint8_t key[16], uint8_t rand[8], uint8_t eDiv[2], bool enabled)

SetEncryption message constructor.

Parameters:
  • connHandle[in] Connection handle

  • llKey[in] Link-layer encryption key (16 bytes)

  • llIv[in] Link-layer encryption initialization vector (8 bytes)

  • key[in] Encryption key

  • rand[in] Random buffer used in link-layer key derivation

  • eDiv[in] Diversifier used in link-layer key derivation

  • enabled[in] If set to true, enable encryption

uint32_t getConnHandle()

Get connection handle.

Returns:

Connection handle value.

uint8_t *getLLKey()

Get the link-layer 16-byte encryption key buffer.

Returns:

Pointer to the link-layer encryption key buffer.

uint8_t *getLLIv()

Get the link-layer 8-byte IV buffer.

Returns:

Pointer to the link-layer encryption IV buffer.

uint8_t *getKey()

Get the key 16-byte buffer.

Returns:

Pointer to the key buffer.

uint8_t *getRand()

Get the key 8-byte Rand buffer.

Returns:

Pointer to the Rand buffer.

uint8_t *getEDiv()

Get the encryption diversifier.

Returns:

Pointer to the encryption diversifier buffer.

bool isEnabled()

Determine if encryption must be enabled or not.

Returns:

True if encryption must be enabled, false otherwise.

class SetAdvData : public whad::ble::BleMsg
#include <setadvdata.hpp>

Public Functions

SetAdvData(uint8_t *pAdvData, unsigned int advDataLength, uint8_t *pScanRsp, unsigned int scanRspLengthv)

SetAdvData message constructor.

Parameters:
  • pAdvData[in] Pointer to a byte buffer containing the device advertising data

  • advDataLength[in] Size in bytes of the advertising data

  • pScanRsp[in] Pointer to a byte buffer containing the device scan response data

  • scanRspLength[in] Size in bytes of the scan response data

class SetBdAddress : public whad::ble::BleMsg
#include <setbdaddr.hpp>

Public Functions

SetBdAddress(NanoPbMsg message)

parse a BD address message constructor.

Parameters:

message[in] Base NanoPb message to use.

SetBdAddress(BDAddress address)

Set adapter BD address message constructor.

Parameters:

address[in] BD address to use

BDAddress *getAddress()

Retrieve the BD address.

Returns:

An instance of BDAddress on success, NULL otherwise.

class SniffAccessAddress : public whad::ble::BleMsg
#include <sniff_aa.hpp>

Public Functions

SniffAccessAddress(BleMsg &message)

Parse a BleMsg as a SniffAccessAddress message.

Parameters:

message[in] Message to parse

SniffAccessAddress(ChannelMap channelMap)

SnifAccessAddress message constructor.

Parameters:

channelMap[in] Channel map specifying the channels to use for access adress sniffing

ChannelMap &getChannelMap()

Get channel map.

Return values:

Channel – map reference

class AccessAddressDiscovered : public whad::ble::BleMsg
#include <sniff_aa.hpp>

Public Functions

AccessAddressDiscovered(BleMsg &message)

Parse a BleMsg as an AccessAddressDiscovered message.

Parameters:

message[in] Message to parse

AccessAddressDiscovered(uint32_t accessAddress)

Notify the discovery of an access address.

Parameters:

accessAddress[in] Discovered access address

AccessAddressDiscovered(uint32_t accessAddress, uint32_t timestamp)

Notify the discovery of an access address including timestamp.

Parameters:
  • accessAddress[in] Discovered access address

  • timestamp[in] Timestamp

AccessAddressDiscovered(uint32_t accessAddress, int32_t rssi)

Notify the discovery of an access address including RSSI.

Parameters:
  • accessAddress[in] Discovered access address

  • rssi[in] Received Signal Strength Indicator

AccessAddressDiscovered(uint32_t accessAddress, uint32_t timestamp, int32_t rssi)

Notify the discovery of an access address including timestamp and RSSI.

Parameters:
  • accessAddress[in] Discovered access address

  • timestamp[in] Timestamp

  • rssi[in] Received Signal Strength Indicator

uint32_t getAccessAddress()

Get the access address.

Return values:

Access – Address

bool hasTimestamp()

Determine if a timestamp is available.

Return values:
  • true – The timestamp is available

  • false – The timestamp is not available (default to 0)

uint32_t getTimestamp()

Get the Timestamp value.

Return values:

Timestamp – in milliseconds

bool hasRssi()

Determine if an RSSI is available.

Return values:
  • true – The RSSI is available

  • false – The RSSI is not available (default to 0)

int32_t getRssi()

Get the RSSI value.

Return values:

RSSI – value

class SniffActiveConn : public whad::ble::BleMsg
#include <sniff_act_conn.hpp>

Public Functions

SniffActiveConn(BleMsg &message)

Parse a BleMsg as a SniffActiveConn message.

Parameters:

message[in] Message to parse

SniffActiveConn(uint32_t accessAddress, uint32_t crcInit, uint32_t hopInterval, uint32_t hopIncrement, ChannelMap channelMap, ChannelMap channels)

SniffActiveConn message constructor.

Parameters:
  • accessAddress[in] Connection access address

  • crcInit[in] Connection CRC init value (seed)

  • hopInterval[in] Hop interval

  • hopIncrement[in] Hop increment

  • channelMap[in] Connection channel map

  • channels[in] Channel map specifying the channels to use when recovering the channel map (if multiple sniffers are used &#8212; collaborative channel map recovery).

uint32_t getAccessAddress()

Get the access address.

Return values:

Access – Address

uint32_t getCrcInit()

Get the CRC initial value.

Return values:

CRC – initial value

uint32_t getHopInterval()

Get the connection hop interval.

Return values:

Hop – interval value

uint32_t getHopIncrement()

Get the connection hop increment.

Return values:

Hop – increment value

ChannelMap &getChannelMap()

Get the connection channel map.

Return values:

Channel – map

ChannelMap &getChannels()

Get the connection channels.

Return values:

Channels

class SniffAdv : public whad::ble::BleMsg
#include <sniff_adv.hpp>

Public Functions

SniffAdv(BleMsg &message)

Parse a BleMsg as a SniffAdv message.

Parameters:

message[in] Message to parse

SniffAdv(uint32_t channel, BDAddress targetAddr, bool useExtAdv)

SniffAdv message constructor.

Parameters:
  • channel[in] Channel to use for sniffing

  • targetAddr[in] Target device BD address

  • useExtAdv[in] If set to true, use extended advertising (BLE 5.x)

uint32_t getChannel()

Get advertising channel.

Returns:

Advertising channel number.

BDAddress getAddress()

Get the target BD address.

Returns:

BD address of the target device to sniff.

bool mustUseExtAdv()

Determine if we must use extended advertisements.

Returns:

True if extended advertisements must be used, false otherwise.

class SniffConnReq : public whad::ble::BleMsg
#include <sniff_connreq.hpp>

Public Functions

SniffConnReq(BleMsg &message)

Parse a BleMsg as a SniffConnReq message.

Parameters:

message[in] Message to parse

SniffConnReq(uint32_t channel, BDAddress targetAddr, bool showAdv, bool showEmpty)

SnifConnReq message constructor.

Parameters:
  • channel[in] Channel to sniff for connection request

  • targetAddr[in] Target device BD address

  • showAdv[in] If set to true, adapter will report every advertisement received

  • showEmpty[in] If set to true, adapter will report empty PDUs

uint32_t getChannel()

Get channel.

Return values:

Channel – number

BDAddress &getTargetAddress()

Get target BD address.

Return values:

Target – BD address

bool mustReportAdv()

Determine if advertisements must be reported while sniffing for a connection request.

Return values:

True – if advertisements must be reported, false otherwise

bool mustReportEmpty()

Determine if empty PDUs must be reported.

Return values:

True – if empty PDUs must be reported, false otherwise.

class Start : public whad::ble::BleMsg
#include <start.hpp>

Public Functions

Start(BleMsg &message)

Parse a BleMsg as a Start message.

Parameters:

message[in] Message to parse

Start(void)

Start message constructor.

class Stop : public whad::ble::BleMsg
#include <stop.hpp>

Public Functions

Stop(BleMsg &message)

Parse a BleMsg as a Stop message.

Parameters:

message[in] Message to parse

Stop(void)

Stop message constructor.

class Synchronized : public whad::ble::BleMsg
#include <synchro.hpp>

Public Functions

Synchronized(BleMsg &message)

Parse a BleMsg as a Synchronized message.

Parameters:

message[in] Message to parse

Synchronized(uint32_t accessAddress, uint32_t crcInit, uint32_t hopInterval, uint32_t hopIncrement, ChannelMap channelMap)

Notify a successful connection synchronization.

Parameters:
  • accessAddress[in] Connection access address

  • crcInit[in] Recovered CRC initial value (seed)

  • hopInterval[in] Recovered hop interval

  • hopIncrement[in] Recovered hop increment

  • channelMap[in] Recovered channel map

uint32_t getAccessAddress()

Get the access address.

Return values:

Access – Address

uint32_t getCrcInit()

Get the CRC initial value.

Return values:

CRC – initial value

uint32_t getHopInterval()

Get the connection hop interval.

Return values:

Hop – interval value

uint32_t getHopIncrement()

Get the connection hop increment.

Return values:

Hop – increment value

ChannelMap &getChannelMap()

Get the connection channel map.

Return values:

Channel – map

class Desynchronized : public whad::ble::BleMsg
#include <synchro.hpp>

Public Functions

Desynchronized(BleMsg &message)

Parse a BleMsg as a Desynchronized message.

Parameters:

message[in] Message to parse

Desynchronized(uint32_t accessAddress)

Notify a connection desynchronization.

Parameters:

accessAddress[in] Connection access address

uint32_t getAccessAddress()

Get the access address.

Return values:

Access – Address

class Triggered : public whad::ble::BleMsg
#include <triggered.hpp>

Public Functions

Triggered(uint8_t id)

Connection notification constructor.

Parameters:

id[in] Prepared sequence id that has been triggered

uint8_t getId()

Get sequence ID.

Return values:

Prepared – sequence ID.