Changed to work with St Board
Dependencies: BLE_API X_NUCLEO_IDB0XA1 mbed
Fork of BLE_URIBeacon by
main.cpp@0:790a27ffc99b, 2014-10-08 (annotated)
- Committer:
- rgrover1
- Date:
- Wed Oct 08 16:49:32 2014 +0000
- Revision:
- 0:790a27ffc99b
- Child:
- 1:65e87169548d
mbed's implementation of the Google PhysicalWeb
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rgrover1 | 0:790a27ffc99b | 1 | /* mbed Microcontroller Library |
rgrover1 | 0:790a27ffc99b | 2 | * Copyright (c) 2006-2013 ARM Limited |
rgrover1 | 0:790a27ffc99b | 3 | * |
rgrover1 | 0:790a27ffc99b | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
rgrover1 | 0:790a27ffc99b | 5 | * you may not use this file except in compliance with the License. |
rgrover1 | 0:790a27ffc99b | 6 | * You may obtain a copy of the License at |
rgrover1 | 0:790a27ffc99b | 7 | * |
rgrover1 | 0:790a27ffc99b | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
rgrover1 | 0:790a27ffc99b | 9 | * |
rgrover1 | 0:790a27ffc99b | 10 | * Unless required by applicable law or agreed to in writing, software |
rgrover1 | 0:790a27ffc99b | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
rgrover1 | 0:790a27ffc99b | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
rgrover1 | 0:790a27ffc99b | 13 | * See the License for the specific language governing permissions and |
rgrover1 | 0:790a27ffc99b | 14 | * limitations under the License. |
rgrover1 | 0:790a27ffc99b | 15 | */ |
rgrover1 | 0:790a27ffc99b | 16 | |
rgrover1 | 0:790a27ffc99b | 17 | #include "mbed.h" |
rgrover1 | 0:790a27ffc99b | 18 | #include "BLEDevice.h" |
rgrover1 | 0:790a27ffc99b | 19 | |
rgrover1 | 0:790a27ffc99b | 20 | BLEDevice ble; |
rgrover1 | 0:790a27ffc99b | 21 | |
rgrover1 | 0:790a27ffc99b | 22 | static const uint8_t BEACON_UUID[] = {0xD8, 0xFE}; |
rgrover1 | 0:790a27ffc99b | 23 | uint8_t urldata[] = |
rgrover1 | 0:790a27ffc99b | 24 | { |
rgrover1 | 0:790a27ffc99b | 25 | BEACON_UUID[0], BEACON_UUID[1], |
rgrover1 | 0:790a27ffc99b | 26 | 0x00, // flags |
rgrover1 | 0:790a27ffc99b | 27 | 0x20, // power |
rgrover1 | 0:790a27ffc99b | 28 | 0x00, // http://www. |
rgrover1 | 0:790a27ffc99b | 29 | 'm', // 'm' |
rgrover1 | 0:790a27ffc99b | 30 | 'b', // 'b' |
rgrover1 | 0:790a27ffc99b | 31 | 'e', // 'e' |
rgrover1 | 0:790a27ffc99b | 32 | 'd', // 'd' |
rgrover1 | 0:790a27ffc99b | 33 | 0x08, // .".org" |
rgrover1 | 0:790a27ffc99b | 34 | }; |
rgrover1 | 0:790a27ffc99b | 35 | |
rgrover1 | 0:790a27ffc99b | 36 | int main(void) |
rgrover1 | 0:790a27ffc99b | 37 | { |
rgrover1 | 0:790a27ffc99b | 38 | ble.init(); |
rgrover1 | 0:790a27ffc99b | 39 | |
rgrover1 | 0:790a27ffc99b | 40 | ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, BEACON_UUID, sizeof(BEACON_UUID)); |
rgrover1 | 0:790a27ffc99b | 41 | ble.accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA, urldata, sizeof(urldata)); |
rgrover1 | 0:790a27ffc99b | 42 | |
rgrover1 | 0:790a27ffc99b | 43 | ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED); |
rgrover1 | 0:790a27ffc99b | 44 | ble.setAdvertisingInterval(1600); /* 1s; in multiples of 0.625ms. */ |
rgrover1 | 0:790a27ffc99b | 45 | ble.startAdvertising(); |
rgrover1 | 0:790a27ffc99b | 46 | |
rgrover1 | 0:790a27ffc99b | 47 | while (true) { |
rgrover1 | 0:790a27ffc99b | 48 | ble.waitForEvent(); |
rgrover1 | 0:790a27ffc99b | 49 | } |
rgrover1 | 0:790a27ffc99b | 50 | } |