Wilson Tang
/
HSP_RPC_GUI
Fork of the offical HSP_RPC_GUI firmware
Fork of MAXREFDES100 firmware for MAX32620HSP
HSP/Hsp_BLE/HspBLE.h@4:18155622d30a, 2020-01-28 (annotated)
- Committer:
- wt8008
- Date:
- Tue Jan 28 20:22:16 2020 +0000
- Revision:
- 4:18155622d30a
- Parent:
- 0:e4a10ed6eb92
Update Maxim's USBDevice project to the latest version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jbradshaw | 0:e4a10ed6eb92 | 1 | /******************************************************************************* |
jbradshaw | 0:e4a10ed6eb92 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
jbradshaw | 0:e4a10ed6eb92 | 3 | * |
jbradshaw | 0:e4a10ed6eb92 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
jbradshaw | 0:e4a10ed6eb92 | 5 | * copy of this software and associated documentation files (the "Software"), |
jbradshaw | 0:e4a10ed6eb92 | 6 | * to deal in the Software without restriction, including without limitation |
jbradshaw | 0:e4a10ed6eb92 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
jbradshaw | 0:e4a10ed6eb92 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
jbradshaw | 0:e4a10ed6eb92 | 9 | * Software is furnished to do so, subject to the following conditions: |
jbradshaw | 0:e4a10ed6eb92 | 10 | * |
jbradshaw | 0:e4a10ed6eb92 | 11 | * The above copyright notice and this permission notice shall be included |
jbradshaw | 0:e4a10ed6eb92 | 12 | * in all copies or substantial portions of the Software. |
jbradshaw | 0:e4a10ed6eb92 | 13 | * |
jbradshaw | 0:e4a10ed6eb92 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
jbradshaw | 0:e4a10ed6eb92 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
jbradshaw | 0:e4a10ed6eb92 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
jbradshaw | 0:e4a10ed6eb92 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
jbradshaw | 0:e4a10ed6eb92 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
jbradshaw | 0:e4a10ed6eb92 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
jbradshaw | 0:e4a10ed6eb92 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
jbradshaw | 0:e4a10ed6eb92 | 21 | * |
jbradshaw | 0:e4a10ed6eb92 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
jbradshaw | 0:e4a10ed6eb92 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
jbradshaw | 0:e4a10ed6eb92 | 24 | * Products, Inc. Branding Policy. |
jbradshaw | 0:e4a10ed6eb92 | 25 | * |
jbradshaw | 0:e4a10ed6eb92 | 26 | * The mere transfer of this software does not imply any licenses |
jbradshaw | 0:e4a10ed6eb92 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
jbradshaw | 0:e4a10ed6eb92 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
jbradshaw | 0:e4a10ed6eb92 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
jbradshaw | 0:e4a10ed6eb92 | 30 | * ownership rights. |
jbradshaw | 0:e4a10ed6eb92 | 31 | ******************************************************************************* |
jbradshaw | 0:e4a10ed6eb92 | 32 | */ |
jbradshaw | 0:e4a10ed6eb92 | 33 | #ifndef _HSPBLE_H_ |
jbradshaw | 0:e4a10ed6eb92 | 34 | #define _HSPBLE_H_ |
jbradshaw | 0:e4a10ed6eb92 | 35 | |
jbradshaw | 0:e4a10ed6eb92 | 36 | #include "mbed.h" |
jbradshaw | 0:e4a10ed6eb92 | 37 | #include "BluetoothLE.h" |
jbradshaw | 0:e4a10ed6eb92 | 38 | |
jbradshaw | 0:e4a10ed6eb92 | 39 | /// define the number of characteristics used on the HSP platform |
jbradshaw | 0:e4a10ed6eb92 | 40 | #define NUMBER_OF_CHARACTERISTICS (7) |
jbradshaw | 0:e4a10ed6eb92 | 41 | |
jbradshaw | 0:e4a10ed6eb92 | 42 | /// indicies of the characteristics used |
jbradshaw | 0:e4a10ed6eb92 | 43 | #define CHARACTERISTIC_TEMP_TOP (0) |
jbradshaw | 0:e4a10ed6eb92 | 44 | #define CHARACTERISTIC_TEMP_BOTTOM (1) |
jbradshaw | 0:e4a10ed6eb92 | 45 | #define CHARACTERISTIC_ACCELEROMETER (2) |
jbradshaw | 0:e4a10ed6eb92 | 46 | #define CHARACTERISTIC_HEARTRATE (3) |
jbradshaw | 0:e4a10ed6eb92 | 47 | #define CHARACTERISTIC_PRESSURE (4) |
jbradshaw | 0:e4a10ed6eb92 | 48 | #define CHARACTERISTIC_DATA (5) |
jbradshaw | 0:e4a10ed6eb92 | 49 | #define CHARACTERISTIC_CMD (6) |
jbradshaw | 0:e4a10ed6eb92 | 50 | |
jbradshaw | 0:e4a10ed6eb92 | 51 | class HspBLE { |
jbradshaw | 0:e4a10ed6eb92 | 52 | public: |
jbradshaw | 0:e4a10ed6eb92 | 53 | HspBLE(BLE *ble); |
jbradshaw | 0:e4a10ed6eb92 | 54 | ~HspBLE(void); |
jbradshaw | 0:e4a10ed6eb92 | 55 | void init(void); |
jbradshaw | 0:e4a10ed6eb92 | 56 | static void _onDataWritten(int index); |
jbradshaw | 0:e4a10ed6eb92 | 57 | void onDataWritten(int index); |
jbradshaw | 0:e4a10ed6eb92 | 58 | void updateNotification(int index); |
jbradshaw | 0:e4a10ed6eb92 | 59 | void pollSensor(int sensorId, uint8_t *data); |
jbradshaw | 0:e4a10ed6eb92 | 60 | bool getStartDataLogging(void); |
jbradshaw | 0:e4a10ed6eb92 | 61 | static HspBLE *instance; |
jbradshaw | 0:e4a10ed6eb92 | 62 | |
jbradshaw | 0:e4a10ed6eb92 | 63 | private: |
jbradshaw | 0:e4a10ed6eb92 | 64 | void tickerHandler(void); |
jbradshaw | 0:e4a10ed6eb92 | 65 | void testPattern(uint8_t *data, int length, bool clear); |
jbradshaw | 0:e4a10ed6eb92 | 66 | |
jbradshaw | 0:e4a10ed6eb92 | 67 | /// pointer to the helper BLE object |
jbradshaw | 0:e4a10ed6eb92 | 68 | BluetoothLE *bluetoothLE; |
jbradshaw | 0:e4a10ed6eb92 | 69 | /// ticker that is used to periodically update the characteristic |
jbradshaw | 0:e4a10ed6eb92 | 70 | /// notifications |
jbradshaw | 0:e4a10ed6eb92 | 71 | Ticker ticker; |
jbradshaw | 0:e4a10ed6eb92 | 72 | |
jbradshaw | 0:e4a10ed6eb92 | 73 | /// value that controls the notifications to be sent in a round robin fashion |
jbradshaw | 0:e4a10ed6eb92 | 74 | int notificationUpdateRoundRobin; |
jbradshaw | 0:e4a10ed6eb92 | 75 | |
jbradshaw | 0:e4a10ed6eb92 | 76 | /// charateristic UUIDs statically defined |
jbradshaw | 0:e4a10ed6eb92 | 77 | static uint8_t temperatureTopCharUUID[]; |
jbradshaw | 0:e4a10ed6eb92 | 78 | static uint8_t temperatureBottomCharUUID[]; |
jbradshaw | 0:e4a10ed6eb92 | 79 | static uint8_t accelerometerCharUUID[]; |
jbradshaw | 0:e4a10ed6eb92 | 80 | static uint8_t heartrateCharUUID[]; |
jbradshaw | 0:e4a10ed6eb92 | 81 | static uint8_t pressureCharUUID[]; |
jbradshaw | 0:e4a10ed6eb92 | 82 | static uint8_t dataCharUUID[]; |
jbradshaw | 0:e4a10ed6eb92 | 83 | static uint8_t commandCharUUID[]; |
jbradshaw | 0:e4a10ed6eb92 | 84 | static uint8_t envServiceUUID[]; |
jbradshaw | 0:e4a10ed6eb92 | 85 | static uint8_t deviceName[]; |
jbradshaw | 0:e4a10ed6eb92 | 86 | static uint8_t serialNumber[]; |
jbradshaw | 0:e4a10ed6eb92 | 87 | |
jbradshaw | 0:e4a10ed6eb92 | 88 | /// application specific |
jbradshaw | 0:e4a10ed6eb92 | 89 | bool startDataLogging; |
jbradshaw | 0:e4a10ed6eb92 | 90 | }; |
jbradshaw | 0:e4a10ed6eb92 | 91 | |
jbradshaw | 0:e4a10ed6eb92 | 92 | #endif // _HSPBLE_H_ |