Merge remote-tracking branch 'origin/master' into ESP32

This commit is contained in:
wilberforce 2017-04-07 08:27:40 +12:00
commit f5d188c08d
6 changed files with 35 additions and 11 deletions

View File

@ -39,6 +39,8 @@
Increase max graphics size from 1023 to 32767
Add Fat File System to boards with large Flash (ESP32)
nRF52: Don't get stuck in 'HID Busy' state if a HID send failed
Change name of socket close internal variable so it doesn't conflict with Pipe's close call
Stop pipe from causing errors if fields of the requested names exist but aren't functions
1v91 : Fix recent regression if no Boot Code defined at startup
Fix handling of return of rejected promise within a promise

View File

@ -470,6 +470,7 @@ NRF.setAdvertising([
name: "Hello" // The name of the device
showName: true/false // include full name, or nothing
discoverable: true/false // general discoverable, or limited - default is limited
connectable: true/false // whether device is connectable - default is true
interval: 600 // Advertising interval in msec, between 20 and 10000
}
```
@ -508,6 +509,13 @@ void jswrap_nrf_bluetooth_setAdvertising(JsVar *data, JsVar *options) {
}
}
v = jsvObjectGetChild(options, "connectable", 0);
if (v) {
if (jsvGetBoolAndUnLock(v)) bleStatus &= ~BLE_IS_NOT_CONNECTABLE;
else bleStatus |= BLE_IS_NOT_CONNECTABLE;
bleChanged = true;
}
v = jsvObjectGetChild(options, "name", 0);
if (v) {
JSV_GET_AS_CHAR_ARRAY(namePtr, nameLen, v);
@ -685,6 +693,7 @@ NRF.setServices({
writable : true, // optional, default is false
notify : true, // optional, default is false
indicate : true, // optional, default is false
description: "My Characteristic", // optional, default is null
onWrite : function(evt) { // optional
console.log("Got ", evt.data);
}

View File

@ -29,9 +29,9 @@
#define HTTP_NAME_OPTIONS_VAR "opt"
#define HTTP_NAME_SERVER_VAR "svr"
#define HTTP_NAME_CHUNKED "chunked"
#define HTTP_NAME_CLOSENOW "closeNow" // boolean: gotta close
#define HTTP_NAME_CLOSENOW "clsNow" // boolean: gotta close
#define HTTP_NAME_CONNECTED "conn" // boolean: we are connected
#define HTTP_NAME_CLOSE "close" // close after sending
#define HTTP_NAME_CLOSE "cls" // close after sending
#define HTTP_NAME_ON_CONNECT JS_EVENT_PREFIX"connect"
#define HTTP_NAME_ON_CLOSE JS_EVENT_PREFIX"close"
#define HTTP_NAME_ON_END JS_EVENT_PREFIX"end"

View File

@ -69,14 +69,16 @@ static void handlePipeClose(JsVar *arr, JsvObjectIterator *it, JsVar* pipe) {
jswrap_object_removeAllListeners_cstr(destination, "close");
// execute the 'end' function
JsVar *endFunc = jspGetNamedField(destination, "end", false);
if (endFunc) {
jsvUnLock2(jspExecuteFunction(endFunc, destination, 0, 0), endFunc);
if (jsvIsFunction(endFunc)) {
jsvUnLock(jspExecuteFunction(endFunc, destination, 0, 0));
}
jsvUnLock(endFunc);
// execute the 'close' function
JsVar *closeFunc = jspGetNamedField(destination, "close", false);
if (closeFunc) {
jsvUnLock2(jspExecuteFunction(closeFunc, destination, 0, 0), closeFunc);
if (jsvIsFunction(closeFunc)) {
jsvUnLock(jspExecuteFunction(closeFunc, destination, 0, 0));
}
jsvUnLock(closeFunc);
}
/* call source.close if available - probably not what node does
but seems very sensible in this case. If you don't want it,
@ -86,9 +88,10 @@ static void handlePipeClose(JsVar *arr, JsvObjectIterator *it, JsVar* pipe) {
jswrap_object_removeAllListeners_cstr(source, "close");
// execute the 'close' function
JsVar *closeFunc = jspGetNamedField(source, "close", false);
if (closeFunc) {
jsvUnLock2(jspExecuteFunction(closeFunc, source, 0, 0), closeFunc);
if (jsvIsFunction(closeFunc)) {
jsvUnLock(jspExecuteFunction(closeFunc, source, 0, 0));
}
jsvUnLock(closeFunc);
}
}
jsvUnLock2(source, destination);

View File

@ -1462,7 +1462,7 @@ void jsble_advertising_start() {
ble_gap_adv_params_t adv_params;
memset(&adv_params, 0, sizeof(adv_params));
adv_params.type = BLE_GAP_ADV_TYPE_ADV_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;
@ -1654,6 +1654,7 @@ void jsble_set_services(JsVar *data) {
ble_gatts_attr_t attr_char_value;
ble_gatts_attr_md_t attr_md;
ble_gatts_char_handles_t characteristic_handles;
char description[32];
if ((errorStr=bleVarToUUIDAndUnLock(&char_uuid, jsvObjectIteratorGetKey(&serviceit)))) {
jsExceptionHere(JSET_ERROR, "Invalid Characteristic UUID: %s", errorStr);
@ -1679,6 +1680,14 @@ void jsble_set_services(JsVar *data) {
char_md.p_user_desc_md = NULL;
char_md.p_cccd_md = NULL;
char_md.p_sccd_md = NULL;
JsVar *charDescriptionVar = jsvObjectGetChild(charVar, "description", 0);
if (charDescriptionVar && jsvHasCharacterData(charDescriptionVar)) {
int8_t len = jsvGetString(charDescriptionVar, description, sizeof(description));
char_md.p_char_user_desc = (uint8_t *)description;
char_md.char_user_desc_size = len;
char_md.char_user_desc_max_size = len;
}
jsvUnLock(charDescriptionVar);
memset(&attr_md, 0, sizeof(attr_md));
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);

View File

@ -48,9 +48,10 @@ 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;