Skip to content

Commit 5d76771

Browse files
committed
Massive bluetooth name refactoring, potentially to help with #1445
1 parent 737dab0 commit 5d76771

File tree

9 files changed

+161
-160
lines changed

9 files changed

+161
-160
lines changed

libs/bluetooth/bluetooth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ typedef struct {
7878

7979
typedef enum {
8080
BLE_NONE = 0,
81-
BLE_IS_SENDING = 1, //< sending data with jswrap_nrf_transmit_string?
81+
BLE_IS_SENDING = 1, //< sending data with jswrap_ble_transmit_string?
8282
BLE_IS_SCANNING = 2, //< scanning for BLE devices?
8383
BLE_IS_ADVERTISING = 4, //< currently advertising info? stops when connected
8484
BLE_NEEDS_SOFTDEVICE_RESTART = 8, //< We need to reset the services we're reporting, but we can't because we're connected

libs/bluetooth/jswrap_bluetooth.c

Lines changed: 113 additions & 112 deletions
Large diffs are not rendered by default.

libs/bluetooth/jswrap_bluetooth.h

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,58 +51,58 @@ JsVar *bleGetActiveBluetoothGattServer();
5151
#endif
5252

5353
// ------------------------------------------------------------------------------
54-
void jswrap_nrf_init();
55-
bool jswrap_nrf_idle();
56-
void jswrap_nrf_kill();
54+
void jswrap_ble_init();
55+
bool jswrap_ble_idle();
56+
void jswrap_ble_kill();
5757
// Used to dump bluetooth initialisation info for 'dump'
58-
void jswrap_nrf_dumpBluetoothInitialisation(vcbprintf_callback user_callback, void *user_data);
58+
void jswrap_ble_dumpBluetoothInitialisation(vcbprintf_callback user_callback, void *user_data);
5959
/** Reconfigure the softdevice (on init or after restart) to have all the services/advertising we need */
60-
void jswrap_nrf_reconfigure_softdevice();
60+
void jswrap_ble_reconfigure_softdevice();
6161
// ------------------------------------------------------------------------------
6262

6363

64-
void jswrap_nrf_bluetooth_disconnect();
65-
void jswrap_nrf_bluetooth_sleep();
66-
void jswrap_nrf_bluetooth_wake();
67-
void jswrap_nrf_bluetooth_restart();
68-
JsVar *jswrap_nrf_bluetooth_getAddress();
69-
void jswrap_nrf_bluetooth_setAddress(JsVar *address);
64+
void jswrap_ble_disconnect();
65+
void jswrap_ble_sleep();
66+
void jswrap_ble_wake();
67+
void jswrap_ble_restart();
68+
JsVar *jswrap_ble_getAddress();
69+
void jswrap_ble_setAddress(JsVar *address);
7070

71-
JsVarFloat jswrap_nrf_bluetooth_getBattery();
72-
void jswrap_nrf_bluetooth_setAdvertising(JsVar *data, JsVar *options);
73-
JsVar *jswrap_nrf_bluetooth_getAdvertisingData(JsVar *data, JsVar *options);
74-
void jswrap_nrf_bluetooth_setScanResponse(JsVar *data);
75-
void jswrap_nrf_bluetooth_setServices(JsVar *data, JsVar *options);
76-
void jswrap_nrf_bluetooth_updateServices(JsVar *data);
77-
void jswrap_nrf_bluetooth_setScan(JsVar *callback, JsVar *options);
78-
void jswrap_nrf_bluetooth_findDevices(JsVar *callback, JsVar *options);
79-
void jswrap_nrf_bluetooth_setRSSIHandler(JsVar *callback);
80-
void jswrap_nrf_bluetooth_setTxPower(JsVarInt pwr);
81-
void jswrap_nrf_bluetooth_setLowPowerConnection(bool lowPower);
71+
JsVarFloat jswrap_ble_getBattery();
72+
void jswrap_ble_setAdvertising(JsVar *data, JsVar *options);
73+
JsVar *jswrap_ble_getAdvertisingData(JsVar *data, JsVar *options);
74+
void jswrap_ble_setScanResponse(JsVar *data);
75+
void jswrap_ble_setServices(JsVar *data, JsVar *options);
76+
void jswrap_ble_updateServices(JsVar *data);
77+
void jswrap_ble_setScan(JsVar *callback, JsVar *options);
78+
void jswrap_ble_findDevices(JsVar *callback, JsVar *options);
79+
void jswrap_ble_setRSSIHandler(JsVar *callback);
80+
void jswrap_ble_setTxPower(JsVarInt pwr);
81+
void jswrap_ble_setLowPowerConnection(bool lowPower);
8282

83-
void jswrap_nrf_nfcURL(JsVar *url);
84-
void jswrap_nrf_nfcRaw(JsVar *payload);
85-
JsVar *jswrap_nrf_nfcStart(JsVar *payload);
86-
void jswrap_nrf_nfcStop();
87-
void jswrap_nrf_nfcSend(JsVar *payload);
88-
void jswrap_nrf_sendHIDReport(JsVar *data, JsVar *callback);
83+
void jswrap_nfc_URL(JsVar *url);
84+
void jswrap_nfc_raw(JsVar *payload);
85+
JsVar *jswrap_nfc_start(JsVar *payload);
86+
void jswrap_nfc_stop();
87+
void jswrap_nfc_send(JsVar *payload);
88+
void jswrap_ble_sendHIDReport(JsVar *data, JsVar *callback);
8989

90-
JsVar *jswrap_nrf_bluetooth_requestDevice(JsVar *options);
91-
JsVar *jswrap_nrf_bluetooth_connect(JsVar *mac, JsVar *options);
92-
void jswrap_nrf_setWhitelist(bool whitelist);
93-
void jswrap_nrf_setConnectionInterval(JsVar *interval);
90+
JsVar *jswrap_ble_requestDevice(JsVar *options);
91+
JsVar *jswrap_ble_connect(JsVar *mac, JsVar *options);
92+
void jswrap_ble_setWhitelist(bool whitelist);
93+
void jswrap_ble_setConnectionInterval(JsVar *interval);
9494

9595
JsVar *jswrap_BluetoothDevice_gatt(JsVar *parent);
96-
JsVar *jswrap_nrf_BluetoothRemoteGATTServer_connect(JsVar *parent, JsVar *options);
96+
JsVar *jswrap_ble_BluetoothRemoteGATTServer_connect(JsVar *parent, JsVar *options);
9797
void jswrap_BluetoothRemoteGATTServer_disconnect(JsVar *parent);
98-
JsVar *jswrap_nrf_BluetoothRemoteGATTServer_startBonding(JsVar *parent, bool forceRePair);
99-
JsVar *jswrap_nrf_BluetoothRemoteGATTServer_getSecurityStatus(JsVar *parent);
98+
JsVar *jswrap_ble_BluetoothRemoteGATTServer_startBonding(JsVar *parent, bool forceRePair);
99+
JsVar *jswrap_ble_BluetoothRemoteGATTServer_getSecurityStatus(JsVar *parent);
100100
JsVar *jswrap_BluetoothRemoteGATTServer_getPrimaryService(JsVar *parent, JsVar *service);
101101
JsVar *jswrap_BluetoothRemoteGATTServer_getPrimaryServices(JsVar *parent);
102102
void jswrap_BluetoothRemoteGATTServer_setRSSIHandler(JsVar *parent, JsVar *callback);
103103
JsVar *jswrap_BluetoothRemoteGATTService_getCharacteristic(JsVar *parent, JsVar *characteristic);
104104
JsVar *jswrap_BluetoothRemoteGATTService_getCharacteristics(JsVar *parent);
105-
JsVar *jswrap_nrf_BluetoothRemoteGATTCharacteristic_writeValue(JsVar *characteristic, JsVar *data);
106-
JsVar *jswrap_nrf_BluetoothRemoteGATTCharacteristic_readValue(JsVar *characteristic);
107-
JsVar *jswrap_nrf_BluetoothRemoteGATTCharacteristic_startNotifications(JsVar *characteristic);
108-
JsVar *jswrap_nrf_BluetoothRemoteGATTCharacteristic_stopNotifications(JsVar *characteristic);
105+
JsVar *jswrap_ble_BluetoothRemoteGATTCharacteristic_writeValue(JsVar *characteristic, JsVar *data);
106+
JsVar *jswrap_ble_BluetoothRemoteGATTCharacteristic_readValue(JsVar *characteristic);
107+
JsVar *jswrap_ble_BluetoothRemoteGATTCharacteristic_startNotifications(JsVar *characteristic);
108+
JsVar *jswrap_ble_BluetoothRemoteGATTCharacteristic_stopNotifications(JsVar *characteristic);

libs/hexbadge/jswrap_hexbadge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Return an approximate battery percentage remaining based on
198198
a normal CR2032 battery (2.8 - 2.2v)
199199
*/
200200
int jswrap_badge_getBatteryPercentage() {
201-
JsVarFloat v = jswrap_nrf_bluetooth_getBattery();
201+
JsVarFloat v = jswrap_ble_getBattery();
202202
int pc = (v-2.2)*100/0.6;
203203
if (pc>100) pc=100;
204204
if (pc<0) pc=0;

libs/pixljs/jswrap_pixljs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ void jswrap_pixljs_init() {
540540
}
541541
graphicsDrawString(&gfx,28,39,JS_VERSION);
542542
// Write MAC address in bottom right
543-
JsVar *addr = jswrap_nrf_bluetooth_getAddress();
543+
JsVar *addr = jswrap_ble_getAddress();
544544
char buf[20];
545545
jsvGetString(addr, buf, sizeof(buf));
546546
jsvUnLock(addr);

libs/puckjs/jswrap_puck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ JsVarFloat jswrap_puck_light() {
523523
delay = 50000;
524524
jshDelayMicroseconds(delay);
525525
}
526-
JsVarFloat v = jswrap_nrf_bluetooth_getBattery();
526+
JsVarFloat v = jswrap_ble_getBattery();
527527
JsVarFloat f = jshPinAnalog(LED1_PININDEX)*v/(3*0.45);
528528
if (f>1) f=1;
529529
// turn the red LED back on if it was on before

src/jsinteractive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ void jsiDumpHardwareInitialisation(vcbprintf_callback user_callback, void *user_
711711
}
712712
#ifdef BLUETOOTH
713713
if (humanReadableDump)
714-
jswrap_nrf_dumpBluetoothInitialisation(user_callback, user_data);
714+
jswrap_ble_dumpBluetoothInitialisation(user_callback, user_data);
715715
#endif
716716
}
717717

targets/esp32/bluetooth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void jsble_restart_softdevice(){
8484
if (bleStatus & BLE_IS_SCANNING) {
8585
bluetooth_gap_setScan(false);
8686
}
87-
jswrap_nrf_reconfigure_softdevice();
87+
jswrap_ble_reconfigure_softdevice();
8888
}
8989

9090
void jsble_advertising_start(){

targets/nrf5x/bluetooth.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,12 +2208,12 @@ void jsble_advertising_stop() {
22082208
advertising_init();
22092209
conn_params_init();
22102210

2211-
jswrap_nrf_bluetooth_wake();
2211+
jswrap_ble_wake();
22122212
}
22132213

22142214
/** Completely deinitialise the BLE stack */
22152215
void jsble_kill() {
2216-
jswrap_nrf_bluetooth_sleep();
2216+
jswrap_ble_sleep();
22172217

22182218
// BLE NUS doesn't need deinitialising (no ble_nus_kill)
22192219
bleStatus &= ~BLE_NUS_INITED;
@@ -2241,7 +2241,7 @@ void jsble_restart_softdevice() {
22412241
jsble_kill();
22422242
jsble_init();
22432243
// reinitialise everything
2244-
jswrap_nrf_reconfigure_softdevice();
2244+
jswrap_ble_reconfigure_softdevice();
22452245
}
22462246

22472247
uint32_t jsble_set_scanning(bool enabled) {

0 commit comments

Comments
 (0)