Skip to content

Commit

Permalink
Fix Core 3 compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
arendst committed Aug 23, 2023
1 parent 3c725a1 commit 0d80e63
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tasmota/tasmota_xsns_sensor/xsns_62_esp32_mi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*/
#ifndef USE_BLE_ESP32
#ifdef ESP32 // ESP32 only. Use define USE_HM10 for ESP8266 support
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3
#if defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32C2 || defined CONFIG_IDF_TARGET_ESP32C6 || defined CONFIG_IDF_TARGET_ESP32S3

#ifdef USE_MI_ESP32

Expand Down Expand Up @@ -119,7 +119,7 @@ class MI32SensorCallback : public NimBLEClientCallbacks {
}
};

class MI32AdvCallbacks: public NimBLEAdvertisedDeviceCallbacks {
class MI32AdvCallbacks: public NimBLEScanCallbacks {
void onResult(NimBLEAdvertisedDevice* advertisedDevice) {
static bool _mutex = false;
if(_mutex) return;
Expand Down Expand Up @@ -210,7 +210,7 @@ class MI32CharacteristicCallbacks: public NimBLECharacteristicCallbacks {
/** The status returned in status is defined in NimBLECharacteristic.h.
* The value returned in code is the NimBLE host return code.
*/
void onStatus(NimBLECharacteristic* pCharacteristic, Status status, int code) {
void onStatus(NimBLECharacteristic* pCharacteristic, int code) {
BLEqueueBuffer_t q;
q.length = 0;
q.type = BLE_OP_ON_STATUS;
Expand Down Expand Up @@ -697,7 +697,9 @@ void MI32PreInit(void) {
void MI32Init(void) {
if (MI32.mode.init) { return; }

if (TasmotaGlobal.global_state.wifi_down && TasmotaGlobal.global_state.eth_down) { return; }
if (TasmotaGlobal.global_state.wifi_down && TasmotaGlobal.global_state.eth_down) {
if (!(WIFI_MANAGER == Wifi.config_type || WIFI_MANAGER_RESET_ONLY == Wifi.config_type)) return;
}

if (!TasmotaGlobal.global_state.wifi_down) {
TasmotaGlobal.wifi_stay_asleep = true;
Expand All @@ -719,8 +721,8 @@ void MI32Init(void) {
}

if (!MI32.mode.init) {
NimBLEDevice::setScanFilterMode(CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE);
NimBLEDevice::setScanDuplicateCacheSize(40); // will not be perfect for every situation (few vs many BLE devices nearby)
// NimBLEDevice::setScanFilterMode(1); //CONFIG_BTDM_SCAN_DUPL_TYPE_DATA
// NimBLEDevice::setScanDuplicateCacheSize(40); // will not be perfect for every situation (few vs many BLE devices nearby)
const std::string name(TasmotaGlobal.hostname);
NimBLEDevice::init(name);
AddLog(LOG_LEVEL_INFO,PSTR("M32: Init BLE device: %s"),TasmotaGlobal.hostname);
Expand Down Expand Up @@ -866,10 +868,10 @@ extern "C" {
bool _runningScan = MI32Scan->stop();
if(NimBLEDevice::whiteListAdd(_newAddress)){
MI32Scan->setFilterPolicy(BLE_HCI_SCAN_FILT_USE_WL);
if(_runningScan) MI32Scan->start(0, MI32scanEndedCB, false);
if(_runningScan) MI32Scan->start(0, false);
}
else {
if(_runningScan) MI32Scan->start(0, MI32scanEndedCB, false);
if(_runningScan) MI32Scan->start(0, false);
return false;
}
}
Expand Down Expand Up @@ -1200,7 +1202,7 @@ void MI32ScanTask(void *pvParameters){

MI32Scan = NimBLEDevice::getScan();

MI32Scan->setAdvertisedDeviceCallbacks(&MI32ScanCallbacks,false);
MI32Scan->setScanCallbacks(&MI32ScanCallbacks,false);
if(NimBLEDevice::getWhiteListCount()>0){
MI32Scan->setFilterPolicy(BLE_HCI_SCAN_FILT_USE_WL);
}
Expand All @@ -1210,7 +1212,7 @@ void MI32ScanTask(void *pvParameters){

MI32Scan->setActiveScan(MI32.option.activeScan == 1);
MI32Scan->setMaxResults(0);
MI32Scan->start(0, MI32scanEndedCB, false); // never stop scanning, will pause automatically while connecting
MI32Scan->start(0, false); // never stop scanning, will pause automatically while connecting
MI32.infoMsg = MI32.option.activeScan?MI32_START_SCANNING_ACTIVE:MI32_START_SCANNING_PASSIVE;

uint32_t timer = 0;
Expand Down Expand Up @@ -1292,7 +1294,7 @@ bool MI32StartConnectionTask(){
}

void MI32ConnectionTask(void *pvParameters){
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6) //needs more testing ...
#if !defined(CONFIG_IDF_TARGET_ESP32C3) || !defined(CONFIG_IDF_TARGET_ESP32C6) //needs more testing ...
// NimBLEDevice::setOwnAddrType(BLE_OWN_ADDR_RANDOM,false); //seems to be important for i.e. xbox controller, hopefully not breaking other things
// NimBLEDevice::setSecurityAuth(true, true, true);
#endif //CONFIG_IDF_TARGET_ESP32C3
Expand Down Expand Up @@ -2669,4 +2671,4 @@ bool Xsns62(uint32_t function)
#endif // USE_MI_ESP32
#endif // CONFIG_IDF_TARGET_ESP32 or CONFIG_IDF_TARGET_ESP32C3
#endif // ESP32
#endif // USE_BLE_ESP32
#endif // USE_BLE_ESP32

0 comments on commit 0d80e63

Please sign in to comment.