|
| 1 | +/* |
| 2 | + * The MIT License (MIT) |
| 3 | + * |
| 4 | + * Copyright (c) 2019 Ha Thach (tinyusb.org) for Adafruit Industries |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in |
| 14 | + * all copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | + * THE SOFTWARE. |
| 23 | + */ |
| 24 | + |
| 25 | +#include "BLEAdafruitService.h" |
| 26 | + |
| 27 | +//--------------------------------------------------------------------+ |
| 28 | +// MACRO TYPEDEF CONSTANT ENUM DECLARATION |
| 29 | +//--------------------------------------------------------------------+ |
| 30 | + |
| 31 | + |
| 32 | +/* All Adafruit Service/Characteristic UUID128 share the same Base UUID: |
| 33 | + * ADAFxxx-C332-42A8-93BD-25E905756CB8 |
| 34 | + * |
| 35 | + * Shared Characteristics |
| 36 | + * - Measurement Period 0001 | int32_t | Read + Write | |
| 37 | + * ms between measurements, -1: stop reading, 0: update when changes |
| 38 | + * |
| 39 | + * Accelerometer service 0E00 |
| 40 | + * - Data 0E01 | uint16_t | Read + Notify | unit-less |
| 41 | + * - Measurement Period 0001 |
| 42 | + */ |
| 43 | + |
| 44 | +const uint8_t BLEAdafruitProximity::UUID128_SERVICE[16] = |
| 45 | +{ |
| 46 | + 0xB8, 0x6c, 0x75, 0x05, 0xE9, 0x25, 0xBD, 0x93, |
| 47 | + 0xA8, 0x42, 0x32, 0xC3, 0x00, 0x0E, 0xAF, 0xAD |
| 48 | +}; |
| 49 | + |
| 50 | +const uint8_t BLEAdafruitProximity::UUID128_CHR_DATA[16] = |
| 51 | +{ |
| 52 | + 0xB8, 0x6c, 0x75, 0x05, 0xE9, 0x25, 0xBD, 0x93, |
| 53 | + 0xA8, 0x42, 0x32, 0xC3, 0x01, 0x0E, 0xAF, 0xAD |
| 54 | +}; |
| 55 | + |
| 56 | +// Constructor |
| 57 | +BLEAdafruitProximity::BLEAdafruitProximity(void) |
| 58 | + : BLEAdafruitSensor(UUID128_SERVICE, UUID128_CHR_DATA) |
| 59 | +{ |
| 60 | + // Setup Measurement Characteristic |
| 61 | + _measurement.setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY); |
| 62 | + _measurement.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); |
| 63 | + _measurement.setFixedLen(2); |
| 64 | +} |
0 commit comments