Logitech Unifying

Parsing Logitech Unifying messages

When processing Logitech Unifying messages sent to a compatible interface, the whad::unifying::UnifyingMsg::getType() function returns the corresponding message type (whad::unifying::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 Logitech Unifying packet sniffing. The supported commands must also be indicated in the interface’s capabilities as described in cpp__cap`.

void process_unifying_message(Message *p_message)
{
    NanoPbMsg *response = NULL;

    /* Wrap our NanoPbMsg into a UnifyingMsg. */
    whad::unifying::UnifyingMsg uni_msg(message);

    switch (uni_msg.getType())
    {
        case whad::unifying::MessageType::SniffModeMsg:
        {
            /* Configure our interface in sniffing mode ... (custom code) */
            /* ... */

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

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

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

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

Logitech Unifying API reference

namespace unifying

Typedefs

typedef whad::Packet<255> PDU

Logitech Unifying PDU class.

typedef DeviceAddress<1, 5> UnifyingAddress

Logitech Unifying device address.

Enums

enum MessageType

Unifying message types.

Values:

enumerator UnknownMsg

Unknown message.

enumerator SetNodeAddressMsg

Set node address.

enumerator SniffModeMsg

Set interface in sniffing mode.

enumerator JamModeMsg

Set interface in jamming mode.

enumerator SendMsg

Send PDU.

enumerator SendRawMsg

Send raw PDU.

enumerator DongleModeMsg

Set interface in dongle mode.

enumerator KeyboardModeMsg

Set interface in keyboard mode.

enumerator MouseModeMsg

Set interface in mouse mode.

enumerator StartMsg

Start current mode.

enumerator StopMsg

Stop current mode.

enumerator SniffPairingMsg

Set interface in pairing sniffing mode.

enumerator JammedMsg

Jamming result notification.

enumerator RawPduReceivedMsg

Raw PDU received notification.

enumerator PduReceivedMsg

PDU received notification.

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

Subclassed by whad::unifying::DongleMode, whad::unifying::JamMode, whad::unifying::Jammed, whad::unifying::KeyboardMode, whad::unifying::MouseMode, whad::unifying::PduReceived, whad::unifying::RawPduReceived, whad::unifying::SendPdu, whad::unifying::SendRawPdu, whad::unifying::SetNodeAddress, whad::unifying::SniffMode

Public Functions

UnifyingMsg()

Unifying message base class.

UnifyingMsg(NanoPbMsg pMessage)

Unifying message base class.

Parameters:

pMessage[in] NanoPbMsg object containing a ble domain message

~UnifyingMsg()

Unifying message base class destructor.

MessageType getType(void)

Identify the underlying unifying message.

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

Returns:

Unifying message type.

class DongleMode : public whad::unifying::UnifyingMsg
#include <dongle.hpp>

Public Functions

DongleMode(UnifyingMsg &message)

Parse a message as a DongleMode message.

DongleMode(uint32_t channel)

DongleMode message constructor.

Parameters:

channel[in] Channel to use

uint32_t getChannel()

Retrieve the channel to jam.

Return values:

Channel – number

class JamMode : public whad::unifying::UnifyingMsg
#include <jam.hpp>

Public Functions

JamMode(UnifyingMsg &message)

Parse a message as a JamMode message.

JamMode(uint32_t channel)

JamMode message constructor.

Parameters:

channel[in] Channel to use

uint32_t getChannel()

Retrieve the channel to jam.

Return values:

Channel – number

class Jammed : public whad::unifying::UnifyingMsg
#include <jammed.hpp>

Public Functions

Jammed(UnifyingMsg &message)

Parse a message as a Jammed message.

Jammed(uint32_t timestamp)

Jammed message constructor.

Parameters:

timestamp[in] Timestamp at which the jamming has been detected

uint32_t getTimestamp()

Retrieve the timestamp.

Return values:

Timestamp – in seconds

class KeyboardMode : public whad::unifying::UnifyingMsg
#include <keyboard.hpp>

Public Functions

KeyboardMode(UnifyingMsg &message)

Parse a message as a KeyboardMode message.

KeyboardMode(uint32_t channel)

KeyboardMode message constructor.

Parameters:

channel[in] Channel to use

uint32_t getChannel()

Retrieve the channel to jam.

Return values:

Channel – number

class MouseMode : public whad::unifying::UnifyingMsg
#include <mouse.hpp>

Public Functions

MouseMode(UnifyingMsg &message)

Parse a message as a MouseMode message.

MouseMode(uint32_t channel)

MouseMode message constructor.

Parameters:

channel[in] Channel to use

uint32_t getChannel()

Retrieve the channel to jam.

Return values:

Channel – number

class UnifyingPacket
#include <packet.hpp>

Public Functions

UnifyingPacket(uint32_t channel, uint8_t *pPdu, int length, uint32_t crc)

Create a UnifyingPacket object with the given channel, PDU and FCS values.

Parameters:
  • channel[in] ZigBee channel on which the PDU has been received

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

  • length[in] PDU length in bytes

  • crc[in] Frame Check Sequence value

UnifyingPacket(uint32_t channel, uint8_t *pPdu, int length, uint32_t crc, int32_t rssi)

Create a UnifyingPacket object with the given channel, PDU and FCS values.

Parameters:
  • channel[in] ZigBee channel on which the PDU has been received

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

  • length[in] PDU length in bytes

  • crc[in] Frame Check Sequence value

  • rssi[in] Received Signal Strength Indicator value (in dBm)

UnifyingPacket(uint32_t channel, uint8_t *pPdu, int length, uint32_t crc, int32_t rssi, uint32_t timestamp)

Create a UnifyingPacket object with the given channel, PDU and FCS values.

Parameters:
  • channel[in] ZigBee channel on which the PDU has been received

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

  • length[in] PDU length in bytes

  • crc[in] Frame Check Sequence value

  • rssi[in] Received Signal Strength Indicator value (in dBm)

  • timestamp[in] Timestamp (in seconds) at which the PDU has been received

void setChannel(uint32_t channel)

Set zigbee packet channel value.

Parameters:

channel[in] Zigbee channel this packet has been received on

void setPdu(PDU &pdu)

Set zigbee packet PDU.

Parameters:

pdu[in] packet PDU

void setCrc(uint32_t crc)

Set zigbee packet channel FCS value.

Parameters:

crc[in] Frame Check Sequence value for this packet

void addRssi(int32_t rssi)

Add RSSI to the received PDU.

Parameters:

rssi[in] Received Signal Strength Indicator in dBm

void addTimestamp(uint32_t timestamp)

Add Timestamp to the received PDU.

Parameters:

timestamp[in] Timestamp in seconds

void addCrcValidity(bool valid)

Add FCS validity to the received PDU.

Parameters:

valid[in] FCS validity

uint32_t getChannel()

Retrieve the channel on which the PDU has been received.

Return values:

Channel – number

PDU &getPdu()

Retrieve the received PDU.

Return values:

Received – PDU

uint32_t getCrc()

Retrieve the Frame Check Sequence value.

Return values:
  • FCS – value

  • 0 – if not available

bool hasRssi()

Determine if the PDU has RSSI information available.

Returns:

True if RSSI is available, false otherwise

int32_t getRssi()

Retrieve the PDU RSSI value.

Return values:

RSSI – value

bool hasCrcValidity()

Determine if the PDU has FCS validity information available.

Return values:

FCS – validity presence

bool isCrcValid()

Determine if the PDU FCS value is valid.

Return values:

FCS – validity

bool hasTimestamp()

Determine if the packet timestamp is available.

Return values:

True – if available, false otherwise.

uint32_t getTimestamp()

Retrieve the timestamp value.

Return values:

Timestamp – value

class PduReceived : public whad::unifying::UnifyingMsg
#include <pdu.hpp>

Public Functions

PduReceived(UnifyingMsg &message)

Parse a message as a PduReceived message.

PduReceived(UnifyingPacket &packet)

PduReceived message constructor.

Parameters:

packet[in] Unifying packet received

void addAddress(UnifyingAddress &address)

Set optional address field.

Parameters:

address[in] Unifying node address

UnifyingPacket &getPacket()

Retrieve the received packet and its metadata.

Return values:

Reference – to a UnifyingPacket

bool hasAddress()

Determine if the address field has been set.

Return values:

True – if set, false otherwise

UnifyingAddress &getAddress()

Retrieve the retry counter.

Return values:

Number – of retransmission counter

class RawPduReceived : public whad::unifying::UnifyingMsg
#include <rawpdu.hpp>

Public Functions

RawPduReceived(UnifyingMsg &message)

Parse a message as a RawPduReceived message.

RawPduReceived(UnifyingPacket &packet)

RawPduReceived message constructor.

Parameters:

packet[in] Unifying packet received

void addAddress(UnifyingAddress &address)

Set optional address field.

Parameters:

address[in] Unifying node address

UnifyingPacket &getPacket()

Retrieve the received packet and its metadata.

Return values:

Reference – to a UnifyingPacket

bool hasAddress()

Determine if the address field has been set.

Return values:

True – if set, false otherwise

UnifyingAddress &getAddress()

Retrieve the retry counter.

Return values:

Number – of retransmission counter

class SendPdu : public whad::unifying::UnifyingMsg
#include <sendpdu.hpp>

Public Functions

SendPdu(UnifyingMsg &message)

Parse a message as a SendPdu message.

SendPdu(uint32_t channel, int retrCount, uint8_t *pPdu, int length)

SendPdu message constructor.

Parameters:
  • channel[in] Channel on which the PDU will be sent

  • retryCount[in] Maximum number of PDU retransmission

  • pPdu[in] Pointer to the byte buffer to send

  • length[in] PDU length in bytes

uint32_t getChannel()

Retrieve the sniffing channel.

Return values:

Channel – number

int getRetrCounter()

Retrieve the retry counter.

Return values:

Number – of retransmission counter

PDU &getPdu()

Retrieve the PDU.

Return values:

Reference – to the PDU

class SendRawPdu : public whad::unifying::UnifyingMsg
#include <sendrawpdu.hpp>

Public Functions

SendRawPdu(UnifyingMsg &message)

Parse a message as a SendRawPdu message.

SendRawPdu(uint32_t channel, int retrCount, uint8_t *pPdu, int length)

SendRawPdu message constructor.

Parameters:
  • channel[in] Channel on which the PDU will be sent

  • retryCount[in] Maximum number of PDU retransmission

  • pPdu[in] Pointer to the byte buffer to send

  • length[in] PDU length in bytes

uint32_t getChannel()

Retrieve the sniffing channel.

Return values:

Channel – number

int getRetrCounter()

Retrieve the retry counter.

Return values:

Number – of retransmission counter

PDU &getPdu()

Retrieve the PDU.

Return values:

Reference – to the PDU

class SetNodeAddress : public whad::unifying::UnifyingMsg
#include <setnodeaddr.hpp>

Public Functions

SetNodeAddress(UnifyingMsg &message)

Parse a message as a SetNodeAddress message.

SetNodeAddress(UnifyingAddress &address)

SetNodeAddress message constructor.

Parameters:

address[in] Specify the device address to use

UnifyingAddress &getAddress()

Retrieve the unifying node address.

Return values:

Node – address

class SniffMode : public whad::unifying::UnifyingMsg
#include <sniff.hpp>

Public Functions

SniffMode(UnifyingMsg &message)

Parse a message as a SniffMode message.

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

SniffMode message constructor.

Parameters:
  • address[in] Specify the device address to use

  • channel[in] Channel to sniff

  • showAcks[in] If set to true, interface will report packet acknowledgements

UnifyingAddress &getAddress()

Retrieve the unifying node address.

Return values:

Node – address

uint32_t getChannel()

Retrieve the sniffing channel.

Return values:

Channel – number

bool mustShowAcks()

Determine if we must show ACKs.

Return values:

True – if ACKs must be shown, false otherwise