v2
Dependencies: BLE_API mbed DOOR
Fork of DOOR by
main.cpp@57:9782cb35c494, 2015-02-16 (annotated)
- Committer:
- rgrover1
- Date:
- Mon Feb 16 09:33:34 2015 +0000
- Revision:
- 57:9782cb35c494
- Parent:
- 56:56bc0cab3916
- Child:
- 58:ea344155a388
adding a const qualifier to a global variable.
Who changed what in which revision?
User | Revision | Line number | New 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" |
mbedAustin | 53:f9ec2c7a47f5 | 18 | #include "iBeaconService.h" |
ktownsend | 0:7613d21e5974 | 19 | |
mbedAustin | 56:56bc0cab3916 | 20 | /** |
mbedAustin | 56:56bc0cab3916 | 21 | * For this demo application, populate the beacon advertisement payload |
mbedAustin | 56:56bc0cab3916 | 22 | * with 2 AD structures: FLAG and MSD (manufacturer specific data). |
mbedAustin | 56:56bc0cab3916 | 23 | * |
mbedAustin | 56:56bc0cab3916 | 24 | * Reference: |
mbedAustin | 56:56bc0cab3916 | 25 | * Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 11, 18 |
mbedAustin | 56:56bc0cab3916 | 26 | */ |
mbedAustin | 56:56bc0cab3916 | 27 | |
mbedAustin | 50:7bc38f01d2d3 | 28 | BLEDevice ble; |
mbedAustin | 50:7bc38f01d2d3 | 29 | |
mbedAustin | 56:56bc0cab3916 | 30 | /** |
mbedAustin | 56:56bc0cab3916 | 31 | * The Beacon payload has the following composition: |
mbedAustin | 56:56bc0cab3916 | 32 | * 128-Bit / 16byte UUID = E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 |
mbedAustin | 56:56bc0cab3916 | 33 | * Major/Minor = 0x1122 / 0x3344 |
mbedAustin | 56:56bc0cab3916 | 34 | * Tx Power = 0xC8 = 200, 2's compliment is 256-200 = (-56dB) |
mbedAustin | 56:56bc0cab3916 | 35 | * |
mbedAustin | 56:56bc0cab3916 | 36 | * Note: please remember to calibrate your beacons |
mbedAustin | 56:56bc0cab3916 | 37 | * TX Power for more accurate results. |
mbedAustin | 56:56bc0cab3916 | 38 | */ |
rgrover1 | 57:9782cb35c494 | 39 | const uint8_t uuid[] = {0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4, |
rgrover1 | 57:9782cb35c494 | 40 | 0xA1, 0x2F, 0x17, 0xD1, 0xAD, 0x07, 0xA9, 0x61 |
rgrover1 | 57:9782cb35c494 | 41 | }; |
mbedAustin | 56:56bc0cab3916 | 42 | uint16_t majorNumber = 1122; |
mbedAustin | 56:56bc0cab3916 | 43 | uint16_t minorNumber = 3344; |
mbedAustin | 56:56bc0cab3916 | 44 | uint16_t txPower = 0xC8; |
mbedAustin | 56:56bc0cab3916 | 45 | |
ktownsend | 0:7613d21e5974 | 46 | int main(void) |
ktownsend | 0:7613d21e5974 | 47 | { |
mbedAustin | 56:56bc0cab3916 | 48 | // Initialize BLE baselayer |
Rohit Grover |
11:6774f4827024 | 49 | ble.init(); |
mbedAustin | 53:f9ec2c7a47f5 | 50 | |
mbedAustin | 56:56bc0cab3916 | 51 | // Initialize ibeacon |
mbedAustin | 56:56bc0cab3916 | 52 | iBeaconService ibeacon(ble, uuid, majorNumber, minorNumber, txPower); |
mbedAustin | 53:f9ec2c7a47f5 | 53 | |
mbedAustin | 53:f9ec2c7a47f5 | 54 | // Set advertising time |
rgrover1 | 57:9782cb35c494 | 55 | ble.setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(100)); /* 100ms. */ |
Rohit Grover |
19:869d8c7306b4 | 56 | ble.startAdvertising(); |
ktownsend | 0:7613d21e5974 | 57 | |
mbedAustin | 56:56bc0cab3916 | 58 | while(1) { |
mbedAustin | 56:56bc0cab3916 | 59 | ble.waitForEvent(); // allows or low power operation |
ktownsend | 0:7613d21e5974 | 60 | } |
Rohit Grover |
10:391c1acf4b9d | 61 | } |