mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 11:16:34 +00:00
Rebase fixes
This commit is contained in:
parent
ff6c328ba9
commit
1c6b0d8a4d
@ -283,16 +283,13 @@ void ESP32Init() {
|
||||
|
||||
if (TasmotaGlobal.global_state.wifi_down) { return; }
|
||||
|
||||
TasmotaGlobal.wifi_stay_asleep = true;
|
||||
if (WiFi.getSleep() == false) {
|
||||
if (0 == Settings.flag3.sleep_normal) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: About to restart to put WiFi modem in sleep mode"),"BLE");
|
||||
Settings.flag3.sleep_normal = 1; // SetOption60 - Enable normal sleep instead of dynamic sleep
|
||||
TasmotaGlobal.restart_flag = 2;
|
||||
}
|
||||
return;
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Put WiFi modem in sleep mode"),"BLE");
|
||||
WiFi.setSleep(true); // Sleep
|
||||
}
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Initializing Blueetooth..."),"BLE");
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Initializing Bluetooth..."),"BLE");
|
||||
|
||||
if (!ESP32BLE.mode.init) {
|
||||
NimBLEDevice::init("");
|
||||
@ -1020,4 +1017,4 @@ bool Xsns52(byte function)
|
||||
|
||||
#endif // USE_IBEACON
|
||||
|
||||
#endif
|
||||
#endif // USE_BLE_ESP32
|
||||
|
@ -590,17 +590,17 @@ int MI32_decryptPacket(char *_buf, uint16_t _bufSize, uint32_t _type){
|
||||
MI32_ReverseMAC(packet->MAC);
|
||||
uint8_t _bindkey[16] = {0x0};
|
||||
bool foundNoKey = true;
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: search key for MAC: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Search key for MAC: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]);
|
||||
for(uint32_t i=0; i<MIBLEbindKeys.size(); i++){
|
||||
if(memcmp(packet->MAC,MIBLEbindKeys[i].MAC,sizeof(packet->MAC))==0){
|
||||
memcpy(_bindkey,MIBLEbindKeys[i].key,sizeof(_bindkey));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: decryption Key found"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Decryption Key found"));
|
||||
foundNoKey = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(foundNoKey){
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: no Key found !!"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: No Key found !!"));
|
||||
return -2;
|
||||
}
|
||||
|
||||
@ -620,7 +620,7 @@ int MI32_decryptPacket(char *_buf, uint16_t _bufSize, uint32_t _type){
|
||||
|
||||
ret = br_ccm_check_tag(&ctx, &tag);
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, packet->payload[1],packet->payload[2],packet->payload[3],packet->payload[4],packet->payload[5]);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, packet->payload[1],packet->payload[2],packet->payload[3],packet->payload[4],packet->payload[5]);
|
||||
return ret-1;
|
||||
}
|
||||
#endif // USE_MI_DECRYPTION
|
||||
@ -661,7 +661,7 @@ uint32_t MIBLEgetSensorSlot(uint8_t (&_MAC)[6], uint16_t _type, uint8_t counter)
|
||||
bool _success = false;
|
||||
for (uint32_t i=0;i<MI32_TYPES;i++){ // i < sizeof(kMI32DeviceID) gives compiler warning
|
||||
if(_type == kMI32DeviceID[i]){
|
||||
DEBUG_SENSOR_LOG(PSTR("MI32: ID is type %u"), i);
|
||||
DEBUG_SENSOR_LOG(PSTR("M32: ID is type %u"), i);
|
||||
_type = i+1;
|
||||
_success = true;
|
||||
}
|
||||
@ -780,26 +780,23 @@ void MI32PreInit(void) {
|
||||
MI32.option.showRSSI = 1;
|
||||
MI32.option.ignoreBogusBattery = 1; // from advertisements
|
||||
MI32.option.holdBackFirstAutodiscovery = 1;
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: pre-init"));
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: pre-init"));
|
||||
}
|
||||
|
||||
void MI32Init(void) {
|
||||
if (MI32.mode.init) { return; }
|
||||
|
||||
if (TasmotaGlobal.global_state.wifi_down) { return; }
|
||||
|
||||
TasmotaGlobal.wifi_stay_asleep = true;
|
||||
if (WiFi.getSleep() == false) {
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: WiFi modem not in sleep mode, BLE cannot start yet"));
|
||||
if (0 == Settings.flag3.sleep_normal) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: About to restart to put WiFi modem in sleep mode"));
|
||||
Settings.flag3.sleep_normal = 1; // SetOption60 - Enable normal sleep instead of dynamic sleep
|
||||
TasmotaGlobal.restart_flag = 2;
|
||||
}
|
||||
return;
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Put WiFi modem in sleep mode"));
|
||||
WiFi.setSleep(true); // Sleep
|
||||
}
|
||||
|
||||
if (!MI32.mode.init) {
|
||||
NimBLEDevice::init("");
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: init BLE device"));
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Init BLE device"));
|
||||
MI32.mode.canScan = 1;
|
||||
MI32.mode.init = 1;
|
||||
MI32.period = Settings.tele_period;
|
||||
@ -1287,7 +1284,7 @@ void MI32parseMiBeacon(char * _buf, uint32_t _slot, uint16_t _bufSize){
|
||||
break;
|
||||
}
|
||||
if(decryptRet!=0){
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: decryption failed with error: %d"),decryptRet);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Decryption failed with error: %d"),decryptRet);
|
||||
return;
|
||||
}
|
||||
#endif //USE_MI_DECRYPTION
|
||||
@ -1460,7 +1457,7 @@ void MI32parseCGD1Packet(char * _buf, uint32_t length, uint8_t addr[6], int RSSI
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DEBUG_SENSOR_LOG(PSTR("MI32: unexpected CGD1-packet"));
|
||||
DEBUG_SENSOR_LOG(PSTR("M32: Unexpected CGD1-packet"));
|
||||
}
|
||||
if(MIBLEsensors[_slot].eventType.raw == 0) return;
|
||||
MIBLEsensors[_slot].shallSendMQTT = 1;
|
||||
@ -1492,7 +1489,7 @@ void MI32ParseResponse(char *buf, uint16_t bufsize, uint8_t addr[6], int RSSI) {
|
||||
* @param UUID
|
||||
*/
|
||||
void MI32ParseGenericBeacon(uint8_t* payload, size_t payloadLength, uint16_t* CID, uint16_t*SVC, uint16_t* UUID){
|
||||
AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("MI32: Beacon:____________"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Beacon:____________"));
|
||||
for (uint32_t i = 0; i<payloadLength;){
|
||||
uint32_t ADtype = payload[i+1];
|
||||
uint32_t offset = payload[i];
|
||||
@ -1550,13 +1547,13 @@ void MI32HandleGenericBeacon(uint8_t* payload, size_t payloadLength, int RSSI, u
|
||||
}
|
||||
// else handle scan
|
||||
if(MIBLEscanResult.size()>19) {
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: Scan buffer full"));
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Scan buffer full"));
|
||||
MI32.state.beaconScanCounter = 1;
|
||||
return;
|
||||
}
|
||||
for(auto _scanResult : MIBLEscanResult){
|
||||
if(memcmp(addr,_scanResult.MAC,6)==0){
|
||||
// AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: known device"));
|
||||
// AddLog_P(LOG_LEVEL_INFO,PSTR("M32: known device"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1586,12 +1583,12 @@ void MI32addBeacon(uint8_t index, char* data){
|
||||
_new.time = 0;
|
||||
if(memcmp(_empty,_new.MAC,6) == 0){
|
||||
_new.active = false;
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: beacon%u deactivated"), index);
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Beacon%u deactivated"), index);
|
||||
}
|
||||
else{
|
||||
_new.active = true;
|
||||
MI32.mode.activeBeacon = 1;
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: beacon added with MAC: %s"), _MAC);
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Beacon added with MAC: %s"), _MAC);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1846,7 +1843,7 @@ void CmndMi32Time(void) {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
if (MIBLEsensors.size() > XdrvMailbox.payload) {
|
||||
if ((LYWSD02 == MIBLEsensors[XdrvMailbox.payload].type) || (MHOC303 == MIBLEsensors[XdrvMailbox.payload].type)) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("MI32: will set Time"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Will set Time"));
|
||||
MI32.state.sensor = XdrvMailbox.payload;
|
||||
MI32.mode.canScan = 0;
|
||||
MI32.mode.canConnect = 0;
|
||||
@ -1876,7 +1873,7 @@ void CmndMi32Unit(void) {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
if (MIBLEsensors.size() > XdrvMailbox.payload) {
|
||||
if ((LYWSD02 == MIBLEsensors[XdrvMailbox.payload].type) || (MHOC303 == MIBLEsensors[XdrvMailbox.payload].type)) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: will set Unit"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Will set Unit"));
|
||||
MI32.state.sensor = XdrvMailbox.payload;
|
||||
MI32.mode.canScan = 0;
|
||||
MI32.mode.canConnect = 0;
|
||||
@ -1926,11 +1923,11 @@ void CmndMi32Block(void){
|
||||
switch (XdrvMailbox.index) {
|
||||
case 0:
|
||||
MIBLEBlockList.clear();
|
||||
// AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: size of ilist: %u"), MIBLEBlockList.size());
|
||||
ResponseCmndIdxChar(PSTR("block list cleared"));
|
||||
// AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size());
|
||||
ResponseCmndIdxChar(PSTR("Block list cleared"));
|
||||
break;
|
||||
case 1:
|
||||
ResponseCmndIdxChar(PSTR("show block list"));
|
||||
ResponseCmndIdxChar(PSTR("Show block list"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1956,7 +1953,7 @@ void CmndMi32Block(void){
|
||||
ResponseCmndIdxChar(XdrvMailbox.data);
|
||||
MI32removeMIBLEsensor(_MACasBytes.buf);
|
||||
}
|
||||
// AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: size of ilist: %u"), MIBLEBlockList.size());
|
||||
// AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2323,4 +2320,4 @@ bool Xsns62(uint8_t function)
|
||||
}
|
||||
#endif // USE_MI_ESP32
|
||||
#endif // ESP32
|
||||
#endif
|
||||
#endif // USE_BLE_ESP32
|
Loading…
x
Reference in New Issue
Block a user