Changed uint8_t to be int8_t for calibration and added transmission interval as optional parameter to physical web transmission

This commit is contained in:
Thomas Beverley 2016-09-27 10:01:54 +00:00
parent 95dc970024
commit 93917402e6
2 changed files with 12 additions and 8 deletions

View File

@ -71,6 +71,8 @@ DEALINGS IN THE SOFTWARE.
#define MICROBIT_BLE_MAXIMUM_BONDS 4
#define MICROBIT_BLE_ENABLE_BONDING true
#define MICROBIT_BLE_PW_ADV_INTERVAL 400
extern const int8_t MICROBIT_BLE_POWER_LEVEL[];
struct BLESysAttribute
@ -208,14 +210,15 @@ class MicroBitBLEManager : MicroBitComponent
* @param calibratedPower: the calibrated to transmit at. This is the received power at 0 meters in dBm.
* The value ranges from -100 to +20 to a resolution of 1. The calibrated power should be binary encoded.
* More information can be found at https://github.com/google/eddystone/tree/master/eddystone-url#tx-power-level
* @param internval: the advertising interval of the beacon
*/
void advertisePhysicalWebUrl(char* url, uint8_t calibratedPower);
void advertisePhysicalWebUrl(char* url, int8_t calibratedPower, uint16_t interval = MICROBIT_BLE_PW_ADV_INTERVAL);
/**
* Transmits a physical web url, but accepts a ManagedString as a url. For more info see
* advertisePhysicalWebUrl(char* url, uint8_t calibratedPower)
* advertisePhysicalWebUrl(char* url, int8_t calibratedPower, uint16_t interval)
*/
void advertisePhysicalWebUrl(ManagedString url, uint8_t calibratedPower);
void advertisePhysicalWebUrl(ManagedString url, int8_t calibratedPower, uint16_t internval = MICROBIT_BLE_PW_ADV_INTERVAL);
private:

View File

@ -482,8 +482,9 @@ void MicroBitBLEManager::stopAdvertising()
* @param calibratedPower: the calibrated to transmit at. This is the received power at 0 meters in dBm.
* The value ranges from -100 to +20 to a resolution of 1. The calibrated power should be binary encoded.
* More information can be found at https://github.com/google/eddystone/tree/master/eddystone-url#tx-power-level
* @param internval: the advertising interval of the beacon
*/
void MicroBitBLEManager::advertisePhysicalWebUrl(char* url, uint8_t calibratedPower)
void MicroBitBLEManager::advertisePhysicalWebUrl(char* url, int8_t calibratedPower, uint16_t interval)
{
int urlDataLength = 0;
char urlData[PWEB_URL_MAX_LENGTH];
@ -534,7 +535,7 @@ void MicroBitBLEManager::advertisePhysicalWebUrl(char* url, uint8_t calibratedPo
ble->accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, EDDYSTONE_UUID, sizeof(EDDYSTONE_UUID));
ble->accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA, rawFrame, index+urlDataLength);
ble->setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble->setAdvertisingInterval(400);
ble->setAdvertisingInterval(interval);
#if (MICROBIT_BLE_ADVERTISING_TIMEOUT > 0)
ble->gap().setAdvertisingTimeout(MICROBIT_BLE_ADVERTISING_TIMEOUT);
@ -544,11 +545,11 @@ void MicroBitBLEManager::advertisePhysicalWebUrl(char* url, uint8_t calibratedPo
/**
* Transmits a physical web url, but accepts a ManagedString as a url. For more info see
* advertisePhysicalWebUrl(char* url, uint8_t calibratedPower)
* advertisePhysicalWebUrl(char* url, uint8_t calibratedPower, uint16_t interval)
*/
void advertisePhysicalWebUrl(ManagedString url, uint8_t calibratedPower)
void advertisePhysicalWebUrl(ManagedString url, int8_t calibratedPower, uint16_t interval)
{
advertisePhysicalWebUrl((char *)url.toCharArray(), calibratedPower);
advertisePhysicalWebUrl((char *)url.toCharArray(), calibratedPower, interval);
}
/**