From d873cbb6c3b8d757cabe2378b74987208ec64dd5 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Wed, 30 Nov 2016 04:24:52 -0800 Subject: [PATCH] updated api definitions --- docs/reference/bluetooth/stop-advertising.md | 12 ++++++++---- libs/bluetooth/_locales/bluetooth-jsdoc-strings.json | 4 ++++ libs/bluetooth/_locales/bluetooth-strings.json | 2 ++ libs/bluetooth/bluetooth.cpp | 6 +++--- libs/bluetooth/bluetooth.ts | 9 --------- libs/bluetooth/shims.d.ts | 6 +++--- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/docs/reference/bluetooth/stop-advertising.md b/docs/reference/bluetooth/stop-advertising.md index 1f0c41c4..82ce25ba 100644 --- a/docs/reference/bluetooth/stop-advertising.md +++ b/docs/reference/bluetooth/stop-advertising.md @@ -21,14 +21,18 @@ Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/ bluetooth.stopAdvertising(); ``` +### Example: stop advertising on button pressed + +```blocks +input.onButtonPressed(Button.A, () => { + bluetooth.stopAdvertising(); +}) +``` + ## See Also [advertise-url](/reference/bluetooth/advertise-url) -```blocks -bluetooth.stopAdvertising(); -``` - ```package bluetooth ``` \ No newline at end of file diff --git a/libs/bluetooth/_locales/bluetooth-jsdoc-strings.json b/libs/bluetooth/_locales/bluetooth-jsdoc-strings.json index ca3ba8ef..b22f5b9c 100644 --- a/libs/bluetooth/_locales/bluetooth-jsdoc-strings.json +++ b/libs/bluetooth/_locales/bluetooth-jsdoc-strings.json @@ -1,5 +1,8 @@ { "bluetooth": "Support for additional Bluetooth services.", + "bluetooth.advertiseUrl": "Advertise an Eddystone URL", + "bluetooth.advertiseUrl|param|power": "power level between 0 and 7, e.g.: 7", + "bluetooth.advertiseUrl|param|url": "the url to transmit. Must be no longer than the supported eddystone url length", "bluetooth.onBluetoothConnected": "Register code to run when the micro:bit is connected to over Bluetooth", "bluetooth.onBluetoothConnected|param|body": "Code to run when a Bluetooth connection is established", "bluetooth.onBluetoothDisconnected": "Register code to run when a bluetooth connection to the micro:bit is lost", @@ -11,6 +14,7 @@ "bluetooth.startMagnetometerService": "Starts the Bluetooth magnetometer service", "bluetooth.startTemperatureService": "Starts the Bluetooth temperature service", "bluetooth.startUartService": "Starts the Bluetooth UART service", + "bluetooth.stopAdvertising": "Stops advertising Eddystone end points", "bluetooth.uartReadUntil": "Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.", "bluetooth.uartWriteNumber": "Prints a numeric value to the serial", "bluetooth.uartWriteString": "Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.", diff --git a/libs/bluetooth/_locales/bluetooth-strings.json b/libs/bluetooth/_locales/bluetooth-strings.json index ad894e0c..f4ac4022 100644 --- a/libs/bluetooth/_locales/bluetooth-strings.json +++ b/libs/bluetooth/_locales/bluetooth-strings.json @@ -1,4 +1,5 @@ { + "bluetooth.advertiseUrl|block": "bluetooth advertise url %url|with power %power", "bluetooth.onBluetoothConnected|block": "on bluetooth connected", "bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected", "bluetooth.startAccelerometerService|block": "bluetooth accelerometer service", @@ -8,6 +9,7 @@ "bluetooth.startMagnetometerService|block": "bluetooth magnetometer service", "bluetooth.startTemperatureService|block": "bluetooth temperature service", "bluetooth.startUartService|block": "bluetooth uart service", + "bluetooth.stopAdvertising|block": "bluetooth stop advertising", "bluetooth.uartReadUntil|block": "bluetooth uart|read until %del=serial_delimiter_conv", "bluetooth.uartWriteNumber|block": "bluetooth uart|write number %value", "bluetooth.uartWriteString|block": "bluetooth uart|write string %data", diff --git a/libs/bluetooth/bluetooth.cpp b/libs/bluetooth/bluetooth.cpp index 82424b74..37d217ac 100644 --- a/libs/bluetooth/bluetooth.cpp +++ b/libs/bluetooth/bluetooth.cpp @@ -127,8 +127,8 @@ namespace bluetooth { * @param url the url to transmit. Must be no longer than the supported eddystone url length * @param power power level between 0 and 7, e.g.: 7 */ - //% blockId=eddystone_advertise_url block="advertise url %url|power %power" - //% parts=bluetooth weight=11 + //% blockId=eddystone_advertise_url block="bluetooth advertise url %url|with power %power" + //% parts=bluetooth weight=11 blockGap=8 //% help=bluetooth/advertise-url void advertiseUrl(StringData* url, int power) { int8_t level = CALIBRATED_POWERS[min(7, max(0, power))]; @@ -138,7 +138,7 @@ namespace bluetooth { /** * Stops advertising Eddystone end points */ - //% blockId=eddystone_stop_advertising block="stop advertising" + //% blockId=eddystone_stop_advertising block="bluetooth stop advertising" //% parts=bluetooth weight=10 //% help=bluetooth/stop-advertising void stopAdvertising() { diff --git a/libs/bluetooth/bluetooth.ts b/libs/bluetooth/bluetooth.ts index 99af025c..3f480408 100644 --- a/libs/bluetooth/bluetooth.ts +++ b/libs/bluetooth/bluetooth.ts @@ -46,13 +46,4 @@ namespace bluetooth { // dummy implementation for simulator return "???" } - - //% shim=bluetooth::advertiseUrl - export function advertiseUrl(url: string, powerLevel: number) { - } - - //% shim=bluetooth::stopAdvertising - export function stopAdvertising() { - } - } diff --git a/libs/bluetooth/shims.d.ts b/libs/bluetooth/shims.d.ts index adce4f03..57d9e45b 100644 --- a/libs/bluetooth/shims.d.ts +++ b/libs/bluetooth/shims.d.ts @@ -86,15 +86,15 @@ declare namespace bluetooth { * @param url the url to transmit. Must be no longer than the supported eddystone url length * @param power power level between 0 and 7, e.g.: 7 */ - //% blockId=eddystone_advertise_url block="advertise url %url|power %power" - //% parts=bluetooth weight=11 + //% blockId=eddystone_advertise_url block="bluetooth advertise url %url|with power %power" + //% parts=bluetooth weight=11 blockGap=8 //% help=bluetooth/advertise-url shim=bluetooth::advertiseUrl function advertiseUrl(url: string, power: number): void; /** * Stops advertising Eddystone end points */ - //% blockId=eddystone_stop_advertising block="stop advertising" + //% blockId=eddystone_stop_advertising block="bluetooth stop advertising" //% parts=bluetooth weight=10 //% help=bluetooth/stop-advertising shim=bluetooth::stopAdvertising function stopAdvertising(): void;