Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Committer:
AntonLS
Date:
Sat Jul 11 01:57:40 2015 +0000
Revision:
16:3c873f2c8a27
Converted BLE_API lib to folder so the version stays frozen.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AntonLS 16:3c873f2c8a27 1 /* mbed Microcontroller Library
AntonLS 16:3c873f2c8a27 2 * Copyright (c) 2006-2015 ARM Limited
AntonLS 16:3c873f2c8a27 3 *
AntonLS 16:3c873f2c8a27 4 * Licensed under the Apache License, Version 2.0 (the "License");
AntonLS 16:3c873f2c8a27 5 * you may not use this file except in compliance with the License.
AntonLS 16:3c873f2c8a27 6 * You may obtain a copy of the License at
AntonLS 16:3c873f2c8a27 7 *
AntonLS 16:3c873f2c8a27 8 * http://www.apache.org/licenses/LICENSE-2.0
AntonLS 16:3c873f2c8a27 9 *
AntonLS 16:3c873f2c8a27 10 * Unless required by applicable law or agreed to in writing, software
AntonLS 16:3c873f2c8a27 11 * distributed under the License is distributed on an "AS IS" BASIS,
AntonLS 16:3c873f2c8a27 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AntonLS 16:3c873f2c8a27 13 * See the License for the specific language governing permissions and
AntonLS 16:3c873f2c8a27 14 * limitations under the License.
AntonLS 16:3c873f2c8a27 15 */
AntonLS 16:3c873f2c8a27 16 #ifndef __BLE_IBEACON_SERVICE_H__
AntonLS 16:3c873f2c8a27 17 #define __BLE_IBEACON_SERVICE_H__
AntonLS 16:3c873f2c8a27 18
AntonLS 16:3c873f2c8a27 19 #include "core_cmInstr.h"
AntonLS 16:3c873f2c8a27 20 #include "BLEDevice.h"
AntonLS 16:3c873f2c8a27 21
AntonLS 16:3c873f2c8a27 22 /**
AntonLS 16:3c873f2c8a27 23 * @class iBeaconService
AntonLS 16:3c873f2c8a27 24 * @brief iBeacon Service. This service sets up a device to broadcast advertising packets to mimic an iBeacon<br>
AntonLS 16:3c873f2c8a27 25 */
AntonLS 16:3c873f2c8a27 26
AntonLS 16:3c873f2c8a27 27 class iBeaconService
AntonLS 16:3c873f2c8a27 28 {
AntonLS 16:3c873f2c8a27 29 public:
AntonLS 16:3c873f2c8a27 30 typedef const uint8_t LocationUUID_t[16];
AntonLS 16:3c873f2c8a27 31
AntonLS 16:3c873f2c8a27 32 union Payload {
AntonLS 16:3c873f2c8a27 33 uint8_t raw[25];
AntonLS 16:3c873f2c8a27 34 struct {
AntonLS 16:3c873f2c8a27 35 uint16_t companyID;
AntonLS 16:3c873f2c8a27 36 uint8_t ID;
AntonLS 16:3c873f2c8a27 37 uint8_t len;
AntonLS 16:3c873f2c8a27 38 uint8_t proximityUUID[16];
AntonLS 16:3c873f2c8a27 39 uint16_t majorNumber;
AntonLS 16:3c873f2c8a27 40 uint16_t minorNumber;
AntonLS 16:3c873f2c8a27 41 uint8_t txPower;
AntonLS 16:3c873f2c8a27 42 };
AntonLS 16:3c873f2c8a27 43
AntonLS 16:3c873f2c8a27 44 Payload(LocationUUID_t uuid, uint16_t majNum, uint16_t minNum, uint8_t transmitPower, uint16_t companyIDIn) :
AntonLS 16:3c873f2c8a27 45 companyID(companyIDIn), ID(0x02), len(0x15), majorNumber(__REV16(majNum)), minorNumber(__REV16(minNum)), txPower(transmitPower)
AntonLS 16:3c873f2c8a27 46 {
AntonLS 16:3c873f2c8a27 47 memcpy(proximityUUID, uuid, sizeof(LocationUUID_t));
AntonLS 16:3c873f2c8a27 48 }
AntonLS 16:3c873f2c8a27 49 };
AntonLS 16:3c873f2c8a27 50
AntonLS 16:3c873f2c8a27 51 public:
AntonLS 16:3c873f2c8a27 52 iBeaconService(BLEDevice &_ble,
AntonLS 16:3c873f2c8a27 53 LocationUUID_t uuid,
AntonLS 16:3c873f2c8a27 54 uint16_t majNum,
AntonLS 16:3c873f2c8a27 55 uint16_t minNum,
AntonLS 16:3c873f2c8a27 56 uint8_t txP = 0xC8,
AntonLS 16:3c873f2c8a27 57 uint16_t compID = 0x004C) :
AntonLS 16:3c873f2c8a27 58 ble(_ble), data(uuid, majNum, minNum, txP, compID)
AntonLS 16:3c873f2c8a27 59 {
AntonLS 16:3c873f2c8a27 60 // Generate the 0x020106 part of the iBeacon Prefix
AntonLS 16:3c873f2c8a27 61 ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE );
AntonLS 16:3c873f2c8a27 62 // Generate the 0x1AFF part of the iBeacon Prefix
AntonLS 16:3c873f2c8a27 63 ble.accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, data.raw, sizeof(data.raw));
AntonLS 16:3c873f2c8a27 64
AntonLS 16:3c873f2c8a27 65 // Set advertising type
AntonLS 16:3c873f2c8a27 66 ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);
AntonLS 16:3c873f2c8a27 67 }
AntonLS 16:3c873f2c8a27 68
AntonLS 16:3c873f2c8a27 69 private:
AntonLS 16:3c873f2c8a27 70 BLEDevice &ble;
AntonLS 16:3c873f2c8a27 71 Payload data;
AntonLS 16:3c873f2c8a27 72 };
AntonLS 16:3c873f2c8a27 73
AntonLS 16:3c873f2c8a27 74 #endif //__BLE_IBEACON_SERVICE_H__