using calibrated powers for Eddystone

This commit is contained in:
Peli de Halleux 2016-12-07 11:37:33 -08:00
parent 019b00209e
commit c85b6f9507

View File

@ -120,6 +120,7 @@ namespace bluetooth {
registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, body);
}
const int8_t CALIBRATED_POWERS[] = {-49, -37, -33, -28, -25, -20, -15, -10};
/**
* Advertise an Eddystone URL
* @param url the url to transmit. Must be no longer than the supported eddystone url length, eg: "https://pxt.io/"
@ -131,7 +132,7 @@ namespace bluetooth {
//% help=bluetooth/advertise-url blockExternalInputs=1
void advertiseUrl(StringData* url, int power, bool connectable) {
power = min(MICROBIT_BLE_POWER_LEVELS-1, max(0, power));
int8_t level = MICROBIT_BLE_POWER_LEVEL[power];
int8_t level = CALIBRATED_POWERS[power];
uBit.bleManager.advertiseEddystoneUrl(ManagedString(url), level, connectable);
uBit.bleManager.setTransmitPower(power);
}