Future Electronics
/
sequana-ble-lab-base
This is a basic code to be used for Sequana BLE Lab exercises.
source/SequanaPrimaryService.cpp@4:44690f4495ef, 2019-03-22 (annotated)
- Committer:
- lru
- Date:
- Fri Mar 22 10:11:59 2019 +0000
- Revision:
- 4:44690f4495ef
- Parent:
- 2:06e62a299a74
Initialized properly device name characteristic and changed type of advertising MAC address used to guarantee uniqueness.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lru | 0:ff033dfc838b | 1 | /* |
lru | 0:ff033dfc838b | 2 | * Copyright (c) 2017-2019 Future Electronics |
lru | 0:ff033dfc838b | 3 | * |
lru | 0:ff033dfc838b | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
lru | 0:ff033dfc838b | 5 | * you may not use this file except in compliance with the License. |
lru | 0:ff033dfc838b | 6 | * You may obtain a copy of the License at |
lru | 0:ff033dfc838b | 7 | * |
lru | 0:ff033dfc838b | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
lru | 0:ff033dfc838b | 9 | * |
lru | 0:ff033dfc838b | 10 | * Unless required by applicable law or agreed to in writing, software |
lru | 0:ff033dfc838b | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
lru | 0:ff033dfc838b | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
lru | 0:ff033dfc838b | 13 | * See the License for the specific language governing permissions and |
lru | 0:ff033dfc838b | 14 | * limitations under the License. |
lru | 0:ff033dfc838b | 15 | */ |
lru | 0:ff033dfc838b | 16 | |
lru | 0:ff033dfc838b | 17 | #include <mbed.h> |
lru | 0:ff033dfc838b | 18 | #include "ble/BLE.h" |
lru | 0:ff033dfc838b | 19 | #include "UUID.h" |
lru | 0:ff033dfc838b | 20 | |
lru | 0:ff033dfc838b | 21 | #include "SequanaPrimaryService.h" |
lru | 0:ff033dfc838b | 22 | |
lru | 0:ff033dfc838b | 23 | |
lru | 0:ff033dfc838b | 24 | namespace sequana { |
lru | 0:ff033dfc838b | 25 | |
lru | 0:ff033dfc838b | 26 | const UUID PrimaryService::UUID_SEQUANA_PRIMARY_SERVICE("F79B4EB2-1B6E-41F2-8D65-D346B4EF5685"); |
lru | 0:ff033dfc838b | 27 | |
lru | 0:ff033dfc838b | 28 | UUID UUID_TEMPERATURE_CHAR(GattCharacteristic::UUID_TEMPERATURE_CHAR); |
lru | 0:ff033dfc838b | 29 | UUID UUID_ACCELLEROMETER_CHAR("F79B4EB5-1B6E-41F2-8D65-D346B4EF5685"); |
lru | 0:ff033dfc838b | 30 | UUID UUID_MAGNETOMETER_CHAR("F79B4EB7-1B6E-41F2-8D65-D346B4EF5685"); |
lru | 0:ff033dfc838b | 31 | UUID UUID_AIR_QUALITY_CHAR("f79B4EBA-1B6E-41F2-8D65-D346B4EF5685"); |
lru | 0:ff033dfc838b | 32 | UUID UUID_PARTICULATE_MATTER_CHAR("F79B4EBB-1B6B-41F2-8D65-D346B4EF5685"); |
lru | 0:ff033dfc838b | 33 | UUID UUID_OTHER_ENV_CHAR("F79B4EBC-1B6E-41F2-8D65-D346B4EF5685"); |
lru | 0:ff033dfc838b | 34 | |
lru | 0:ff033dfc838b | 35 | int16_t tempValue = 0; |
lru | 0:ff033dfc838b | 36 | |
lru | 0:ff033dfc838b | 37 | SingleCharParams accMagSensorCharacteristics[2] = { |
lru | 0:ff033dfc838b | 38 | { &UUID_ACCELLEROMETER_CHAR, 0, 6 }, |
lru | 0:ff033dfc838b | 39 | { &UUID_MAGNETOMETER_CHAR, 6, 6 } |
lru | 0:ff033dfc838b | 40 | }; |
lru | 0:ff033dfc838b | 41 | |
lru | 0:ff033dfc838b | 42 | |
lru | 0:ff033dfc838b | 43 | PrimaryService::PrimaryService(BLE &ble, |
lru | 2:06e62a299a74 | 44 | Kmx65Sensor &kmx65) : |
lru | 0:ff033dfc838b | 45 | _ble(ble), |
lru | 0:ff033dfc838b | 46 | _accMagSensorMeasurement(ble, |
lru | 0:ff033dfc838b | 47 | accMagSensorCharacteristics, |
lru | 2:06e62a299a74 | 48 | kmx65) |
lru | 0:ff033dfc838b | 49 | { |
lru | 0:ff033dfc838b | 50 | GattCharacteristic *sequanaChars[] = { |
lru | 0:ff033dfc838b | 51 | _accMagSensorMeasurement.get_characteristic(0), |
lru | 0:ff033dfc838b | 52 | _accMagSensorMeasurement.get_characteristic(1) |
lru | 0:ff033dfc838b | 53 | }; |
lru | 0:ff033dfc838b | 54 | |
lru | 0:ff033dfc838b | 55 | GattService sequanaService(UUID_SEQUANA_PRIMARY_SERVICE, sequanaChars, sizeof(sequanaChars) / sizeof(GattCharacteristic *)); |
lru | 0:ff033dfc838b | 56 | |
lru | 0:ff033dfc838b | 57 | _ble.gattServer().addService(sequanaService); |
lru | 0:ff033dfc838b | 58 | } |
lru | 0:ff033dfc838b | 59 | |
lru | 0:ff033dfc838b | 60 | } //namespace |
lru | 0:ff033dfc838b | 61 |