MAX32620HSP (MAXREFDES100) RPC Example for Graphical User Interface

Dependencies:   USBDevice

Fork of HSP_Release by Jerry Bradshaw

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HspBLE.h Source File

HspBLE.h

00001 /*******************************************************************************
00002  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a
00005  * copy of this software and associated documentation files (the "Software"),
00006  * to deal in the Software without restriction, including without limitation
00007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008  * and/or sell copies of the Software, and to permit persons to whom the
00009  * Software is furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included
00012  * in all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00018  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020  * OTHER DEALINGS IN THE SOFTWARE.
00021  *
00022  * Except as contained in this notice, the name of Maxim Integrated
00023  * Products, Inc. shall not be used except as stated in the Maxim Integrated
00024  * Products, Inc. Branding Policy.
00025  *
00026  * The mere transfer of this software does not imply any licenses
00027  * of trade secrets, proprietary technology, copyrights, patents,
00028  * trademarks, maskwork rights, or any other form of intellectual
00029  * property whatsoever. Maxim Integrated Products, Inc. retains all
00030  * ownership rights.
00031  *******************************************************************************
00032  */
00033 #ifndef _HSPBLE_H_
00034 #define _HSPBLE_H_
00035 
00036 #include "mbed.h"
00037 #include "BluetoothLE.h"
00038 
00039 /// define the number of characteristics used on the HSP platform
00040 #define NUMBER_OF_CHARACTERISTICS (7)
00041 
00042 /// indicies of the characteristics used
00043 #define CHARACTERISTIC_TEMP_TOP (0)
00044 #define CHARACTERISTIC_TEMP_BOTTOM (1)
00045 #define CHARACTERISTIC_ACCELEROMETER (2)
00046 #define CHARACTERISTIC_HEARTRATE (3)
00047 #define CHARACTERISTIC_PRESSURE (4)
00048 #define CHARACTERISTIC_DATA (5)
00049 #define CHARACTERISTIC_CMD (6)
00050 
00051 class HspBLE {
00052 public:
00053   HspBLE(BLE *ble);
00054   ~HspBLE(void);
00055   void init(void);
00056   static void _onDataWritten(int index);
00057   void onDataWritten(int index);
00058   void updateNotification(int index);
00059   void pollSensor(int sensorId, uint8_t *data);
00060   bool getStartDataLogging(void);
00061   static HspBLE *instance;
00062 
00063 private:
00064   void tickerHandler(void);
00065   void testPattern(uint8_t *data, int length, bool clear);
00066 
00067   /// pointer to the helper BLE object
00068   BluetoothLE *bluetoothLE;
00069   /// ticker that is used to periodically update the characteristic
00070   /// notifications
00071   Ticker ticker;
00072 
00073   /// value that controls the notifications to be sent in a round robin fashion
00074   int notificationUpdateRoundRobin;
00075 
00076   /// charateristic UUIDs statically defined
00077   static uint8_t temperatureTopCharUUID[];
00078   static uint8_t temperatureBottomCharUUID[];
00079   static uint8_t accelerometerCharUUID[];
00080   static uint8_t heartrateCharUUID[];
00081   static uint8_t pressureCharUUID[];
00082   static uint8_t dataCharUUID[];
00083   static uint8_t commandCharUUID[];
00084   static uint8_t envServiceUUID[];
00085   static uint8_t deviceName[];
00086   static uint8_t serialNumber[];
00087 
00088   /// application specific
00089   bool startDataLogging;
00090 };
00091 
00092 #endif // _HSPBLE_H_