mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 13:16:32 +00:00
make discoverAttributes optional
This commit is contained in:
parent
23e94c1aca
commit
f9c31bd8b8
@ -190,6 +190,7 @@ struct {
|
|||||||
uint32_t triggerBerryConnCB:1;
|
uint32_t triggerBerryConnCB:1;
|
||||||
uint32_t triggerNextConnJob:1;
|
uint32_t triggerNextConnJob:1;
|
||||||
uint32_t readyForNextConnJob:1;
|
uint32_t readyForNextConnJob:1;
|
||||||
|
uint32_t discoverAttributes:1;
|
||||||
};
|
};
|
||||||
uint32_t all = 0;
|
uint32_t all = 0;
|
||||||
} mode;
|
} mode;
|
||||||
|
@ -119,7 +119,7 @@ extern "C" {
|
|||||||
extern void MI32setBerryAdvCB(void* function, uint8_t *buffer);
|
extern void MI32setBerryAdvCB(void* function, uint8_t *buffer);
|
||||||
extern void MI32setBerryConnCB(void* function, uint8_t *buffer);
|
extern void MI32setBerryConnCB(void* function, uint8_t *buffer);
|
||||||
extern bool MI32runBerryConnection(uint8_t operation, bool response);
|
extern bool MI32runBerryConnection(uint8_t operation, bool response);
|
||||||
extern bool MI32setBerryCtxSvc(const char *Svc);
|
extern bool MI32setBerryCtxSvc(const char *Svc, bool discoverAttributes);
|
||||||
extern bool MI32setBerryCtxChr(const char *Chr);
|
extern bool MI32setBerryCtxChr(const char *Chr);
|
||||||
extern bool MI32setBerryCtxMAC(uint8_t *MAC, uint8_t type);
|
extern bool MI32setBerryCtxMAC(uint8_t *MAC, uint8_t type);
|
||||||
extern bool MI32addMACtoBlockList(uint8_t *MAC, uint8_t type);
|
extern bool MI32addMACtoBlockList(uint8_t *MAC, uint8_t type);
|
||||||
@ -175,8 +175,12 @@ extern "C" {
|
|||||||
int be_BLE_set_service(bvm *vm);
|
int be_BLE_set_service(bvm *vm);
|
||||||
int be_BLE_set_service(bvm *vm){
|
int be_BLE_set_service(bvm *vm){
|
||||||
int32_t argc = be_top(vm); // Get the number of arguments
|
int32_t argc = be_top(vm); // Get the number of arguments
|
||||||
if (argc == 2 && be_isstring(vm, 2)) {
|
if (argc > 1 && be_isstring(vm, 2)) {
|
||||||
if (MI32setBerryCtxSvc(be_tostring(vm, 2))) be_return(vm);
|
bool discoverAttributes = false;
|
||||||
|
if(argc == 3 && be_isint(vm, 3)){
|
||||||
|
discoverAttributes = be_toint(vm,3)>0;
|
||||||
|
}
|
||||||
|
if (MI32setBerryCtxSvc(be_tostring(vm, 2),discoverAttributes)) be_return(vm);
|
||||||
}
|
}
|
||||||
be_raise(vm, kTypeError, nullptr);
|
be_raise(vm, kTypeError, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -702,10 +702,11 @@ extern "C" {
|
|||||||
AddLog(LOG_LEVEL_INFO,PSTR("M32: Connection Ctx created"));
|
AddLog(LOG_LEVEL_INFO,PSTR("M32: Connection Ctx created"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MI32setBerryCtxSvc(const char *Svc){
|
bool MI32setBerryCtxSvc(const char *Svc, bool discoverAttributes){
|
||||||
if(MI32.conCtx != nullptr){
|
if(MI32.conCtx != nullptr){
|
||||||
MI32.conCtx->serviceUUID = NimBLEUUID(Svc);
|
MI32.conCtx->serviceUUID = NimBLEUUID(Svc);
|
||||||
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: SVC: %s"),MI32.conCtx->serviceUUID.toString().c_str());
|
AddLog(LOG_LEVEL_DEBUG,PSTR("M32: SVC: %s"),MI32.conCtx->serviceUUID.toString().c_str());
|
||||||
|
MI32.mode.discoverAttributes = discoverAttributes;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1182,8 +1183,9 @@ void MI32ConnectionTask(void *pvParameters){
|
|||||||
timer++;
|
timer++;
|
||||||
vTaskDelay(10/ portTICK_PERIOD_MS);
|
vTaskDelay(10/ portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
// TODO: make next line optional
|
if(MI32.mode.discoverAttributes){
|
||||||
// MI32Client->discoverAttributes(); // solves connection problems on i.e. yeelight dimmer
|
MI32Client->discoverAttributes(); // solves connection problems on i.e. yeelight dimmer
|
||||||
|
}
|
||||||
NimBLERemoteService* pSvc = nullptr;
|
NimBLERemoteService* pSvc = nullptr;
|
||||||
NimBLERemoteCharacteristic* pChr = nullptr;
|
NimBLERemoteCharacteristic* pChr = nullptr;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user