-
• #2
So you intend to call
jswrap_ESP32_get_Char_Value
when the ESP32 asks Espruino for the data inside a characteristic?Rather than:
jsvObjectIteratorNew(&serviceIt,servicesĀData); while(jsvObjectIteratorHasValue(&serviceĀIt)){ serviceKey = jsvObjectIteratorGetKey(&serviceIt); if(jsvIsEqual(serviceKey,serviceUUID)){ ...
You could just use:
serviceData = jsvSkipName(jsvFindChildFromVar(servicesData, serviceUUID, false)); if (serviceData) {
However one problem you have is UUIDs can be defined in different ways, eg
0xABCD, "ABCD", "AbCd"
- so maybe what you're doing is better - but usebleVarToUUID
and then compare the raw UUIDs, rather than usingjsvIsEqual
.you do say the ESP32 uses handles though? IMO it would probably be faster/easier to have a separate list of handle vs. value in
execInfo.hiddenRoot
instead? It might come in handy in other places - for instance I think notifications so something like that already?
During porting jswrap_nrf_bluetooth_updateServices to ESP32, I found calls to nrf relevant functions.
ESP32 uses different walks through all of this. Most common point is use of UUIDs and handles.
Searching for a better solution, found this jsvObjectGetChild(execInfo.hiddenRoot,"BLE_SVC_D",0);
Idea now is to move UUIDs and handles to this object to be more general. Value is already there.
For testing of concept, this function was born. In my eyes it looks very complex.
So I've 2 questions:
is there a better way to read value from BLE_SVC_D ?