mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
fix regression in NRF.setServices caused by recent fix for loading them at boot time
This commit is contained in:
parent
218d155553
commit
a4268f8473
@ -152,6 +152,12 @@ void jswrap_nrf_init() {
|
||||
}
|
||||
// Set advertising interval back to default
|
||||
bleAdvertisingInterval = DEFAULT_ADVERTISING_INTERVAL;
|
||||
// Now set up whatever advertising we were doing before
|
||||
jswrap_nrf_reconfigure_softdevice();
|
||||
}
|
||||
|
||||
/** Reconfigure the softdevice (on init or after restart) to have all the services/advertising we need */
|
||||
void jswrap_nrf_reconfigure_softdevice() {
|
||||
// restart various
|
||||
JsVar *v,*o;
|
||||
v = jsvObjectGetChild(execInfo.root, BLE_SCAN_EVENT,0);
|
||||
@ -167,9 +173,8 @@ void jswrap_nrf_init() {
|
||||
jsvUnLock2(v,o);
|
||||
// services
|
||||
v = jsvObjectGetChild(execInfo.hiddenRoot, BLE_NAME_SERVICE_DATA, 0);
|
||||
o = jsvObjectGetChild(execInfo.hiddenRoot, BLE_NAME_SERVICE_OPTIONS, 0);
|
||||
if (v || o) jswrap_nrf_bluetooth_setServices(v, o);
|
||||
jsvUnLock2(v,o);
|
||||
if (v) jsble_set_services(v);
|
||||
jsvUnLock(v);
|
||||
// If we had scan response data set, update it
|
||||
JsVar *scanData = jsvObjectGetChild(execInfo.hiddenRoot, BLE_NAME_SCAN_RESPONSE_DATA, 0);
|
||||
if (scanData) jswrap_nrf_bluetooth_setScanResponse(scanData);
|
||||
@ -967,10 +972,11 @@ void jswrap_nrf_bluetooth_setServices(JsVar *data, JsVar *options) {
|
||||
// work out whether to apply changes
|
||||
if (bleStatus & (BLE_SERVICES_WERE_SET|BLE_NEEDS_SOFTDEVICE_RESTART)) {
|
||||
jswrap_nrf_bluetooth_restart();
|
||||
} else {
|
||||
/* otherwise, we can set the services now, since we're only adding
|
||||
* and not changing anything we don't need a restart. */
|
||||
jsble_set_services(data);
|
||||
}
|
||||
/* otherwise, we can set the services now, since we're only adding
|
||||
* and not changing anything we don't need a restart. */
|
||||
jsble_set_services(data);
|
||||
}
|
||||
|
||||
/*JSON{
|
||||
|
||||
@ -55,6 +55,8 @@ bool jswrap_nrf_idle();
|
||||
void jswrap_nrf_kill();
|
||||
// Used to dump bluetooth initialisation info for 'dump'
|
||||
void jswrap_nrf_dumpBluetoothInitialisation(vcbprintf_callback user_callback, void *user_data);
|
||||
/** Reconfigure the softdevice (on init or after restart) to have all the services/advertising we need */
|
||||
void jswrap_nrf_reconfigure_softdevice();
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@ -1582,6 +1582,8 @@ void jsble_restart_softdevice() {
|
||||
|
||||
jsble_kill();
|
||||
jsble_init();
|
||||
// reinitialise everything
|
||||
jswrap_nrf_reconfigure_softdevice();
|
||||
}
|
||||
|
||||
uint32_t jsble_set_scanning(bool enabled) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user