summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/direct_bt/BTDevice.hpp3
-rw-r--r--api/direct_bt/BTManager.hpp2
-rw-r--r--api/direct_bt/MgmtTypes.hpp17
3 files changed, 20 insertions, 2 deletions
diff --git a/api/direct_bt/BTDevice.hpp b/api/direct_bt/BTDevice.hpp
index e4528c4c..a30634b7 100644
--- a/api/direct_bt/BTDevice.hpp
+++ b/api/direct_bt/BTDevice.hpp
@@ -899,6 +899,9 @@ namespace direct_bt {
*/
bool isConnSecurityAutoEnabled() const noexcept;
+ HCIStatusCode setPairingPINCode(const std::string& pinCode) noexcept;
+ HCIStatusCode setPairingPINCodeNegative() noexcept;
+
/**
* Method sets the given passkey entry, see ::PairingMode::PASSKEY_ENTRY_ini.
* <p>
diff --git a/api/direct_bt/BTManager.hpp b/api/direct_bt/BTManager.hpp
index e683f821..44003784 100644
--- a/api/direct_bt/BTManager.hpp
+++ b/api/direct_bt/BTManager.hpp
@@ -502,6 +502,8 @@ namespace direct_bt {
HCIStatusCode uploadLinkKey(const uint16_t dev_id, const MgmtLinkKeyInfo &key) noexcept;
HCIStatusCode uploadLinkKey(const uint16_t dev_id, const BDAddressAndType & addressAndType, const SMPLinkKey& lk) noexcept;
+ MgmtStatus userPINCodeReply(const uint16_t dev_id, const BDAddressAndType & addressAndType, const std::string& pinCode) noexcept;
+ MgmtStatus userPINCodeNegativeReply(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept;
MgmtStatus userPasskeyReply(const uint16_t dev_id, const BDAddressAndType & addressAndType, const uint32_t passkey) noexcept;
MgmtStatus userPasskeyNegativeReply(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept;
MgmtStatus userConfirmReply(const uint16_t dev_id, const BDAddressAndType & addressAndType, const bool positive) noexcept;
diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp
index 579cec1e..444e3035 100644
--- a/api/direct_bt/MgmtTypes.hpp
+++ b/api/direct_bt/MgmtTypes.hpp
@@ -852,13 +852,26 @@ namespace direct_bt {
public:
MgmtPinCodeReplyCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType,
- const uint8_t pin_len, const jau::TROOctets &pin_code)
+ const jau::TROOctets& pin_code)
: MgmtCommand(Opcode::PIN_CODE_REPLY, dev_id, 6+1+1+16)
{
+ const uint8_t pin_len = static_cast<uint8_t>( std::min<jau::nsize_t>(16, pin_code.size()) );
pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
pdu.put_uint8_nc(MGMT_HEADER_SIZE+7, pin_len);
- pdu.put_octets_nc(MGMT_HEADER_SIZE+8, pin_code);
+ pdu.bzero_nc(MGMT_HEADER_SIZE+8, 16);
+ pdu.put_octets_nc(MGMT_HEADER_SIZE+8, pin_code, 0, pin_len);
+ }
+ MgmtPinCodeReplyCmd(const uint16_t dev_id, const BDAddressAndType& addressAndType,
+ const std::string& pin_code)
+ : MgmtCommand(Opcode::PIN_CODE_REPLY, dev_id, 6+1+1+16)
+ {
+ const uint8_t pin_len = static_cast<uint8_t>( std::min<size_t>(16, pin_code.size()) );
+ pdu.put_eui48_nc(MGMT_HEADER_SIZE, addressAndType.address);
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+6, direct_bt::number(addressAndType.type));
+ pdu.put_uint8_nc(MGMT_HEADER_SIZE+7, pin_len);
+ pdu.bzero_nc(MGMT_HEADER_SIZE+8, 16);
+ pdu.put_string_nc(MGMT_HEADER_SIZE+8, pin_code, pin_len, false /* EOS */);
}
const EUI48& getAddress() const noexcept { return *reinterpret_cast<const EUI48 *>( pdu.get_ptr_nc(MGMT_HEADER_SIZE + 0) ); } // mgmt_addr_info
BDAddressType getAddressType() const noexcept { return static_cast<BDAddressType>(pdu.get_uint8_nc(MGMT_HEADER_SIZE+6)); } // mgmt_addr_info