14
14
* limitations under the License.
15
15
*/
16
16
17
- #include " mbed.h"
17
+ #include " mbed-drivers/mbed .h"
18
18
#include " ble/BLE.h"
19
19
#include " ble/services/iBeacon.h"
20
20
21
- BLE ble ;
21
+ static iBeacon* ibeaconPtr ;
22
22
23
23
/* *
24
24
* This function is called when the ble initialization process has failled
25
25
*/
26
26
void onBleInitError (BLE &ble, ble_error_t error)
27
27
{
28
- // Initialization error handling should go here
28
+ /* Initialization error handling should go here */
29
29
}
30
30
31
31
/* *
@@ -37,12 +37,12 @@ void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
37
37
ble_error_t error = params->error ;
38
38
39
39
if (error != BLE_ERROR_NONE) {
40
- // in case of error, forward the error handling to onBleInitError
40
+ /* In case of error, forward the error handling to onBleInitError */
41
41
onBleInitError (ble, error);
42
42
return ;
43
43
}
44
44
45
- // ensure that it is the default instance of BLE
45
+ /* Ensure that it is the default instance of BLE */
46
46
if (ble.getInstanceID () != BLE::DEFAULT_INSTANCE) {
47
47
return ;
48
48
}
@@ -55,18 +55,19 @@ void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
55
55
*
56
56
* Note: please remember to calibrate your beacons TX Power for more accurate results.
57
57
*/
58
- const uint8_t uuid[] = {0xE2 , 0x0A , 0x39 , 0xF4 , 0x73 , 0xF5 , 0x4B , 0xC4 ,
59
- 0xA1 , 0x2F , 0x17 , 0xD1 , 0xAD , 0x07 , 0xA9 , 0x61 };
58
+ static const uint8_t uuid[] = {0xE2 , 0x0A , 0x39 , 0xF4 , 0x73 , 0xF5 , 0x4B , 0xC4 ,
59
+ 0xA1 , 0x2F , 0x17 , 0xD1 , 0xAD , 0x07 , 0xA9 , 0x61 };
60
60
uint16_t majorNumber = 1122 ;
61
61
uint16_t minorNumber = 3344 ;
62
62
uint16_t txPower = 0xC8 ;
63
- iBeacon ibeacon (ble, uuid, majorNumber, minorNumber, txPower);
63
+ ibeaconPtr = new iBeacon (ble, uuid, majorNumber, minorNumber, txPower);
64
64
65
65
ble.gap ().setAdvertisingInterval (1000 ); /* 1000ms. */
66
66
ble.gap ().startAdvertising ();
67
67
}
68
68
69
- void app_start (int argc , char *argv[] )
69
+ void app_start (int , char ** )
70
70
{
71
+ BLE &ble = BLE::Instance ();
71
72
ble.init (bleInitComplete);
72
73
}
0 commit comments