aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-06-08 09:37:55 +0200
committerSven Gothel <[email protected]>2020-06-08 09:37:55 +0200
commitadee0106e27079a1188e8434cf9669ea79e1237e (patch)
treeb720b9556538b4073f60bea9d7d029ff4da0953e /api
parent704395713943a91635d53b13f17c463eee5d994c (diff)
DBTManager/MgmtTypes: Expose MgmtEvtDeviceBlocked, MgmtEvtDeviceUnblocked, MgmtEvtUserPasskeyRequest
Diffstat (limited to 'api')
-rw-r--r--api/direct_bt/DBTManager.hpp5
-rw-r--r--api/direct_bt/MgmtTypes.hpp68
2 files changed, 51 insertions, 22 deletions
diff --git a/api/direct_bt/DBTManager.hpp b/api/direct_bt/DBTManager.hpp
index 3578c350..fc16821e 100644
--- a/api/direct_bt/DBTManager.hpp
+++ b/api/direct_bt/DBTManager.hpp
@@ -116,11 +116,14 @@ namespace direct_bt {
bool mgmtEvDeviceDisconnectedCB(std::shared_ptr<MgmtEvent> e);
bool mgmtEvDeviceConnectedCB(std::shared_ptr<MgmtEvent> e);
bool mgmtEvConnectFailedCB(std::shared_ptr<MgmtEvent> e);
- bool mgmtEvDevicePinCodeRequestCB(std::shared_ptr<MgmtEvent> e);
+ bool mgmtEvDeviceBlockedCB(std::shared_ptr<MgmtEvent> e);
+ bool mgmtEvDeviceUnblockedCB(std::shared_ptr<MgmtEvent> e);
bool mgmtEvDeviceUnpairedCB(std::shared_ptr<MgmtEvent> e);
bool mgmtEvNewConnectionParamCB(std::shared_ptr<MgmtEvent> e);
bool mgmtEvDeviceWhitelistAddedCB(std::shared_ptr<MgmtEvent> e);
bool mgmtEvDeviceWhilelistRemovedCB(std::shared_ptr<MgmtEvent> e);
+ bool mgmtEvPinCodeRequestCB(std::shared_ptr<MgmtEvent> e);
+ bool mgmtEvUserPasskeyRequestCB(std::shared_ptr<MgmtEvent> e);
void sendMgmtEvent(std::shared_ptr<MgmtEvent> event);
public:
diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp
index e4ffb0ec..31dd8573 100644
--- a/api/direct_bt/MgmtTypes.hpp
+++ b/api/direct_bt/MgmtTypes.hpp
@@ -1053,10 +1053,8 @@ namespace direct_bt {
/**
* mgmt_addr_info { EUI48, uint8_t type },
*/
- class MgmtEvtDeviceWhitelistRemoved : public MgmtEvent
+ class MgmtEvtAdressInfoMeta : public MgmtEvent
{
- public:
-
protected:
std::string baseString() const override {
return MgmtEvent::baseString()+", address="+getAddress().toString()+
@@ -1064,10 +1062,10 @@ namespace direct_bt {
}
public:
- MgmtEvtDeviceWhitelistRemoved(const uint8_t* buffer, const int buffer_len)
+ MgmtEvtAdressInfoMeta(const Opcode opc, const uint8_t* buffer, const int buffer_len)
: MgmtEvent(buffer, buffer_len)
{
- checkOpcode(getOpcode(), Opcode::DEVICE_WHITELIST_REMOVED);
+ checkOpcode(getOpcode(), opc);
}
const EUI48 getAddress() const { return EUI48(pdu.get_ptr(MGMT_HEADER_SIZE)); } // mgmt_addr_info
BDAddressType getAddressType() const { return static_cast<BDAddressType>(pdu.get_uint8(MGMT_HEADER_SIZE+6)); } // mgmt_addr_info
@@ -1080,28 +1078,56 @@ namespace direct_bt {
/**
* mgmt_addr_info { EUI48, uint8_t type },
*/
- class MgmtEvtDeviceUnpaired : public MgmtEvent
+ class MgmtEvtDeviceWhitelistRemoved : public MgmtEvtAdressInfoMeta
{
public:
+ MgmtEvtDeviceWhitelistRemoved(const uint8_t* buffer, const int buffer_len)
+ : MgmtEvtAdressInfoMeta(Opcode::DEVICE_WHITELIST_REMOVED, buffer, buffer_len)
+ { }
+ };
- protected:
- std::string baseString() const override {
- return MgmtEvent::baseString()+", address="+getAddress().toString()+
- ", addressType "+getBDAddressTypeString(getAddressType());
- }
-
+ /**
+ * mgmt_addr_info { EUI48, uint8_t type },
+ */
+ class MgmtEvtDeviceUnpaired : public MgmtEvtAdressInfoMeta
+ {
public:
MgmtEvtDeviceUnpaired(const uint8_t* buffer, const int buffer_len)
- : MgmtEvent(buffer, buffer_len)
- {
- checkOpcode(getOpcode(), Opcode::DEVICE_UNPAIRED);
- }
- const EUI48 getAddress() const { return EUI48(pdu.get_ptr(MGMT_HEADER_SIZE)); } // mgmt_addr_info
- BDAddressType getAddressType() const { return static_cast<BDAddressType>(pdu.get_uint8(MGMT_HEADER_SIZE+6)); } // mgmt_addr_info
+ : MgmtEvtAdressInfoMeta(Opcode::DEVICE_UNPAIRED, buffer, buffer_len)
+ { }
+ };
- int getDataOffset() const override { return MGMT_HEADER_SIZE+7; }
- int getDataSize() const override { return getParamSize()-7; }
- const uint8_t* getData() const override { return getDataSize()>0 ? pdu.get_ptr(getDataOffset()) : nullptr; }
+ /**
+ * mgmt_addr_info { EUI48, uint8_t type },
+ */
+ class MgmtEvtDeviceBlocked : public MgmtEvtAdressInfoMeta
+ {
+ public:
+ MgmtEvtDeviceBlocked(const uint8_t* buffer, const int buffer_len)
+ : MgmtEvtAdressInfoMeta(Opcode::DEVICE_BLOCKED, buffer, buffer_len)
+ { }
+ };
+
+ /**
+ * mgmt_addr_info { EUI48, uint8_t type },
+ */
+ class MgmtEvtDeviceUnblocked : public MgmtEvtAdressInfoMeta
+ {
+ public:
+ MgmtEvtDeviceUnblocked(const uint8_t* buffer, const int buffer_len)
+ : MgmtEvtAdressInfoMeta(Opcode::DEVICE_UNBLOCKED, buffer, buffer_len)
+ { }
+ };
+
+ /**
+ * mgmt_addr_info { EUI48, uint8_t type },
+ */
+ class MgmtEvtUserPasskeyRequest: public MgmtEvtAdressInfoMeta
+ {
+ public:
+ MgmtEvtUserPasskeyRequest(const uint8_t* buffer, const int buffer_len)
+ : MgmtEvtAdressInfoMeta(Opcode::USER_PASSKEY_REQUEST, buffer, buffer_len)
+ { }
};
/**