mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-24 23:07:17 +00:00
needed API changes
This commit is contained in:
parent
3368b73753
commit
e213461985
@ -333,13 +333,13 @@ class MI32SensorCallback : public NimBLEClientCallbacks {
|
|||||||
|
|
||||||
class MI32AdvCallbacks: public NimBLEAdvertisedDeviceCallbacks {
|
class MI32AdvCallbacks: public NimBLEAdvertisedDeviceCallbacks {
|
||||||
void onResult(NimBLEAdvertisedDevice* advertisedDevice) {
|
void onResult(NimBLEAdvertisedDevice* advertisedDevice) {
|
||||||
// AddLog_P2(LOG_LEVEL_DEBUG,PSTR("Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData().length());
|
// AddLog_P2(LOG_LEVEL_DEBUG,PSTR("Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
|
||||||
if (advertisedDevice->getServiceData().length() == 0) {
|
if (advertisedDevice->getServiceDataCount() == 0) {
|
||||||
// AddLog_P2(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData().length());
|
// AddLog_P2(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
|
||||||
MI32Scan->erase(advertisedDevice->getAddress());
|
MI32Scan->erase(advertisedDevice->getAddress());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint16_t uuid = advertisedDevice->getServiceDataUUID().getNative()->u16.value;
|
uint16_t uuid = advertisedDevice->getServiceDataUUID(0).getNative()->u16.value;
|
||||||
// AddLog_P2(LOG_LEVEL_DEBUG,PSTR("UUID: %x"),uuid);
|
// AddLog_P2(LOG_LEVEL_DEBUG,PSTR("UUID: %x"),uuid);
|
||||||
uint8_t addr[6];
|
uint8_t addr[6];
|
||||||
memcpy(addr,advertisedDevice->getAddress().getNative(),6);
|
memcpy(addr,advertisedDevice->getAddress().getNative(),6);
|
||||||
@ -350,14 +350,14 @@ class MI32AdvCallbacks: public NimBLEAdvertisedDeviceCallbacks {
|
|||||||
}
|
}
|
||||||
// AddLog_P2(LOG_LEVEL_DEBUG,PSTR("RSSI: %d"),rssi); // actually i never got a 0xffff
|
// AddLog_P2(LOG_LEVEL_DEBUG,PSTR("RSSI: %d"),rssi); // actually i never got a 0xffff
|
||||||
if(uuid==0xfe95) {
|
if(uuid==0xfe95) {
|
||||||
MI32ParseResponse((char*)advertisedDevice->getServiceData().data(),advertisedDevice->getServiceData().length(), addr, rssi);
|
MI32ParseResponse((char*)advertisedDevice->getServiceData(0).data(),advertisedDevice->getServiceData(0).length(), addr, rssi);
|
||||||
}
|
}
|
||||||
else if(uuid==0xfdcd) {
|
else if(uuid==0xfdcd) {
|
||||||
MI32parseCGD1Packet((char*)advertisedDevice->getServiceData().data(),advertisedDevice->getServiceData().length(), addr, rssi);
|
MI32parseCGD1Packet((char*)advertisedDevice->getServiceData(0).data(),advertisedDevice->getServiceData(0).length(), addr, rssi);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MI32Scan->erase(advertisedDevice->getAddress());
|
MI32Scan->erase(advertisedDevice->getAddress());
|
||||||
// AddLog_P2(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData().length());
|
// AddLog_P2(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -749,12 +749,12 @@ void MI32StartScanTask(){
|
|||||||
|
|
||||||
void MI32ScanTask(void *pvParameters){
|
void MI32ScanTask(void *pvParameters){
|
||||||
if (MI32Scan == nullptr) MI32Scan = NimBLEDevice::getScan();
|
if (MI32Scan == nullptr) MI32Scan = NimBLEDevice::getScan();
|
||||||
DEBUG_SENSOR_LOG(PSTR("%s: Scan Cache Length: %u"),D_CMND_MI32, MI32Scan->getResults().getCount());
|
// DEBUG_SENSOR_LOG(PSTR("%s: Scan Cache Length: %u"),D_CMND_MI32, MI32Scan->getResults().getCount());
|
||||||
MI32Scan->setInterval(70);
|
MI32Scan->setInterval(70);
|
||||||
MI32Scan->setWindow(50);
|
MI32Scan->setWindow(50);
|
||||||
MI32Scan->setAdvertisedDeviceCallbacks(&MI32ScanCallbacks,true);
|
MI32Scan->setAdvertisedDeviceCallbacks(&MI32ScanCallbacks,true);
|
||||||
MI32Scan->setActiveScan(false);
|
MI32Scan->setActiveScan(false);
|
||||||
MI32Scan->start(0, MI32scanEndedCB, true); // never stop scanning, will pause automaically while connecting
|
MI32Scan->start(0, MI32scanEndedCB, true); // never stop scanning, will pause automatically while connecting
|
||||||
|
|
||||||
uint32_t timer = 0;
|
uint32_t timer = 0;
|
||||||
for(;;){
|
for(;;){
|
||||||
@ -841,7 +841,7 @@ bool MI32connectLYWSD03forNotification(){
|
|||||||
}
|
}
|
||||||
if (pChr){
|
if (pChr){
|
||||||
if(pChr->canNotify()) {
|
if(pChr->canNotify()) {
|
||||||
if(pChr->subscribe(true,false,MI32notifyCB)) {
|
if(pChr->subscribe(true,MI32notifyCB,false)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user