Beacon demo for the BLE API using the nRF51822 native mode drivers

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_iBeacon by Bluetooth Low Energy

Committer:
rgrover1
Date:
Fri Feb 13 16:44:04 2015 +0000
Revision:
55:b9616b70d6a3
Parent:
54:3a655a9fce9a
Child:
56:56bc0cab3916
simplified iBeacon based on the iBeaconService

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ktownsend 0:7613d21e5974 1 /* mbed Microcontroller Library
ktownsend 0:7613d21e5974 2 * Copyright (c) 2006-2013 ARM Limited
ktownsend 0:7613d21e5974 3 *
ktownsend 0:7613d21e5974 4 * Licensed under the Apache License, Version 2.0 (the "License");
ktownsend 0:7613d21e5974 5 * you may not use this file except in compliance with the License.
ktownsend 0:7613d21e5974 6 * You may obtain a copy of the License at
ktownsend 0:7613d21e5974 7 *
ktownsend 0:7613d21e5974 8 * http://www.apache.org/licenses/LICENSE-2.0
ktownsend 0:7613d21e5974 9 *
ktownsend 0:7613d21e5974 10 * Unless required by applicable law or agreed to in writing, software
ktownsend 0:7613d21e5974 11 * distributed under the License is distributed on an "AS IS" BASIS,
ktownsend 0:7613d21e5974 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ktownsend 0:7613d21e5974 13 * See the License for the specific language governing permissions and
ktownsend 0:7613d21e5974 14 * limitations under the License.
ktownsend 0:7613d21e5974 15 */
ktownsend 0:7613d21e5974 16
ktownsend 0:7613d21e5974 17 #include "mbed.h"
rgrover1 55:b9616b70d6a3 18 #include "BLEDevice.h"
mbedAustin 53:f9ec2c7a47f5 19 #include "iBeaconService.h"
ktownsend 0:7613d21e5974 20
mbedAustin 50:7bc38f01d2d3 21 BLEDevice ble;
mbedAustin 50:7bc38f01d2d3 22
ktownsend 0:7613d21e5974 23 int main(void)
ktownsend 0:7613d21e5974 24 {
Rohit Grover 11:6774f4827024 25 ble.init();
mbedAustin 53:f9ec2c7a47f5 26
rgrover1 55:b9616b70d6a3 27 const uint8_t uuid[] = {0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4,
rgrover1 55:b9616b70d6a3 28 0xA1, 0x2F, 0x17, 0xD1, 0xAD, 0x07, 0xA9, 0x61};
rgrover1 55:b9616b70d6a3 29 iBeaconService ibeacon(ble, uuid, 0x1122 /* majorNumber */, 0x3344 /* minorNumber */, 0xC8 /* 2's complement of the Tx power (-56dB) */);
mbedAustin 53:f9ec2c7a47f5 30
mbedAustin 53:f9ec2c7a47f5 31 // Set advertising time
mbedAustin 50:7bc38f01d2d3 32 ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */
Rohit Grover 19:869d8c7306b4 33 ble.startAdvertising();
ktownsend 0:7613d21e5974 34
rgrover1 55:b9616b70d6a3 35 for (;;) {
rgrover1 55:b9616b70d6a3 36 ble.waitForEvent();
ktownsend 0:7613d21e5974 37 }
Rohit Grover 10:391c1acf4b9d 38 }