72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
#ifndef __BLE_SCAN_H
|
|
#define __BLE_SCAN_H
|
|
|
|
class NimBLEClient;
|
|
class NimBLERemoteCharacteristic;
|
|
class NimBLEAddress;
|
|
|
|
class CBLEScan {
|
|
public:
|
|
void setupConnect(uint64_t addr, uint64_t addr2);
|
|
void setupScan();
|
|
void loop(unsigned long clock);
|
|
void startScan();
|
|
bool connect(NimBLEAddress addr, bool bAsync);
|
|
inline int16_t getTemp() { return m_nTemp; };
|
|
inline int16_t getHumid() { return m_nHumid; };
|
|
inline uint8_t getBatteyLevel() { return m_nBatteryLevel; };
|
|
inline int16_t getTemp2() { return m_nTemp2; };
|
|
inline int16_t getHumid2() { return m_nHumid2; };
|
|
inline uint8_t getBatteyLevel2() { return m_nBatteryLevel2; };
|
|
|
|
inline void setData(int16_t temp, uint16_t humid, uint8_t bLevel) {
|
|
m_nTemp = temp;
|
|
m_nHumid = humid;
|
|
m_nBatteryLevel = bLevel;
|
|
m_bDataReceived = true;
|
|
m_nLastReceive = m_nLatestBLEAdvertise;
|
|
m_nLatestBLEAdvertise = millis();
|
|
}
|
|
|
|
inline void setData2(int16_t temp, uint16_t humid, uint8_t bLevel) {
|
|
m_nTemp2 = temp;
|
|
m_nHumid2 = humid;
|
|
m_nBatteryLevel2 = bLevel;
|
|
m_bDataReceived2 = true;
|
|
m_nLastReceive2 = m_nLatestBLEAdvertise2;
|
|
m_nLatestBLEAdvertise2 = millis();
|
|
}
|
|
|
|
inline void setScanType(bool bContinuous) { m_bContinuousScan = bContinuous; };
|
|
|
|
private:
|
|
bool m_bContinuousScan;
|
|
bool m_bScanStarted;
|
|
bool m_bConnected;
|
|
bool m_bConnectionInProgress;
|
|
int16_t m_nInterval;
|
|
uint64_t m_nAddr, m_nAddr2;
|
|
|
|
int16_t m_nTemp;
|
|
int16_t m_nHumid;
|
|
uint8_t m_nBatteryLevel;
|
|
|
|
int16_t m_nTemp2;
|
|
int16_t m_nHumid2;
|
|
uint8_t m_nBatteryLevel2;
|
|
|
|
unsigned long m_nLatestBLEAdvertise;
|
|
unsigned long m_nLastReceive;
|
|
bool m_bDataReceived;
|
|
|
|
unsigned long m_nLatestBLEAdvertise2;
|
|
unsigned long m_nLastReceive2;
|
|
bool m_bDataReceived2;
|
|
|
|
NimBLEClient *pClient;
|
|
NimBLERemoteCharacteristic *pRemoteCharacteristic;
|
|
};
|
|
|
|
extern CBLEScan ble;
|
|
|
|
#endif |