Skip to content

Commit

Permalink
Massive bluetooth name refactoring, potentially to help with #1445
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Sep 3, 2018
1 parent 737dab0 commit 5d76771
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 160 deletions.
2 changes: 1 addition & 1 deletion libs/bluetooth/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ typedef struct {

typedef enum {
BLE_NONE = 0,
BLE_IS_SENDING = 1, //< sending data with jswrap_nrf_transmit_string?
BLE_IS_SENDING = 1, //< sending data with jswrap_ble_transmit_string?
BLE_IS_SCANNING = 2, //< scanning for BLE devices?
BLE_IS_ADVERTISING = 4, //< currently advertising info? stops when connected
BLE_NEEDS_SOFTDEVICE_RESTART = 8, //< We need to reset the services we're reporting, but we can't because we're connected
Expand Down
225 changes: 113 additions & 112 deletions libs/bluetooth/jswrap_bluetooth.c

Large diffs are not rendered by default.

78 changes: 39 additions & 39 deletions libs/bluetooth/jswrap_bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,58 +51,58 @@ JsVar *bleGetActiveBluetoothGattServer();
#endif

// ------------------------------------------------------------------------------
void jswrap_nrf_init();
bool jswrap_nrf_idle();
void jswrap_nrf_kill();
void jswrap_ble_init();
bool jswrap_ble_idle();
void jswrap_ble_kill();
// Used to dump bluetooth initialisation info for 'dump'
void jswrap_nrf_dumpBluetoothInitialisation(vcbprintf_callback user_callback, void *user_data);
void jswrap_ble_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();
void jswrap_ble_reconfigure_softdevice();
// ------------------------------------------------------------------------------


void jswrap_nrf_bluetooth_disconnect();
void jswrap_nrf_bluetooth_sleep();
void jswrap_nrf_bluetooth_wake();
void jswrap_nrf_bluetooth_restart();
JsVar *jswrap_nrf_bluetooth_getAddress();
void jswrap_nrf_bluetooth_setAddress(JsVar *address);
void jswrap_ble_disconnect();
void jswrap_ble_sleep();
void jswrap_ble_wake();
void jswrap_ble_restart();
JsVar *jswrap_ble_getAddress();
void jswrap_ble_setAddress(JsVar *address);

JsVarFloat jswrap_nrf_bluetooth_getBattery();
void jswrap_nrf_bluetooth_setAdvertising(JsVar *data, JsVar *options);
JsVar *jswrap_nrf_bluetooth_getAdvertisingData(JsVar *data, JsVar *options);
void jswrap_nrf_bluetooth_setScanResponse(JsVar *data);
void jswrap_nrf_bluetooth_setServices(JsVar *data, JsVar *options);
void jswrap_nrf_bluetooth_updateServices(JsVar *data);
void jswrap_nrf_bluetooth_setScan(JsVar *callback, JsVar *options);
void jswrap_nrf_bluetooth_findDevices(JsVar *callback, JsVar *options);
void jswrap_nrf_bluetooth_setRSSIHandler(JsVar *callback);
void jswrap_nrf_bluetooth_setTxPower(JsVarInt pwr);
void jswrap_nrf_bluetooth_setLowPowerConnection(bool lowPower);
JsVarFloat jswrap_ble_getBattery();
void jswrap_ble_setAdvertising(JsVar *data, JsVar *options);
JsVar *jswrap_ble_getAdvertisingData(JsVar *data, JsVar *options);
void jswrap_ble_setScanResponse(JsVar *data);
void jswrap_ble_setServices(JsVar *data, JsVar *options);
void jswrap_ble_updateServices(JsVar *data);
void jswrap_ble_setScan(JsVar *callback, JsVar *options);
void jswrap_ble_findDevices(JsVar *callback, JsVar *options);
void jswrap_ble_setRSSIHandler(JsVar *callback);
void jswrap_ble_setTxPower(JsVarInt pwr);
void jswrap_ble_setLowPowerConnection(bool lowPower);

void jswrap_nrf_nfcURL(JsVar *url);
void jswrap_nrf_nfcRaw(JsVar *payload);
JsVar *jswrap_nrf_nfcStart(JsVar *payload);
void jswrap_nrf_nfcStop();
void jswrap_nrf_nfcSend(JsVar *payload);
void jswrap_nrf_sendHIDReport(JsVar *data, JsVar *callback);
void jswrap_nfc_URL(JsVar *url);
void jswrap_nfc_raw(JsVar *payload);
JsVar *jswrap_nfc_start(JsVar *payload);
void jswrap_nfc_stop();
void jswrap_nfc_send(JsVar *payload);
void jswrap_ble_sendHIDReport(JsVar *data, JsVar *callback);

JsVar *jswrap_nrf_bluetooth_requestDevice(JsVar *options);
JsVar *jswrap_nrf_bluetooth_connect(JsVar *mac, JsVar *options);
void jswrap_nrf_setWhitelist(bool whitelist);
void jswrap_nrf_setConnectionInterval(JsVar *interval);
JsVar *jswrap_ble_requestDevice(JsVar *options);
JsVar *jswrap_ble_connect(JsVar *mac, JsVar *options);
void jswrap_ble_setWhitelist(bool whitelist);
void jswrap_ble_setConnectionInterval(JsVar *interval);

JsVar *jswrap_BluetoothDevice_gatt(JsVar *parent);
JsVar *jswrap_nrf_BluetoothRemoteGATTServer_connect(JsVar *parent, JsVar *options);
JsVar *jswrap_ble_BluetoothRemoteGATTServer_connect(JsVar *parent, JsVar *options);
void jswrap_BluetoothRemoteGATTServer_disconnect(JsVar *parent);
JsVar *jswrap_nrf_BluetoothRemoteGATTServer_startBonding(JsVar *parent, bool forceRePair);
JsVar *jswrap_nrf_BluetoothRemoteGATTServer_getSecurityStatus(JsVar *parent);
JsVar *jswrap_ble_BluetoothRemoteGATTServer_startBonding(JsVar *parent, bool forceRePair);
JsVar *jswrap_ble_BluetoothRemoteGATTServer_getSecurityStatus(JsVar *parent);
JsVar *jswrap_BluetoothRemoteGATTServer_getPrimaryService(JsVar *parent, JsVar *service);
JsVar *jswrap_BluetoothRemoteGATTServer_getPrimaryServices(JsVar *parent);
void jswrap_BluetoothRemoteGATTServer_setRSSIHandler(JsVar *parent, JsVar *callback);
JsVar *jswrap_BluetoothRemoteGATTService_getCharacteristic(JsVar *parent, JsVar *characteristic);
JsVar *jswrap_BluetoothRemoteGATTService_getCharacteristics(JsVar *parent);
JsVar *jswrap_nrf_BluetoothRemoteGATTCharacteristic_writeValue(JsVar *characteristic, JsVar *data);
JsVar *jswrap_nrf_BluetoothRemoteGATTCharacteristic_readValue(JsVar *characteristic);
JsVar *jswrap_nrf_BluetoothRemoteGATTCharacteristic_startNotifications(JsVar *characteristic);
JsVar *jswrap_nrf_BluetoothRemoteGATTCharacteristic_stopNotifications(JsVar *characteristic);
JsVar *jswrap_ble_BluetoothRemoteGATTCharacteristic_writeValue(JsVar *characteristic, JsVar *data);
JsVar *jswrap_ble_BluetoothRemoteGATTCharacteristic_readValue(JsVar *characteristic);
JsVar *jswrap_ble_BluetoothRemoteGATTCharacteristic_startNotifications(JsVar *characteristic);
JsVar *jswrap_ble_BluetoothRemoteGATTCharacteristic_stopNotifications(JsVar *characteristic);
2 changes: 1 addition & 1 deletion libs/hexbadge/jswrap_hexbadge.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Return an approximate battery percentage remaining based on
a normal CR2032 battery (2.8 - 2.2v)
*/
int jswrap_badge_getBatteryPercentage() {
JsVarFloat v = jswrap_nrf_bluetooth_getBattery();
JsVarFloat v = jswrap_ble_getBattery();
int pc = (v-2.2)*100/0.6;
if (pc>100) pc=100;
if (pc<0) pc=0;
Expand Down
2 changes: 1 addition & 1 deletion libs/pixljs/jswrap_pixljs.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ void jswrap_pixljs_init() {
}
graphicsDrawString(&gfx,28,39,JS_VERSION);
// Write MAC address in bottom right
JsVar *addr = jswrap_nrf_bluetooth_getAddress();
JsVar *addr = jswrap_ble_getAddress();
char buf[20];
jsvGetString(addr, buf, sizeof(buf));
jsvUnLock(addr);
Expand Down
2 changes: 1 addition & 1 deletion libs/puckjs/jswrap_puck.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ JsVarFloat jswrap_puck_light() {
delay = 50000;
jshDelayMicroseconds(delay);
}
JsVarFloat v = jswrap_nrf_bluetooth_getBattery();
JsVarFloat v = jswrap_ble_getBattery();
JsVarFloat f = jshPinAnalog(LED1_PININDEX)*v/(3*0.45);
if (f>1) f=1;
// turn the red LED back on if it was on before
Expand Down
2 changes: 1 addition & 1 deletion src/jsinteractive.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ void jsiDumpHardwareInitialisation(vcbprintf_callback user_callback, void *user_
}
#ifdef BLUETOOTH
if (humanReadableDump)
jswrap_nrf_dumpBluetoothInitialisation(user_callback, user_data);
jswrap_ble_dumpBluetoothInitialisation(user_callback, user_data);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion targets/esp32/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void jsble_restart_softdevice(){
if (bleStatus & BLE_IS_SCANNING) {
bluetooth_gap_setScan(false);
}
jswrap_nrf_reconfigure_softdevice();
jswrap_ble_reconfigure_softdevice();
}

void jsble_advertising_start(){
Expand Down
6 changes: 3 additions & 3 deletions targets/nrf5x/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2208,12 +2208,12 @@ void jsble_advertising_stop() {
advertising_init();
conn_params_init();

jswrap_nrf_bluetooth_wake();
jswrap_ble_wake();
}

/** Completely deinitialise the BLE stack */
void jsble_kill() {
jswrap_nrf_bluetooth_sleep();
jswrap_ble_sleep();

// BLE NUS doesn't need deinitialising (no ble_nus_kill)
bleStatus &= ~BLE_NUS_INITED;
Expand Down Expand Up @@ -2241,7 +2241,7 @@ void jsble_restart_softdevice() {
jsble_kill();
jsble_init();
// reinitialise everything
jswrap_nrf_reconfigure_softdevice();
jswrap_ble_reconfigure_softdevice();
}

uint32_t jsble_set_scanning(bool enabled) {
Expand Down

0 comments on commit 5d76771

Please sign in to comment.