preparing support for eddystone
This commit is contained in:
parent
63d0b86508
commit
b1fcc51bc8
@ -29,19 +29,21 @@ control.inBackground(() => {
|
||||
});
|
||||
```
|
||||
|
||||
## Bluetooth
|
||||
|
||||
## bluetooth and Eddystone
|
||||
|
||||
```namespaces
|
||||
devices.tellCameraTo(MesCameraEvent.TakePhoto);
|
||||
bluetooth.onBluetoothConnected(() => {});
|
||||
eddystone.advertiseUrl("https://pxt.io", 6);
|
||||
```
|
||||
|
||||
```package
|
||||
radio
|
||||
devices
|
||||
bluetooth
|
||||
eddystone
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[basic](/reference/basic), [input](/reference/input), [music](/reference/music), [led](/reference/led), [Math (blocks)](/blocks/math), [String](/reference/types/string), [game](/reference/game), [images](/reference/images), [pins](/reference/pins), [serial](/reference/serial), [control](/reference/control), [radio](/reference/radio), [devices](/reference/devices), [bluetooth](/reference/bluetooth)
|
||||
[basic](/reference/basic), [input](/reference/input), [music](/reference/music), [led](/reference/led), [Math (blocks)](/blocks/math), [String](/reference/types/string), [game](/reference/game), [images](/reference/images), [pins](/reference/pins), [serial](/reference/serial), [control](/reference/control), [radio](/reference/radio), [devices](/reference/devices), [bluetooth](/reference/bluetooth), [eddystone](/reference/eddystone)
|
||||
|
28
docs/reference/eddystone.md
Normal file
28
docs/reference/eddystone.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Eddystone
|
||||
|
||||
Support for Eddystone beacons.
|
||||
|
||||
```cards
|
||||
eddystone.advertiseUrl("https://pxt.io/", 6);
|
||||
eddystone.stopAdvertising();
|
||||
```
|
||||
|
||||
### Advanced
|
||||
|
||||
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.
|
||||
|
||||
More information at https://lancaster-university.github.io/microbit-docs/ble/eddystone/
|
||||
|
||||
### See Also
|
||||
|
||||
[eddystone.advertiseUrl](/reference/eddystone/advertise-url),
|
||||
[eddystone.stopAdvertising](/reference/eddystone/stop-advertising),
|
||||
|
||||
```package
|
||||
eddystone
|
||||
```
|
31
libs/eddystone/eddystone.cpp
Normal file
31
libs/eddystone/eddystone.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "pxt.h"
|
||||
#include "Microbit.h"
|
||||
#include "MicroBitEddystone.h"
|
||||
|
||||
using namespace pxt;
|
||||
|
||||
/**
|
||||
* Support for Eddystone beacons
|
||||
*/
|
||||
//% color=#0082FB weight=19
|
||||
namespace eddystone {
|
||||
const int8_t CALIBRATED_POWERS[] = {-49, -37, -33, -28, -25, -20, -15, -10};
|
||||
|
||||
/**
|
||||
* Advertise an Eddystone URL
|
||||
*/
|
||||
//% blockId=eddystone_advertise_url block="eddystone advertise url %url|power %powerLevel"
|
||||
void advertiseUrl(StringData* url, int powerLevel) {
|
||||
int power = CALIBRATED_POWERS[min(7, max(0, powerLevel))];
|
||||
ManagedString murl(url)
|
||||
uBit.bleManager.advertiseEddystoneUrl(murl, power, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops advertising Eddystone end points
|
||||
*/
|
||||
//% blockId=eddystone_stop_advertising block="eddystone stop advertising"
|
||||
void stopAdvertising() {
|
||||
uBit.bleManager.stopAdvertising();
|
||||
}
|
||||
}
|
13
libs/eddystone/eddystone.ts
Normal file
13
libs/eddystone/eddystone.ts
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Support for Eddystone beacons
|
||||
*/
|
||||
//% color=#0082FB weight=19
|
||||
namespace eddystone {
|
||||
//% shim=eddystone::advertiseUrl
|
||||
export function advertiseUrl(url: string, powerLevel: number) {
|
||||
}
|
||||
|
||||
//% shim=eddystone::stopAdvertising
|
||||
export function stopAdvertising() {
|
||||
}
|
||||
}
|
5
libs/eddystone/enums.d.ts
vendored
Normal file
5
libs/eddystone/enums.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
// Auto-generated. Do not edit.
|
||||
declare namespace eddystone {
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
38
libs/eddystone/pxt.json
Normal file
38
libs/eddystone/pxt.json
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "eddystone",
|
||||
"description": "Eddystone beacon support",
|
||||
"dependencies": {
|
||||
"core": "file:../core"
|
||||
},
|
||||
"files": [
|
||||
"eddystone.cpp",
|
||||
"eddystone.ts",
|
||||
"enums.d.ts",
|
||||
"shims.d.ts"
|
||||
],
|
||||
"yotta": {
|
||||
"config": {
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"enabled": 1,
|
||||
"eddystone_url": 1,
|
||||
"eddystone_uid": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"optionalConfig": {
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"pairing_mode": 0,
|
||||
"private_addressing": 0,
|
||||
"whitelist": 0,
|
||||
"advertising_timeout": 0,
|
||||
"tx_power": 6,
|
||||
"dfu_service": 0,
|
||||
"event_service": 0,
|
||||
"device_info_service": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
23
libs/eddystone/shims.d.ts
vendored
Normal file
23
libs/eddystone/shims.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Auto-generated. Do not edit.
|
||||
|
||||
|
||||
/**
|
||||
* Support for Eddystone beacons
|
||||
*/
|
||||
//% color=#0082FB weight=19
|
||||
declare namespace eddystone {
|
||||
|
||||
/**
|
||||
* Advertise an Eddystone URL
|
||||
*/
|
||||
//% blockId=eddystone_advertise_url block="eddystone advertise url %url|power %powerLevel" shim=eddystone::advertiseUrl
|
||||
function advertiseUrl(url: string, powerLevel: number): void;
|
||||
|
||||
/**
|
||||
* Stops advertising Eddystone end points
|
||||
*/
|
||||
//% blockId=eddystone_stop_advertising block="eddystone stop advertising" shim=eddystone::stopAdvertising
|
||||
function stopAdvertising(): void;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
@ -9,7 +9,8 @@
|
||||
"libs/core",
|
||||
"libs/radio",
|
||||
"libs/devices",
|
||||
"libs/bluetooth"
|
||||
"libs/bluetooth",
|
||||
"libs/eddystone"
|
||||
],
|
||||
"cloud": {
|
||||
"workspace": false,
|
||||
|
Loading…
Reference in New Issue
Block a user