@@ -598,6 +598,9 @@ received. It doesn't get called if NFC is started with `NRF.nfcURL` or
598
598
* 4 : coded phy
599
599
600
600
`status` is an integer containing the status code. 0 = success
601
+
602
+ **This is not part of the Web Bluetooth Specification.** It has been added
603
+ specifically for Espruino.
601
604
*/
602
605
/*JSON{
603
606
"type" : "event",
@@ -617,6 +620,9 @@ received. It doesn't get called if NFC is started with `NRF.nfcURL` or
617
620
* 4 : coded phy
618
621
619
622
eg. `7` means all phys (eg any) have been requested
623
+
624
+ **This is not part of the Web Bluetooth Specification.** It has been added
625
+ specifically for Espruino.
620
626
*/
621
627
/*JSON{
622
628
"type" : "event",
@@ -629,6 +635,9 @@ eg. `7` means all phys (eg any) have been requested
629
635
}
630
636
(2v28+) This event is fired when the MTU changes for the active Bluetooth connection. This is the amount of
631
637
data that can be transferred in one packet.
638
+
639
+ **This is not part of the Web Bluetooth Specification.** It has been added
640
+ specifically for Espruino.
632
641
*/
633
642
/*JSON{
634
643
"type" : "event",
@@ -1436,7 +1445,7 @@ it returns the packet that would be advertised as an array.
1436
1445
1437
1446
In addition, `options` can contain:
1438
1447
1439
- * [ 2v26+] `flags : bool` if `flags:false`, the Bluetooth appearance flags
1448
+ * ( 2v26+) `flags : bool` if `flags:false`, the Bluetooth appearance flags
1440
1449
are left out (usually `[2,1,6]`). It can be very useful to do this
1441
1450
if you're using `NRF.getAdvertisingData(...)` to set a scan response packet:
1442
1451
@@ -4065,6 +4074,9 @@ JsVar *jswrap_BluetoothDevice_gatt(JsVar *parent) {
4065
4074
"return" : ["bool", "The last received RSSI (signal strength) for this device" ]
4066
4075
}
4067
4076
This is set whenever the RSSI of the connection is changed. `BluetoothGATTServer.on("rssi", ...)` is also emitted.
4077
+
4078
+ **This is not part of the Web Bluetooth Specification.** It has been added
4079
+ specifically for Espruino.
4068
4080
*/
4069
4081
/*Documentation only*/
4070
4082
/*JSON{
@@ -4077,6 +4089,9 @@ This is set whenever the RSSI of the connection is changed. `BluetoothGATTServer
4077
4089
"ifdef" : "NRF52_SERIES"
4078
4090
}
4079
4091
This event is fired whenever the RSSI of the connection is changed. `BluetoothDevice.rssi` is also updated
4092
+
4093
+ **This is not part of the Web Bluetooth Specification.** It has been added
4094
+ specifically for Espruino.
4080
4095
*/
4081
4096
/*JSON{
4082
4097
"type" : "event",
@@ -4141,6 +4156,99 @@ void jswrap_ble_BluetoothDevice_sendPasskey(JsVar *parent, JsVar *passkeyVar) {
4141
4156
}
4142
4157
#endif
4143
4158
4159
+
4160
+ static void jsble_update_connection (uint16_t connection_handle , JsVar * options ){
4161
+ #ifdef NRF52_SERIES
4162
+ uint32_t err_code ;
4163
+ #if (NRF_SD_BLE_API_VERSION >= 5 )
4164
+ ble_gap_phys_t gap_phys ;
4165
+ uint8_t phy = BLE_GAP_PHY_NOT_SET ;
4166
+ JsVar * advPhy = jsvObjectGetChildIfExists (options , "phy" );
4167
+ if (jsvIsStringEqual (advPhy ,"1mbps" )) {
4168
+ phy = BLE_GAP_PHY_1MBPS ;
4169
+ } else if (jsvIsStringEqual (advPhy ,"2mbps" )) {
4170
+ phy = BLE_GAP_PHY_2MBPS ;
4171
+ } else if (jsvIsStringEqual (advPhy ,"auto" )) {
4172
+ phy = BLE_GAP_PHY_AUTO ;
4173
+ #if NRF_SD_BLE_API_VERSION > 5
4174
+ } else if (jsvIsStringEqual (advPhy ,"coded" )) {
4175
+ phy = BLE_GAP_PHY_CODED ;
4176
+ #endif
4177
+ } else jsWarn ("Unknown phy %q\n" , advPhy );
4178
+ jsvUnLock (advPhy );
4179
+ if (phy != BLE_GAP_PHY_NOT_SET ){
4180
+ gap_phys .rx_phys = phy ;
4181
+ gap_phys .tx_phys = phy ;
4182
+ err_code = sd_ble_gap_phy_update (connection_handle , & gap_phys );
4183
+ jsble_check_error (err_code );
4184
+ }
4185
+ #endif
4186
+ #endif
4187
+ #ifdef ESP32
4188
+ jsWarn ("update not implemented\n" );
4189
+ #endif
4190
+ }
4191
+
4192
+ /*JSON{
4193
+ "type" : "method",
4194
+ "class" : "BluetoothRemoteGATTServer",
4195
+ "name" : "updateConnection",
4196
+ "generate" : "jswrap_BluetoothRemoteGATTServer_updateConnection",
4197
+ "params" : [
4198
+ ["options","JsVar","An object containing connection options"]
4199
+ ],
4200
+ "#if" : "defined(NRF52_SERIES)"
4201
+ }
4202
+ (2v28+) Update connection parameters on this central connection. Options can be:
4203
+
4204
+ ```
4205
+ {
4206
+ phy : string // "1mpbs"/"2mpbs"/"coded"/"auto"
4207
+ }
4208
+ ```
4209
+
4210
+ **This is not part of the Web Bluetooth Specification.** It has been added
4211
+ specifically for Espruino.
4212
+ */
4213
+ void jswrap_BluetoothRemoteGATTServer_updateConnection (JsVar * parent , JsVar * options ) {
4214
+ #if CENTRAL_LINK_COUNT > 0
4215
+ uint16_t central_conn_handle = jswrap_ble_BluetoothRemoteGATTServer_getHandle (parent );
4216
+ if (jsvObjectGetBoolChild (parent ,"connected" ) && central_conn_handle != BLE_CONN_HANDLE_INVALID ) {
4217
+ // we have a connection, update it
4218
+ jsble_update_connection (central_conn_handle , options );
4219
+ } else {
4220
+ jsExceptionHere (JSET_ERROR , "Not connected" );
4221
+ }
4222
+ #endif
4223
+ }
4224
+
4225
+ /*JSON{
4226
+ "type" : "staticmethod",
4227
+ "class" : "NRF",
4228
+ "name" : "updateConnection",
4229
+ "ifdef" : "NRF52_SERIES",
4230
+ "generate" : "jswrap_ble_updateConnection",
4231
+ "params" : [
4232
+ ["options","JsVar","An object containing connection options"]
4233
+ ],
4234
+ "#if" : "defined(NRF52_SERIES)"
4235
+ }
4236
+ (2v28+) Update connection parameters on the current peripheral connection. Options can be:
4237
+
4238
+ ```
4239
+ {
4240
+ phy : string // "1mpbs"/"2mpbs"/"coded"/"auto"
4241
+ }
4242
+ ```
4243
+ */
4244
+ void jswrap_ble_updateConnection (JsVar * options ) {
4245
+ if (jsble_has_peripheral_connection ()) {
4246
+ jsble_update_connection (m_peripheral_conn_handle , options );
4247
+ }else {
4248
+ jsExceptionHere (JSET_ERROR , "Not connected" );
4249
+ }
4250
+ }
4251
+
4144
4252
/*JSON{
4145
4253
"type" : "method",
4146
4254
"class" : "BluetoothRemoteGATTServer",
0 commit comments