preparing support for eddystone
This commit is contained in:
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.
|
Reference in New Issue
Block a user