mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
nRF5x: Store "connectable" flag in bleStatus
This saves some precious RAM :)
This commit is contained in:
parent
ed4961aee4
commit
de06eb15b6
@ -511,7 +511,8 @@ void jswrap_nrf_bluetooth_setAdvertising(JsVar *data, JsVar *options) {
|
||||
|
||||
v = jsvObjectGetChild(options, "connectable", 0);
|
||||
if (v) {
|
||||
bleConnectable = jsvGetBoolAndUnLock(v);
|
||||
if (jsvGetBoolAndUnLock(v)) bleStatus &= ~BLE_IS_NOT_CONNECTABLE;
|
||||
else bleStatus |= BLE_IS_NOT_CONNECTABLE;
|
||||
bleChanged = true;
|
||||
}
|
||||
|
||||
|
||||
@ -103,7 +103,6 @@ uint16_t m_central_conn_handle = BLE_CONN_HANDLE_INVALID
|
||||
bool nfcEnabled = false;
|
||||
#endif
|
||||
|
||||
bool bleConnectable = true;
|
||||
uint16_t bleAdvertisingInterval = ADVERTISING_INTERVAL;
|
||||
|
||||
volatile BLEStatus bleStatus = 0;
|
||||
@ -1463,7 +1462,7 @@ void jsble_advertising_start() {
|
||||
|
||||
ble_gap_adv_params_t adv_params;
|
||||
memset(&adv_params, 0, sizeof(adv_params));
|
||||
adv_params.type = bleConnectable ? BLE_GAP_ADV_TYPE_ADV_IND : BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
|
||||
adv_params.type = (bleStatus & BLE_IS_NOT_CONNECTABLE) ? BLE_GAP_ADV_TYPE_ADV_NONCONN_IND : BLE_GAP_ADV_TYPE_ADV_IND;
|
||||
adv_params.p_peer_addr = NULL;
|
||||
adv_params.fp = BLE_GAP_ADV_FP_ANY;
|
||||
adv_params.timeout = APP_ADV_TIMEOUT_IN_SECONDS;
|
||||
|
||||
@ -48,16 +48,16 @@ typedef enum {
|
||||
BLE_IS_RSSI_SCANNING = 256, // Are we scanning for RSSI values
|
||||
BLE_IS_SLEEPING = 512, // NRF.sleep has been called
|
||||
BLE_PM_INITIALISED = 1024, // Set when the Peer Manager has been initialised (only needs doing once, even after SD restart)
|
||||
BLE_IS_NOT_CONNECTABLE = 2048, // Is the device connectable?
|
||||
|
||||
BLE_IS_ADVERTISING_MULTIPLE = 2048, // We have multiple different advertising packets
|
||||
BLE_ADVERTISING_MULTIPLE_ONE = 4096,
|
||||
BLE_IS_ADVERTISING_MULTIPLE = 4096, // We have multiple different advertising packets
|
||||
BLE_ADVERTISING_MULTIPLE_ONE = 8192,
|
||||
BLE_ADVERTISING_MULTIPLE_SHIFT = GET_BIT_NUMBER(BLE_ADVERTISING_MULTIPLE_ONE),
|
||||
BLE_ADVERTISING_MULTIPLE_MASK = 255 << BLE_ADVERTISING_MULTIPLE_SHIFT,
|
||||
} BLEStatus;
|
||||
|
||||
|
||||
extern volatile BLEStatus bleStatus;
|
||||
extern bool bleConnectable; /**< whether the device is connectable */
|
||||
extern uint16_t bleAdvertisingInterval; /**< The advertising interval (in units of 0.625 ms). */
|
||||
extern uint16_t m_conn_handle; /**< Handle of the current connection. */
|
||||
#if CENTRAL_LINK_COUNT>0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user