forked from arduino-libraries/ArduinoBLE
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from unknownconstant/pairing
Fixed packet fragmentation
- Loading branch information
Showing
5 changed files
with
100 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "bitDescriptions.h" | ||
|
||
|
||
#define BONDING_BIT 0b00000001 | ||
#define MITM_BIT 0b00000100 | ||
#define SC_BIT 0b00001000 | ||
#define KEYPRESS_BIT 0b00010000 | ||
#define CT2_BIT 0b00100000 | ||
|
||
|
||
AuthReq::AuthReq(){} | ||
AuthReq::AuthReq(uint8_t octet):_octet(octet){} | ||
bool AuthReq::Bonding(){ return (_octet & BONDING_BIT)>0;} | ||
bool AuthReq::MITM(){ return (_octet & MITM_BIT)>0;} | ||
bool AuthReq::SC(){ return (_octet & SC_BIT)>0;} | ||
bool AuthReq::KeyPress(){ return (_octet & KEYPRESS_BIT)>0;} | ||
bool AuthReq::CT2(){ return (_octet & CT2_BIT)>0;} | ||
|
||
|
||
void AuthReq::setBonding(bool state) { _octet= state? _octet|BONDING_BIT : _octet&~BONDING_BIT;} | ||
void AuthReq::setMITM(bool state) { _octet= state? _octet|MITM_BIT : _octet&~MITM_BIT;} | ||
void AuthReq::setSC(bool state){ _octet= state? _octet|SC_BIT : _octet&~SC_BIT;} | ||
void AuthReq::setKeyPress(bool state){ _octet= state? _octet|KEYPRESS_BIT : _octet&~KEYPRESS_BIT;} | ||
void AuthReq::setCT2(bool state){ _octet= state? _octet|CT2_BIT : _octet&~CT2_BIT;} | ||
|
||
uint8_t _octet; | ||
|
||
|
||
void AuthReq::setOctet( uint8_t octet){_octet = octet;} | ||
uint8_t AuthReq::getOctet() {return _octet;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef _BIT_DESCRIPTIONS_H_ | ||
#define _BIT_DESCRIPTIONS_H_ | ||
#include <Arduino.h> | ||
|
||
class AuthReq{ | ||
public: | ||
AuthReq(); | ||
AuthReq(uint8_t octet); | ||
void setOctet( uint8_t octet); | ||
uint8_t getOctet(); | ||
|
||
|
||
// The Bonding_Flags field is a 2-bit field that indicates the type of bonding being requested by the initiating device | ||
bool Bonding(); | ||
// The MITM field is a 1-bit flag that is set to one if the device is requesting MITM protection | ||
bool MITM(); | ||
// The SC field is a 1 bit flag. If LE Secure Connections pairing is supported by the device, then the SC field shall be set to 1, otherwise it shall be set to 0. | ||
bool SC(); | ||
// The keypress field is a 1-bit flag that is used only in the Passkey Entry protocol and shall be ignored in other protocols. | ||
bool KeyPress(); | ||
// The CT2 field is a 1-bit flag that shall be set to 1 upon transmission to indicate support for the h7 function. | ||
bool CT2(); | ||
|
||
void setBonding(bool state); | ||
void setMITM(bool state); | ||
void setSC(bool state); | ||
void setKeyPress(bool state); | ||
void setCT2(bool state); | ||
private: | ||
uint8_t _octet; | ||
}; | ||
|
||
enum IOCap { | ||
DisplayOnly, | ||
DisplayYesNo, | ||
KeyboardOnly, | ||
NoInputNoOutput, | ||
KeyboardDisplay | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters