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
-
Enums
-
enum AddressType
Bluetooth Device address type.
Values:
-
enumerator AddressRandom
Device address is random.
-
enumerator AddressPublic
Device address is public.
-
enumerator AddressRandom
-
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.
-
enumerator AdvUnknown
-
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.
-
enumerator DirectionUnknown
-
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 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.
-
enumerator UnknownMsg
-
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
-
BDAddress(void)
-
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
-
AdvMode(BleMsg &message)
-
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.
-
BleMsg()
-
class CentralMode : public whad::ble::BleMsg
- #include <central.hpp>
Public Functions
-
CentralMode(BleMsg &message)
Parse a CentralMode message.
-
CentralMode(void)
CentralMode message constructor.
-
CentralMode(BleMsg &message)
-
class ChannelMap
- #include <channelmap.hpp>
-
class ConnEventTrigger
- #include <conn_evt_trigger.hpp>
-
class ConnectTo : public whad::ble::BleMsg
- #include <connect.hpp>
Public Functions
-
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)
-
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
-
ConnectTo(BDAddress targetAddr, uint32_t accessAddress, ChannelMap channelMap, uint32_t hopInterval, uint32_t hopIncrement, uint32_t crcInit)
-
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
-
Connected(uint32_t connHandle, BDAddress advAddr, BDAddress initAddr)
-
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
-
Disconnect(BleMsg &message)
-
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
-
Disconnected(BleMsg &message)
-
class HijackBase
- #include <hijack_base.hpp>
Subclassed by whad::ble::HijackBoth, whad::ble::HijackMaster, whad::ble::HijackSlave, whad::ble::Hijacked, whad::ble::JamActiveConn
-
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
-
HijackBoth(BleMsg &message)
-
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
-
HijackMaster(BleMsg &message)
-
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
-
HijackSlave(BleMsg &message)
-
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
-
Hijacked(BleMsg &message)
-
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
-
Injected(uint32_t accessAddress, uint32_t attempts, bool success)
-
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
-
JamActiveConn(BleMsg &message)
-
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
-
ReactiveJam(BleMsg &message)
-
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
trueif this PDU has already been processeddecrypted – [in] Set to
trueif PDU has been decrypted
-
uint32_t getConnHandle()
Get the connection handle.
- Return values:
Connection – handle value
-
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
-
LinkLayerPdu(uint32_t conn_handle, PDU pdu, Direction direction, bool processed, bool decrypted)
-
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
-
PatternTrigger(uint8_t *pPattern, uint8_t *pMask, int length, uint32_t 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
-
PeripheralMode(BleMsg &message)
-
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
Public Static Functions
-
static SequenceType getType(BleMsg &message)
Determine the type of trigger for this sequence.
- Return values:
Type – of trigger
-
PrepareSequence()
-
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
-
PrepareSequenceManual(BleMsg &message)
-
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
-
PrepareSequenceConnEvt(BleMsg &message)
-
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
-
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)
-
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
-
AdvPdu(BleMsg &message)
-
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
-
uint32_t getConnHandle()
Get connection handle.
- Return values:
Connection – handle value
-
bool isEncrypted()
Determine if PDU has to be encrypted.
- Return values:
True – if encryption is required, false otherwise.
-
SendPdu(BleMsg &message)
-
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
-
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
-
SendRawPdu(BleMsg &message)
-
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
-
SequenceTriggered(BleMsg &message)
-
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.
-
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)
-
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
-
SetAdvData(uint8_t *pAdvData, unsigned int advDataLength, uint8_t *pScanRsp, unsigned int scanRspLengthv)
-
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
-
SniffAccessAddress(BleMsg &message)
-
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
-
AccessAddressDiscovered(BleMsg &message)
-
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 — 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 –
-
SniffActiveConn(BleMsg &message)
-
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.
-
SniffAdv(BleMsg &message)
-
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
-
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.
-
SniffConnReq(BleMsg &message)
-
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
-
Synchronized(BleMsg &message)
-
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
-
Desynchronized(BleMsg &message)
-
enum AddressType