From a7e98ccb3d87c98b02bbfa7e8cb7913fe3305d0a Mon Sep 17 00:00:00 2001 From: guillaumejenkins Date: Wed, 21 Dec 2016 12:31:00 -0800 Subject: [PATCH 1/8] Change default product names for Electron app; Add release manifest --- .gitignore | 2 +- electron/product.json | 12 ++++++------ electron/release.json | 9 +++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 electron/release.json diff --git a/.gitignore b/.gitignore index b98318c0..b3b616ae 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ clients/win10/app/bld clients/win10/*.opendb clients/**/bin/** clients/**/obj/** -clients/electron/projects +electron-out hexcache *.user diff --git a/electron/product.json b/electron/product.json index 96e738d8..7424cd56 100644 --- a/electron/product.json +++ b/electron/product.json @@ -2,13 +2,13 @@ "applicationName": "pxt-microbit-oss", "dataFolderName": ".pxt-microbit-oss", "darwinBundleIdentifier": "com.microsoft.pxtmicrobitoss", - "nameShort": "PXT Microbit - OSS", - "nameLong": "PXT Microbit - OSS", + "nameShort": "PXT microbit - OSS", + "nameLong": "PXT micro:bit - OSS", "targetId": "pxt-microbit", "win32AppId": "{{92db071a-6f58-4938-8c97-13c873f4da13}", - "win32AppUserModelId": "Microsoft.PXTMicrobitOss", - "win32DirName": "Microsoft PXT-Microbit - OSS", + "win32AppUserModelId": "Microsoft.PXTmicrobitOss", + "win32DirName": "Microsoft PXT microbit - OSS", "win32MutexName": "pxtmicrobitoss", - "win32NameVersion": "Microsoft PXT-Microbit-OSS", - "win32RegValueName": "PXTMicrobitOss" + "win32NameVersion": "Microsoft PXT microbit-OSS", + "win32RegValueName": "PXTmicrobitOss" } \ No newline at end of file diff --git a/electron/release.json b/electron/release.json new file mode 100644 index 00000000..e311f179 --- /dev/null +++ b/electron/release.json @@ -0,0 +1,9 @@ +{ + "versions": { + "0": { + "latest": "v0.6.45", + "banned": [], + "prompt": "v0.0.0" + } + } +} \ No newline at end of file From 03c2df327703cf0ec61cf4bf887fdf42a6febcde Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 22 Dec 2016 11:31:50 -0800 Subject: [PATCH 2/8] fixed default projects --- libs/blocksprj/main.blocks | 2 +- libs/bluetoothprj/main.blocks | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/blocksprj/main.blocks b/libs/blocksprj/main.blocks index 5773d9b9..cf17f1bb 100644 --- a/libs/blocksprj/main.blocks +++ b/libs/blocksprj/main.blocks @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/libs/bluetoothprj/main.blocks b/libs/bluetoothprj/main.blocks index 5773d9b9..cf17f1bb 100644 --- a/libs/bluetoothprj/main.blocks +++ b/libs/bluetoothprj/main.blocks @@ -1,3 +1,3 @@ - + \ No newline at end of file From 780d8bcf8d3e7d0cc0e29b1e52e9d07590e784a2 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 22 Dec 2016 11:35:56 -0800 Subject: [PATCH 3/8] Bump pxt-core to 0.7.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7c59dde3..0600b395 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,6 @@ "semantic-ui-less": "^2.2.4" }, "dependencies": { - "pxt-core": "0.7.5" + "pxt-core": "0.7.6" } } From ec3a805326a9ed34e9f0ba11e0d123a1016418bd Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 22 Dec 2016 11:35:58 -0800 Subject: [PATCH 4/8] 0.7.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0600b395..6b380cd5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.7.4", + "version": "0.7.5", "description": "micro:bit target for PXT", "keywords": [ "JavaScript", From 35483487af9e54a50076249c1ccee3f1525b0dee Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 22 Dec 2016 23:18:32 -0800 Subject: [PATCH 5/8] Bump pxt-core to 0.7.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b380cd5..cfabef6b 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,6 @@ "semantic-ui-less": "^2.2.4" }, "dependencies": { - "pxt-core": "0.7.6" + "pxt-core": "0.7.9" } } From 141cb24e3dbb73952078a5435a56e15b359ac7ab Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 22 Dec 2016 23:18:35 -0800 Subject: [PATCH 6/8] 0.7.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cfabef6b..9d2e2642 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.7.5", + "version": "0.7.6", "description": "micro:bit target for PXT", "keywords": [ "JavaScript", From 2da0cf1178ea121cdef2277d59d9cf88378d5e6b Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 23 Dec 2016 08:58:38 -0800 Subject: [PATCH 7/8] support for buffer signature (#325) --- docs/reference/bluetooth.md | 3 +- .../bluetooth/advertise-uid-buffer.md | 37 +++++++++++++++ docs/reference/bluetooth/advertise-uid.md | 46 +++++++++++++++++++ docs/reference/bluetooth/advertise-url.md | 7 +-- .../_locales/bluetooth-jsdoc-strings.json | 9 ++++ .../bluetooth/_locales/bluetooth-strings.json | 1 + libs/bluetooth/bluetooth.cpp | 18 ++++++++ libs/bluetooth/bluetooth.ts | 17 +++++++ libs/bluetooth/pxt.json | 2 +- libs/bluetooth/shims.d.ts | 9 ++++ sim/state/misc.ts | 1 + 11 files changed, 145 insertions(+), 5 deletions(-) create mode 100644 docs/reference/bluetooth/advertise-uid-buffer.md create mode 100644 docs/reference/bluetooth/advertise-uid.md diff --git a/docs/reference/bluetooth.md b/docs/reference/bluetooth.md index 99ce0a45..29750895 100644 --- a/docs/reference/bluetooth.md +++ b/docs/reference/bluetooth.md @@ -35,7 +35,8 @@ bluetooth.uartWriteValue("", 0); ## Eddystone ```cards -bluetooth.advertiseUrl("https://pxt.microbit.org/", 7); +bluetooth.advertiseUid(42, 1, 7, true); +bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true); bluetooth.stopAdvertising(); ``` diff --git a/docs/reference/bluetooth/advertise-uid-buffer.md b/docs/reference/bluetooth/advertise-uid-buffer.md new file mode 100644 index 00000000..da388403 --- /dev/null +++ b/docs/reference/bluetooth/advertise-uid-buffer.md @@ -0,0 +1,37 @@ +# Avertise UID Buffer + +Advertises a UID via the Eddystone protocol over Bluetooth. + +## ~hint + +### Eddystone + +Bluetooth beacons are used to indicate proximity to a place or object of interest. +Beacons use Bluetooth advertising to broadcast a small amount of data, +which can be received and acted upon by anyone in range with a suitable device and software, typically a smartphone and application. + +There are various beacon message formats, which define the way Bluetooth advertising packets are used as containers for beacon data. +iBeacon is Apple's beacon message format. Eddystone comes from Google. + +Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/ . + +## ~ + +```sig +bluetooth.advertiseUidBuffer(pins.createBuffer(16), 7, true); +``` + +### Parameters + +* ``buffer`` - a 16 bytes buffer containing the namespace (first 10 bytes) and instance (last 6 bytes). +* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range). +* ``connectable`` - a [boolean](/reference/type/boolean) indicating whether or not the micro:bit should accept connections. + + +## See Also + +[stop-advertising](/reference/bluetooth/stop-advertising), [advertise-uid](/reference/bluetooth/advertise-uid) + +```package +bluetooth +``` diff --git a/docs/reference/bluetooth/advertise-uid.md b/docs/reference/bluetooth/advertise-uid.md new file mode 100644 index 00000000..942e5b20 --- /dev/null +++ b/docs/reference/bluetooth/advertise-uid.md @@ -0,0 +1,46 @@ +# Avertise UID + +Advertises a UID via the Eddystone protocol over Bluetooth. + +## ~hint + +### Eddystone + +Bluetooth beacons are used to indicate proximity to a place or object of interest. +Beacons use Bluetooth advertising to broadcast a small amount of data, +which can be received and acted upon by anyone in range with a suitable device and software, typically a smartphone and application. + +There are various beacon message formats, which define the way Bluetooth advertising packets are used as containers for beacon data. +iBeacon is Apple's beacon message format. Eddystone comes from Google. + +Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/ . + +## ~ + +```sig +bluetooth.advertiseUid(42, 1, 7, true); +``` + +### Parameters + +* ``namespace`` last 4 bytes of the namespace uid (6 to 9) +* ``instance`` last 4 bytes of the instance (2 to 5) +* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range). +* ``connectable`` - a [boolean](/reference/type/boolean) indicating whether or not the micro:bit should accept connections. + +## Encoding + +The bytes of ``namespace`` and ``instance`` are encoded to generate the 10 bytes UID namespace and 6 bytes UID instance. + +``` +UID namespace: [0, ..., namespace] +UID instance: [0, ..., instance] +``` + +## See Also + +[stop-advertising](/reference/bluetooth/stop-advertising), [advertise-uid-buffer](/reference/bluetooth/advertise-uid-buffer) + +```package +bluetooth +``` diff --git a/docs/reference/bluetooth/advertise-url.md b/docs/reference/bluetooth/advertise-url.md index 852f4090..4f261e86 100644 --- a/docs/reference/bluetooth/advertise-url.md +++ b/docs/reference/bluetooth/advertise-url.md @@ -18,23 +18,24 @@ Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/ ## ~ ```sig -bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true); +bluetooth.advertiseUrl("https://pxt.microbit.org/", true); ``` ### Parameters * ``url`` - a [string](/reference/types/string) containing the URL to broadcast, at most 17 characters long, excluding the protocol (eg: ``https://``) which gets encoded as 1 byte. * ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range). +* ``connectable`` - a [boolean](/reference/type/boolean) indicating whether or not the micro:bit should accept connections. ### Example: Broadcast a secret code ```blocks -bluetooth.advertiseUrl("https://pxt.io?secret=42", 7, true); +bluetooth.advertiseUrl("https://pxt.io?secret=42", true); ``` ## See Also -[stop-advertising](/reference/bluetooth/stop-advertising) +[stop-advertising](/reference/bluetooth/stop-advertising), [advertise-uid](/reference/bluetooth/advertise-uid) ```package bluetooth diff --git a/libs/bluetooth/_locales/bluetooth-jsdoc-strings.json b/libs/bluetooth/_locales/bluetooth-jsdoc-strings.json index ea5514a8..e14253fd 100644 --- a/libs/bluetooth/_locales/bluetooth-jsdoc-strings.json +++ b/libs/bluetooth/_locales/bluetooth-jsdoc-strings.json @@ -1,5 +1,14 @@ { "bluetooth": "Support for additional Bluetooth services.\n\nSupport for additional Bluetooth services.", + "bluetooth.advertiseUid": "Advertise an Eddystone UID", + "bluetooth.advertiseUidBuffer": "Advertise an Eddystone UID", + "bluetooth.advertiseUidBuffer|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.", + "bluetooth.advertiseUidBuffer|param|nsAndInstance": "16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15)", + "bluetooth.advertiseUidBuffer|param|power": "power level between 0 and 7, eg: 7", + "bluetooth.advertiseUid|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.", + "bluetooth.advertiseUid|param|instance": "4 last bytes of the instance uid", + "bluetooth.advertiseUid|param|ns": "4 last bytes of the namespace uid", + "bluetooth.advertiseUid|param|power": "power level between 0 and 7, eg: 7", "bluetooth.advertiseUrl": "Advertise an Eddystone URL", "bluetooth.advertiseUrl|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.", "bluetooth.advertiseUrl|param|power": "power level between 0 and 7, eg: 7", diff --git a/libs/bluetooth/_locales/bluetooth-strings.json b/libs/bluetooth/_locales/bluetooth-strings.json index 70761646..cde5e714 100644 --- a/libs/bluetooth/_locales/bluetooth-strings.json +++ b/libs/bluetooth/_locales/bluetooth-strings.json @@ -1,4 +1,5 @@ { + "bluetooth.advertiseUid|block": "bluetooth advertise UID|namespace (bytes 6-9)%ns|instance (bytes 2-6)%instance|with power %power|connectable %connectable", "bluetooth.advertiseUrl|block": "bluetooth advertise url %url|with power %power|connectable %connectable", "bluetooth.onBluetoothConnected|block": "on bluetooth connected", "bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected", diff --git a/libs/bluetooth/bluetooth.cpp b/libs/bluetooth/bluetooth.cpp index 75622de9..07f5aec3 100644 --- a/libs/bluetooth/bluetooth.cpp +++ b/libs/bluetooth/bluetooth.cpp @@ -137,6 +137,24 @@ namespace bluetooth { uBit.bleManager.setTransmitPower(power); } + /** + * Advertise an Eddystone UID + * @param nsAndInstance 16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15) + * @param power power level between 0 and 7, eg: 7 + * @param connectable true to keep bluetooth connectable for other services, false otherwise. + */ + //% parts=bluetooth weight=12 advanced=true + void advertiseUidBuffer(Buffer nsAndInstance, int power, bool connectable) { + ManagedBuffer buf(nsAndInstance); + if (buf.length() != 16) return; + + power = min(MICROBIT_BLE_POWER_LEVELS-1, max(0, power)); + int8_t level = CALIBRATED_POWERS[power]; + uint8_t uidNs[10]; buf.readBytes(uidNs, 0, 10); + uint8_t uidInst[6]; buf.readBytes(uidInst, 10, 6); + uBit.bleManager.advertiseEddystoneUid((const char*)uidNs, (const char*)uidInst, level, connectable); + } + /** * Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum). * @param power power level between 0 (minimal) and 7 (maximum), eg: 7. diff --git a/libs/bluetooth/bluetooth.ts b/libs/bluetooth/bluetooth.ts index 3f480408..0652ea7a 100644 --- a/libs/bluetooth/bluetooth.ts +++ b/libs/bluetooth/bluetooth.ts @@ -46,4 +46,21 @@ namespace bluetooth { // dummy implementation for simulator return "???" } + + /** + * Advertise an Eddystone UID + * @param ns 4 last bytes of the namespace uid + * @param instance 4 last bytes of the instance uid + * @param power power level between 0 and 7, eg: 7 + * @param connectable true to keep bluetooth connectable for other services, false otherwise. + */ + //% blockId=eddystone_advertise_uid block="bluetooth advertise UID|namespace (bytes 6-9)%ns|instance (bytes 2-6)%instance|with power %power|connectable %connectable" + //% parts=bluetooth weight=12 blockGap=8 + //% help=bluetooth/advertise-uid blockExternalInputs=1 + export function advertiseUid(ns: number, instance: number, power: number, connectable: boolean) { + const buf = pins.createBuffer(16); + buf.fill(ns, 6, 4); + buf.fill(instance, 12, 4); + bluetooth.advertiseUidBuffer(buf, power, connectable); + } } diff --git a/libs/bluetooth/pxt.json b/libs/bluetooth/pxt.json index ac852cd5..92804b96 100644 --- a/libs/bluetooth/pxt.json +++ b/libs/bluetooth/pxt.json @@ -30,7 +30,7 @@ "event_service": 1, "device_info_service": 1, "eddystone_url": 1, - "eddystone_uid": 0, + "eddystone_uid": 1, "open": 0, "pairing_mode": 1, "whitelist": 1, diff --git a/libs/bluetooth/shims.d.ts b/libs/bluetooth/shims.d.ts index e62b991f..12ae7ea4 100644 --- a/libs/bluetooth/shims.d.ts +++ b/libs/bluetooth/shims.d.ts @@ -92,6 +92,15 @@ declare namespace bluetooth { //% help=bluetooth/advertise-url blockExternalInputs=1 shim=bluetooth::advertiseUrl function advertiseUrl(url: string, power: number, connectable: boolean): void; + /** + * Advertise an Eddystone UID + * @param nsAndInstance 16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15) + * @param power power level between 0 and 7, eg: 7 + * @param connectable true to keep bluetooth connectable for other services, false otherwise. + */ + //% parts=bluetooth weight=12 advanced=true shim=bluetooth::advertiseUidBuffer + function advertiseUidBuffer(nsAndInstance: Buffer, power: number, connectable: boolean): void; + /** * Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum). * @param power power level between 0 (minimal) and 7 (maximum), eg: 7. diff --git a/sim/state/misc.ts b/sim/state/misc.ts index da5fe165..6f5a2237 100644 --- a/sim/state/misc.ts +++ b/sim/state/misc.ts @@ -178,6 +178,7 @@ namespace pxsim.bluetooth { // TODO } export function advertiseUrl(url: string, power: number, connectable: boolean) { } + export function advertiseUidBuffer(nsAndInstance: Buffer, power: number, connectable: boolean) { } export function stopAdvertising() { } export function setTransmitPower(power: number) {} } From 4b7b6eebca22ce52f98cf4e7664c37ce923cb348 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 23 Dec 2016 08:59:08 -0800 Subject: [PATCH 8/8] 0.7.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9d2e2642..b4e47cd5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.7.6", + "version": "0.7.7", "description": "micro:bit target for PXT", "keywords": [ "JavaScript",