Martin Woolley / microbit-dal-eddystone

Dependencies:   BLE_API mbed-dev-bin nRF51822

Dependents:   microbit-eddystone

Fork of microbit-dal by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MicroBitEddystone.h Source File

MicroBitEddystone.h

00001 /*
00002 The MIT License (MIT)
00003 
00004 Copyright (c) 2016 British Broadcasting Corporation.
00005 This software is provided by Lancaster University by arrangement with the BBC.
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a
00008 copy of this software and associated documentation files (the "Software"),
00009 to deal in the Software without restriction, including without limitation
00010 the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011 and/or sell copies of the Software, and to permit persons to whom the
00012 Software is furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00020 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00022 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00023 DEALINGS IN THE SOFTWARE.
00024 */
00025 
00026 #ifndef MICROBIT_EDDYSTONE_H
00027 #define MICROBIT_EDDYSTONE_H
00028 
00029 #include "MicroBitConfig.h"
00030 
00031 /*
00032  * Return to our predefined compiler settings.
00033  */
00034 #if !defined(__arm)
00035 #pragma GCC diagnostic pop
00036 #endif
00037 
00038 #include "MicroBitBLEManager.h"
00039 
00040 /**
00041   * Class definition for the MicroBitEddystone.
00042   *
00043   */
00044 class MicroBitEddystone
00045 {
00046   public:
00047 
00048     static MicroBitEddystone* getInstance();
00049 
00050 #if CONFIG_ENABLED(MICROBIT_BLE_EDDYSTONE_URL)
00051 
00052     /**
00053       * Set the content of Eddystone URL frames
00054       *
00055       * @param url The url to broadcast
00056       *
00057       * @param calibratedPower the transmission range of the beacon (Defaults to: 0xF0 ~10m).
00058       *
00059       * @note The calibratedPower value ranges from -100 to +20 to a resolution of 1. The calibrated power should be binary encoded.
00060       * More information can be found at https://github.com/google/eddystone/tree/master/eddystone-uid#tx-power
00061       */
00062     int setURL(BLEDevice* ble, const char *url, int8_t calibratedPower = 0xF0);
00063 
00064     /**
00065       * Set the content of Eddystone URL frames, but accepts a ManagedString as a url.
00066       *
00067       * @param url The url to broadcast
00068       *
00069       * @param calibratedPower the transmission range of the beacon (Defaults to: 0xF0 ~10m).
00070       *
00071       * @note The calibratedPower value ranges from -100 to +20 to a resolution of 1. The calibrated power should be binary encoded.
00072       * More information can be found at https://github.com/google/eddystone/tree/master/eddystone-uid#tx-power
00073       */
00074     int setURL(BLEDevice* ble, ManagedString url, int8_t calibratedPower = 0xF0);
00075 
00076 #endif
00077 
00078 #if CONFIG_ENABLED(MICROBIT_BLE_EDDYSTONE_UID)
00079     /**
00080       * Set the content of Eddystone UID frames
00081       *
00082       * @param uid_namespace the uid namespace. Must 10 bytes long.
00083       *
00084       * @param uid_instance  the uid instance value. Must 6 bytes long.
00085       *
00086       * @param calibratedPower the transmission range of the beacon (Defaults to: 0xF0 ~10m).
00087       *
00088       * @note The calibratedPower value ranges from -100 to +20 to a resolution of 1. The calibrated power should be binary encoded.
00089       * More information can be found at https://github.com/google/eddystone/tree/master/eddystone-uid#tx-power
00090       */
00091     int setUID(BLEDevice* ble, const char* uid_namespace, const char* uid_instance, int8_t calibratedPower = 0xF0);
00092 #endif
00093 
00094   private:
00095 
00096     /**
00097       * Private constructor.
00098       */
00099     MicroBitEddystone();
00100 
00101     static MicroBitEddystone *_instance;
00102 };
00103 
00104 #endif