wersion 1.9
Fork of BLE_API by
ble/services/iBeacon.h@1029:a5d0fec3b17c, 2015-12-10 (annotated)
- Committer:
- rgrover1
- Date:
- Thu Dec 10 09:15:03 2015 +0000
- Revision:
- 1029:a5d0fec3b17c
- Parent:
- 1028:9dc2ab644517
- Child:
- 1042:21a86ac7f5b1
Synchronized with git rev e31ca45a
Author: Irit Arkin
I change the service description
It looked like it was the thermometer's description.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rgrover1 | 755:e41890615604 | 1 | /* mbed Microcontroller Library |
rgrover1 | 755:e41890615604 | 2 | * Copyright (c) 2006-2015 ARM Limited |
rgrover1 | 755:e41890615604 | 3 | * |
rgrover1 | 755:e41890615604 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
rgrover1 | 755:e41890615604 | 5 | * you may not use this file except in compliance with the License. |
rgrover1 | 755:e41890615604 | 6 | * You may obtain a copy of the License at |
rgrover1 | 755:e41890615604 | 7 | * |
rgrover1 | 755:e41890615604 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
rgrover1 | 755:e41890615604 | 9 | * |
rgrover1 | 755:e41890615604 | 10 | * Unless required by applicable law or agreed to in writing, software |
rgrover1 | 755:e41890615604 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
rgrover1 | 755:e41890615604 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
rgrover1 | 755:e41890615604 | 13 | * See the License for the specific language governing permissions and |
rgrover1 | 755:e41890615604 | 14 | * limitations under the License. |
rgrover1 | 755:e41890615604 | 15 | */ |
rgrover1 | 755:e41890615604 | 16 | #ifndef __BLE_IBEACON_H__ |
rgrover1 | 755:e41890615604 | 17 | #define __BLE_IBEACON_H__ |
rgrover1 | 755:e41890615604 | 18 | |
rgrover1 | 755:e41890615604 | 19 | #include "core_cmInstr.h" |
rgrover1 | 755:e41890615604 | 20 | #include "ble/BLE.h" |
rgrover1 | 755:e41890615604 | 21 | |
rgrover1 | 755:e41890615604 | 22 | /** |
rgrover1 | 755:e41890615604 | 23 | * @class iBeacon |
rgrover1 | 1029:a5d0fec3b17c | 24 | * @brief iBeacon Service. This sets up a device to broadcast advertising packets to mimic an iBeacon. |
rgrover1 | 755:e41890615604 | 25 | */ |
rgrover1 | 755:e41890615604 | 26 | class iBeacon |
rgrover1 | 755:e41890615604 | 27 | { |
rgrover1 | 755:e41890615604 | 28 | public: |
rgrover1 | 755:e41890615604 | 29 | typedef const uint8_t LocationUUID_t[16]; |
rgrover1 | 755:e41890615604 | 30 | |
rgrover1 | 755:e41890615604 | 31 | union Payload { |
rgrover1 | 755:e41890615604 | 32 | uint8_t raw[25]; |
rgrover1 | 755:e41890615604 | 33 | struct { |
rgrover1 | 755:e41890615604 | 34 | uint16_t companyID; |
rgrover1 | 755:e41890615604 | 35 | uint8_t ID; |
rgrover1 | 755:e41890615604 | 36 | uint8_t len; |
rgrover1 | 755:e41890615604 | 37 | uint8_t proximityUUID[16]; |
rgrover1 | 755:e41890615604 | 38 | uint16_t majorNumber; |
rgrover1 | 755:e41890615604 | 39 | uint16_t minorNumber; |
rgrover1 | 755:e41890615604 | 40 | uint8_t txPower; |
rgrover1 | 755:e41890615604 | 41 | }; |
rgrover1 | 755:e41890615604 | 42 | |
rgrover1 | 755:e41890615604 | 43 | Payload(LocationUUID_t uuid, uint16_t majNum, uint16_t minNum, uint8_t transmitPower, uint16_t companyIDIn) : |
rgrover1 | 755:e41890615604 | 44 | companyID(companyIDIn), ID(0x02), len(0x15), majorNumber(__REV16(majNum)), minorNumber(__REV16(minNum)), txPower(transmitPower) |
rgrover1 | 755:e41890615604 | 45 | { |
rgrover1 | 755:e41890615604 | 46 | memcpy(proximityUUID, uuid, sizeof(LocationUUID_t)); |
rgrover1 | 755:e41890615604 | 47 | } |
rgrover1 | 755:e41890615604 | 48 | }; |
rgrover1 | 755:e41890615604 | 49 | |
rgrover1 | 755:e41890615604 | 50 | public: |
rgrover1 | 755:e41890615604 | 51 | iBeacon(BLE &_ble, |
rgrover1 | 755:e41890615604 | 52 | LocationUUID_t uuid, |
rgrover1 | 755:e41890615604 | 53 | uint16_t majNum, |
rgrover1 | 755:e41890615604 | 54 | uint16_t minNum, |
rgrover1 | 755:e41890615604 | 55 | uint8_t txP = 0xC8, |
rgrover1 | 755:e41890615604 | 56 | uint16_t compID = 0x004C) : |
rgrover1 | 755:e41890615604 | 57 | ble(_ble), data(uuid, majNum, minNum, txP, compID) |
rgrover1 | 755:e41890615604 | 58 | { |
rgrover1 | 1029:a5d0fec3b17c | 59 | // Generate the 0x020106 part of the iBeacon Prefix. |
rgrover1 | 755:e41890615604 | 60 | ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE ); |
rgrover1 | 1029:a5d0fec3b17c | 61 | // Generate the 0x1AFF part of the iBeacon Prefix. |
rgrover1 | 755:e41890615604 | 62 | ble.accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, data.raw, sizeof(data.raw)); |
rgrover1 | 755:e41890615604 | 63 | |
rgrover1 | 1029:a5d0fec3b17c | 64 | // Set advertising type. |
rgrover1 | 755:e41890615604 | 65 | ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED); |
rgrover1 | 755:e41890615604 | 66 | } |
rgrover1 | 755:e41890615604 | 67 | |
rgrover1 | 755:e41890615604 | 68 | protected: |
rgrover1 | 755:e41890615604 | 69 | BLE &ble; |
rgrover1 | 755:e41890615604 | 70 | Payload data; |
rgrover1 | 755:e41890615604 | 71 | }; |
rgrover1 | 755:e41890615604 | 72 | |
rgrover1 | 755:e41890615604 | 73 | typedef iBeacon iBeaconService; /* This type-alias is deprecated. Please use iBeacon directly. This alias may be dropped from a future release. */ |
rgrover1 | 755:e41890615604 | 74 | |
rgrover1 | 755:e41890615604 | 75 | #endif //__BLE_IBEACON_H__ |