5502879a5b
This is very much still work in progress and much more will change before the final 2.0.0 Some APIs have changed. New libraries have been added. LittleFS included. Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Mike Dunston <m_dunston@comcast.net> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: microDev <70126934+microDev1@users.noreply.github.com> Co-authored-by: tobozo <tobozo@users.noreply.github.com> Co-authored-by: bobobo1618 <bobobo1618@users.noreply.github.com> Co-authored-by: lorol <lorolouis@gmail.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net> Co-authored-by: Sweety <switi.mhaiske@espressif.com> Co-authored-by: Loick MAHIEUX <loick111@gmail.com> Co-authored-by: Larry Bernstone <lbernstone@gmail.com> Co-authored-by: Valerii Koval <valeros@users.noreply.github.com> Co-authored-by: 快乐的我531 <2302004040@qq.com> Co-authored-by: chegewara <imperiaonline4@gmail.com> Co-authored-by: Clemens Kirchgatterer <clemens@1541.org> Co-authored-by: Aron Rubin <aronrubin@gmail.com> Co-authored-by: Pete Lewis <601236+lewispg228@users.noreply.github.com>
74 lines
1.9 KiB
C++
74 lines
1.9 KiB
C++
/*
|
|
* BLESecurity.h
|
|
*
|
|
* Created on: Dec 17, 2017
|
|
* Author: chegewara
|
|
*/
|
|
|
|
#ifndef COMPONENTS_CPP_UTILS_BLESECURITY_H_
|
|
#define COMPONENTS_CPP_UTILS_BLESECURITY_H_
|
|
#include "sdkconfig.h"
|
|
#if defined(CONFIG_BLUEDROID_ENABLED)
|
|
|
|
#include <esp_gap_ble_api.h>
|
|
|
|
class BLESecurity {
|
|
public:
|
|
BLESecurity();
|
|
virtual ~BLESecurity();
|
|
void setAuthenticationMode(esp_ble_auth_req_t auth_req);
|
|
void setCapability(esp_ble_io_cap_t iocap);
|
|
void setInitEncryptionKey(uint8_t init_key);
|
|
void setRespEncryptionKey(uint8_t resp_key);
|
|
void setKeySize(uint8_t key_size = 16);
|
|
void setStaticPIN(uint32_t pin);
|
|
static char* esp_key_type_to_str(esp_ble_key_type_t key_type);
|
|
|
|
private:
|
|
esp_ble_auth_req_t m_authReq;
|
|
esp_ble_io_cap_t m_iocap;
|
|
uint8_t m_initKey;
|
|
uint8_t m_respKey;
|
|
uint8_t m_keySize;
|
|
|
|
}; // BLESecurity
|
|
|
|
|
|
/*
|
|
* @brief Callbacks to handle GAP events related to authorization
|
|
*/
|
|
class BLESecurityCallbacks {
|
|
public:
|
|
virtual ~BLESecurityCallbacks() {};
|
|
|
|
/**
|
|
* @brief Its request from peer device to input authentication pin code displayed on peer device.
|
|
* It requires that our device is capable to input 6-digits code by end user
|
|
* @return Return 6-digits integer value from input device
|
|
*/
|
|
virtual uint32_t onPassKeyRequest() = 0;
|
|
|
|
/**
|
|
* @brief Provide us 6-digits code to perform authentication.
|
|
* It requires that our device is capable to display this code to end user
|
|
* @param
|
|
*/
|
|
virtual void onPassKeyNotify(uint32_t pass_key) = 0;
|
|
|
|
/**
|
|
* @brief Here we can make decision if we want to let negotiate authorization with peer device or not
|
|
* return Return true if we accept this peer device request
|
|
*/
|
|
|
|
virtual bool onSecurityRequest() = 0 ;
|
|
/**
|
|
* Provide us information when authentication process is completed
|
|
*/
|
|
virtual void onAuthenticationComplete(esp_ble_auth_cmpl_t) = 0;
|
|
|
|
virtual bool onConfirmPIN(uint32_t pin) = 0;
|
|
}; // BLESecurityCallbacks
|
|
|
|
#endif // CONFIG_BLUEDROID_ENABLED
|
|
#endif // COMPONENTS_CPP_UTILS_BLESECURITY_H_
|