cleaned unused examples - 3

This commit is contained in:
2019-01-16 10:35:37 +08:00
parent 93e117c79f
commit 1d6a7d84cc
518 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,679 @@
/**************************************************************************************************
Filename: glucservice.c
Revised: $Date $
Revision: $Revision $
Description: This file contains the Glucose sample service
for use with the Glucose sample application.
Copyright 2011-2013 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
/*********************************************************************
* INCLUDES
*/
#include "bcomdef.h"
#include "OSAL.h"
#include "linkdb.h"
#include "att.h"
#include "gatt.h"
#include "gatt_uuid.h"
#include "gattservapp.h"
#include "gapbondmgr.h"
#include "glucservice.h"
/*********************************************************************
* MACROS
*/
/*********************************************************************
* CONSTANTS
*/
// Position of glucose measurement value in attribute array
#define GLUCOSE_MEAS_VALUE_POS 2
#define GLUCOSE_MEAS_CONFIG_POS 3
#define GLUCOSE_CONTEXT_VALUE_POS 5
#define GLUCOSE_CONTEXT_CONFIG_POS 6
#define GLUCOSE_CTL_PNT_VALUE_POS 10
#define GLUCOSE_CTL_PNT_CONFIG_POS 11
/*********************************************************************
* TYPEDEFS
*/
/*********************************************************************
* GLOBAL VARIABLES
*/
// Glucose service
CONST uint8 glucoseServUUID[ATT_BT_UUID_SIZE] =
{
LO_UINT16(GLUCOSE_SERV_UUID), HI_UINT16(GLUCOSE_SERV_UUID)
};
// Glucose characteristic
CONST uint8 glucoseMeasUUID[ATT_BT_UUID_SIZE] =
{
LO_UINT16(GLUCOSE_MEAS_UUID), HI_UINT16(GLUCOSE_MEAS_UUID)
};
// Glucose Measurement Context
CONST uint8 glucoseContextUUID[ATT_BT_UUID_SIZE] =
{
LO_UINT16(GLUCOSE_CONTEXT_UUID), HI_UINT16(GLUCOSE_CONTEXT_UUID)
};
// Glucose Feature
CONST uint8 glucoseFeatureUUID[ATT_BT_UUID_SIZE] =
{
LO_UINT16(GLUCOSE_FEATURE_UUID), HI_UINT16(GLUCOSE_FEATURE_UUID)
};
// Record Control Point
CONST uint8 recordControlPointUUID[ATT_BT_UUID_SIZE] =
{
LO_UINT16(RECORD_CONTROL_POINT_UUID), HI_UINT16(RECORD_CONTROL_POINT_UUID)
};
/*********************************************************************
* EXTERNAL VARIABLES
*/
/* TRUE if record transfer in progress */
extern bool glucoseSendAllRecords;
/*********************************************************************
* EXTERNAL FUNCTIONS
*/
/*********************************************************************
* LOCAL VARIABLES
*/
static glucoseServiceCB_t glucoseServiceCB;
/*********************************************************************
* Profile Attributes - variables
*/
// Glucose Service attribute
static CONST gattAttrType_t glucoseService = { ATT_BT_UUID_SIZE, glucoseServUUID };
// Glucose Characteristic
static uint8 glucoseProps = GATT_PROP_NOTIFY;
static gattCharCfg_t glucoseMeasConfig[GATT_MAX_NUM_CONN];
static uint8 glucoseMeas = 0;
// Measurement Context
static uint8 glucoseContextProps = GATT_PROP_NOTIFY;
static uint8 glucoseContext=0;
static gattCharCfg_t glucoseContextConfig[GATT_MAX_NUM_CONN];
// Glucose Feature
static uint8 glucoseFeatureProps = GATT_PROP_READ;
static uint16 glucoseFeature = GLUCOSE_FEAT_ALL;
// Glucose Control
static uint8 glucoseControlProps = GATT_PROP_INDICATE | GATT_PROP_WRITE;
static uint8 glucoseControl=0;
static gattCharCfg_t glucoseControlConfig[GATT_MAX_NUM_CONN];
/*********************************************************************
* Profile Attributes - Table
*/
static gattAttribute_t glucoseAttrTbl[] =
{
// Glucose Service
{
{ ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
GATT_PERMIT_READ, /* permissions */
0, /* handle */
(uint8 *)&glucoseService /* pValue */
},
// 1. Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseProps
},
// 2. Characteristic Value
{
{ ATT_BT_UUID_SIZE, glucoseMeasUUID },
0, //return READ_NOT_PERMITTED
0,
&glucoseMeas
},
// 3.Characteristic Configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
(uint8 *)&glucoseMeasConfig
},
//////////////////////////////////////////////
// MEASUREMENT CONTEXT
//////////////////////////////////////////////
// 4.Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseContextProps
},
// 5.Characteristic Value
{
{ ATT_BT_UUID_SIZE, glucoseContextUUID },
0, //return READ_NOT_PERMITTED
0,
&glucoseContext
},
// 6.Characteristic Configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
(uint8 *)&glucoseContextConfig
},
//////////////////////////////////////////////
// GLUCOSE FEATURE
//////////////////////////////////////////////
// 7.Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseFeatureProps
},
// 8.Characteristic Value
{
{ ATT_BT_UUID_SIZE, glucoseFeatureUUID },
GATT_PERMIT_READ,
0,
(uint8 *) &glucoseFeature
},
//////////////////////////////////////////////
// GLUCOSE CONTROL POINT
//////////////////////////////////////////////
// 9.Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseControlProps
},
// 10.Characteristic Value
{
{ ATT_BT_UUID_SIZE, recordControlPointUUID },
GATT_PERMIT_WRITE | GATT_PERMIT_AUTHEN_WRITE,
0,
&glucoseControl
},
// 11.Characteristic Configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
(uint8 *)&glucoseControlConfig
}
};
/*********************************************************************
* LOCAL FUNCTIONS
*/
static uint8 glucose_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
static bStatus_t glucose_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
uint8 *pValue, uint8 len, uint16 offset );
static void glucose_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
/*********************************************************************
* PROFILE CALLBACKS
*/
// Service Callbacks
CONST gattServiceCBs_t glucoseCBs =
{
glucose_ReadAttrCB, // Read callback function pointer
glucose_WriteAttrCB, // Write callback function pointer
NULL // Authorization callback function pointer
};
/*********************************************************************
* PUBLIC FUNCTIONS
*/
/*********************************************************************
* @fn Glucose_AddService
*
* @brief Initializes the Glucose service by registering
* GATT attributes with the GATT server.
*
* @param services - services to add. This is a bit map and can
* contain more than one service.
*
* @return Success or Failure
*/
bStatus_t Glucose_AddService( uint32 services )
{
uint8 status = SUCCESS;
// Initialize Client Characteristic Configuration attributes
GATTServApp_InitCharCfg( INVALID_CONNHANDLE, glucoseMeasConfig );
GATTServApp_InitCharCfg( INVALID_CONNHANDLE, glucoseContextConfig );
GATTServApp_InitCharCfg( INVALID_CONNHANDLE, glucoseControlConfig );
// Register with Link DB to receive link status change callback
VOID linkDB_Register( glucose_HandleConnStatusCB );
if ( services & GLUCOSE_SERVICE )
{
// Register GATT attribute list and CBs with GATT Server App
status = GATTServApp_RegisterService( glucoseAttrTbl, GATT_NUM_ATTRS( glucoseAttrTbl ),
&glucoseCBs );
}
return ( status );
}
/*********************************************************************
* @fn Glucose_Register
*
* @brief Register a callback function with the Glucose Service.
*
* @param pfnServiceCB - Callback function.
* pfnCtlPntCB - Callback for control point
*
* @return None.
*/
extern void Glucose_Register( glucoseServiceCB_t pfnServiceCB)
{
glucoseServiceCB = pfnServiceCB;
}
/*********************************************************************
* @fn Glucose_SetParameter
*
* @brief Set a glucose parameter.
*
* @param param - Profile parameter ID
* @param len - length of data to right
* @param value - pointer to data to write. This is dependent on
* the parameter ID and WILL be cast to the appropriate
* data type (example: data type of uint16 will be cast to
* uint16 pointer).
*
* @return bStatus_t
*/
bStatus_t Glucose_SetParameter( uint8 param, uint8 len, void *value )
{
bStatus_t ret = SUCCESS;
switch ( param )
{
case GLUCOSE_FEATURE_PARAM:
glucoseFeature = *((uint16*)value);
break;
default:
ret = INVALIDPARAMETER;
break;
}
return ( ret );
}
/*********************************************************************
* @fn Glucose_GetParameter
*
* @brief Get a Glucose parameter.
*
* @param param - Profile parameter ID
* @param value - pointer to data to get. This is dependent on
* the parameter ID and WILL be cast to the appropriate
* data type (example: data type of uint16 will be cast to
* uint16 pointer).
*
* @return bStatus_t
*/
bStatus_t Glucose_GetParameter( uint8 param, void *value )
{
bStatus_t ret = SUCCESS;
switch ( param )
{
case GLUCOSE_FEATURE_PARAM:
*((uint16*)value) = glucoseFeature;
break;
default:
ret = INVALIDPARAMETER;
break;
}
return ( ret );
}
/*********************************************************************
* @fn Glucose_MeasSend
*
* @brief Send a glucose measurement.
*
* @param connHandle - connection handle
* @param pNoti - pointer to notification structure
*
* @return Success or Failure
*/
bStatus_t Glucose_MeasSend( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId )
{
uint16 value = GATTServApp_ReadCharCfg( connHandle, glucoseMeasConfig );
// If notifications enabled
if ( value & GATT_CLIENT_CFG_NOTIFY )
{
// Set the handle
pNoti->handle = glucoseAttrTbl[GLUCOSE_MEAS_VALUE_POS].handle;
// Send the Indication
return GATT_Notification( connHandle, pNoti, FALSE );
}
return bleNotReady;
}
/*********************************************************************
* @fn Glucose_ContextSend
*
* @brief Send a glucose measurement context.
*
* @param connHandle - connection handle
* @param pNoti - pointer to notification structure
*
* @return Success or Failure
*/
bStatus_t Glucose_ContextSend( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId )
{
uint16 value = GATTServApp_ReadCharCfg( connHandle, glucoseContextConfig );
// If notifications enabled
if ( value & GATT_CLIENT_CFG_NOTIFY )
{
// Set the handle
pNoti->handle = glucoseAttrTbl[GLUCOSE_CONTEXT_VALUE_POS].handle;
// Send the Indication
return GATT_Notification( connHandle, pNoti, FALSE );
}
return bleNotReady;
}
/*********************************************************************
* @fn Glucose_CtlPntIndicate
*
* @brief Send an indication containing a control point
* message.
*
* @param connHandle - connection handle
* @param pInd - pointer to indication structure
*
* @return Success or Failure
*/
bStatus_t Glucose_CtlPntIndicate( uint16 connHandle, attHandleValueInd_t *pInd, uint8 taskId )
{
uint16 value = GATTServApp_ReadCharCfg( connHandle, glucoseControlConfig );
// If indications enabled
if ( value & GATT_CLIENT_CFG_INDICATE )
{
// Set the handle
pInd->handle = glucoseAttrTbl[GLUCOSE_CTL_PNT_VALUE_POS].handle;
// Send the Indication
return GATT_Indication( connHandle, pInd, FALSE, taskId );
}
return bleNotReady;
}
/*********************************************************************
* @fn glucose_ReadAttrCB
*
* @brief Read an attribute.
*
* @param connHandle - connection message was received on
* @param pAttr - pointer to attribute
* @param pValue - pointer to data to be read
* @param pLen - length of data to be read
* @param offset - offset of the first octet to be read
* @param maxLen - maximum length of data to be read
*
* @return Success or Failure
*/
static uint8 glucose_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
{
bStatus_t status = SUCCESS;
// Require security for all characteristics
if ( linkDB_Encrypted( connHandle ) == FALSE )
{
return ATT_ERR_INSUFFICIENT_ENCRYPT;
}
// Make sure it's not a blob operation (no attributes in the profile are long)
if ( offset > 0 )
{
return ( ATT_ERR_ATTR_NOT_LONG );
}
if ( pAttr->type.len == ATT_BT_UUID_SIZE )
{
// 16-bit UUID
uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
switch ( uuid )
{
// No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
// gattserverapp handles those types for reads
case GLUCOSE_FEATURE_UUID:
*pLen = 2;
pValue[0] = LO_UINT16( glucoseFeature );
pValue[1] = HI_UINT16( glucoseFeature );
break;
default:
// Should never get here! (characteristics 3 and 4 do not have read permissions)
*pLen = 0;
status = ATT_ERR_ATTR_NOT_FOUND;
break;
}
}
return ( status );
}
/*********************************************************************
* @fn glucose_WriteAttrCB
*
* @brief Validate attribute data prior to a write operation
*
* @param connHandle - connection message was received on
* @param pAttr - pointer to attribute
* @param pValue - pointer to data to be written
* @param len - length of data
* @param offset - offset of the first octet to be written
*
* @return Success or Failure
*/
static bStatus_t glucose_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
uint8 *pValue, uint8 len, uint16 offset )
{
bStatus_t status = SUCCESS;
// Require security for all characteristics
if ( linkDB_Encrypted( connHandle ) == FALSE )
{
return ATT_ERR_INSUFFICIENT_ENCRYPT;
}
// Make sure it's not a blob operation (no attributes in the profile are long)
if ( offset > 0 )
{
return ( ATT_ERR_ATTR_NOT_LONG );
}
uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
switch ( uuid )
{
case GATT_CLIENT_CHAR_CFG_UUID:
// Glucose Notifications
if ((pAttr->handle == glucoseAttrTbl[GLUCOSE_MEAS_CONFIG_POS].handle ||
pAttr->handle == glucoseAttrTbl[GLUCOSE_CONTEXT_CONFIG_POS].handle))
{
status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
offset, GATT_CLIENT_CFG_NOTIFY );
if ( status == SUCCESS )
{
uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
if(pAttr->handle == glucoseAttrTbl[GLUCOSE_MEAS_CONFIG_POS].handle)
{
(*glucoseServiceCB)((charCfg == 0) ? GLUCOSE_MEAS_NTF_DISABLED :
GLUCOSE_MEAS_NTF_ENABLED, NULL, NULL);
}
else
{
(*glucoseServiceCB)((charCfg == 0) ? GLUCOSE_CONTEXT_NTF_DISABLED :
GLUCOSE_CONTEXT_NTF_ENABLED, NULL, NULL);
}
}
}
// Glucose Indications
else if ( pAttr->handle == glucoseAttrTbl[GLUCOSE_CTL_PNT_CONFIG_POS].handle )
{
status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
offset, GATT_CLIENT_CFG_INDICATE );
if ( status == SUCCESS )
{
uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
(*glucoseServiceCB)((charCfg == 0) ? GLUCOSE_CTL_PNT_IND_DISABLED :
GLUCOSE_CTL_PNT_IND_ENABLED, NULL, NULL);
}
}
else
{
status = ATT_ERR_INVALID_VALUE;
}
break;
case RECORD_CONTROL_POINT_UUID:
if(len >= GLUCOSE_CTL_PNT_MIN_SIZE && len <= GLUCOSE_CTL_PNT_MAX_SIZE)
{
uint8 opcode = pValue[0];
// if transfer in progress
if (opcode != CTL_PNT_OP_ABORT && glucoseSendAllRecords)
{
status = GLUCOSE_ERR_IN_PROGRESS;
}
// if CCC not configured for glucose measurement
else if ( opcode == CTL_PNT_OP_REQ &&
!( GATTServApp_ReadCharCfg( connHandle, glucoseMeasConfig ) & GATT_CLIENT_CFG_NOTIFY ) )
{
status = GLUCOSE_ERR_CCC_CONFIG;
}
else
{
(*glucoseServiceCB)(GLUCOSE_CTL_PNT_CMD, pValue, len);
}
}
else
{
status = ATT_ERR_INVALID_VALUE_SIZE;
}
break;
default:
status = ATT_ERR_ATTR_NOT_FOUND;
break;
}
return ( status );
}
/*********************************************************************
* @fn glucose_HandleConnStatusCB
*
* @brief Simple Profile link status change handler function.
*
* @param connHandle - connection handle
* @param changeType - type of change
*
* @return none
*/
static void glucose_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
{
// Make sure this is not loopback connection
if ( connHandle != LOOPBACK_CONNHANDLE )
{
// Reset Client Char Config if connection has dropped
if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
( !linkDB_Up( connHandle ) ) ) )
{
GATTServApp_InitCharCfg( connHandle, glucoseMeasConfig );
GATTServApp_InitCharCfg( connHandle, glucoseContextConfig );
GATTServApp_InitCharCfg( connHandle, glucoseControlConfig );
}
}
}
/*********************************************************************
*********************************************************************/

View File

@@ -0,0 +1,338 @@
/**************************************************************************************************
Filename: glucservice.h
Revised: $Date: 2011-12-16 15:46:52 -0800 (Fri, 16 Dec 2011) $
Revision: $Revision: 58 $
Description: This file contains the Glucose service definitions and
prototypes.
Copyright 2011 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
#ifndef GLUCOSESERVICE_H
#define GLUCOSESERVICE_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************************************************************
* INCLUDES
*/
#include "OSAL_clock.h"
/*********************************************************************
* CONSTANTS
*/
// Glucose Service Parameters
#define GLUCOSE_FEATURE_PARAM 3
// Characteristic Value sizes
#define GLUCOSE_CTL_PNT_MIN_SIZE 2
#define GLUCOSE_CTL_PNT_MAX_SIZE 20
// Glucose Service UUIDs
#define GLUCOSE_SERV_UUID 0x1808
#define GLUCOSE_MEAS_UUID 0x2A18
#define GLUCOSE_CONTEXT_UUID 0x2A34
#define GLUCOSE_FEATURE_UUID 0x2A51
#define RECORD_CONTROL_POINT_UUID 0x2A52
// Values for meas flags
#define GLUCOSE_MEAS_FLAG_TIME_OFFSET 0x01
#define GLUCOSE_MEAS_FLAG_CONCENTRATION 0x02
#define GLUCOSE_MEAS_FLAG_UNITS 0x04
#define GLUCOSE_MEAS_FLAG_STATUS_ANNUNCIATION 0x08
#define GLUCOSE_MEAS_FLAG_CONTEXT_INFO 0x10
#define GLUCOSE_MEAS_FLAG_ALL (GLUCOSE_MEAS_FLAG_TIME_OFFSET | GLUCOSE_MEAS_FLAG_CONCENTRATION | GLUCOSE_MEAS_FLAG_UNITS | GLUCOSE_MEAS_FLAG_STATUS_ANNUNCIATION | GLUCOSE_MEAS_FLAG_CONTEXT_INFO)
// Values for Type Nibble
#define GLUCOSE_TYPE_CAPILLARY_WHOLE 0x1
#define GLUCOSE_TYPE_CAPILLARY_PLASMA 0x2
#define GLUCOSE_TYPE_VENOUS_WHOLE 0x3
#define GLUCOSE_TYPE_VENOUS_PLASMA 0x4
#define GLUCOSE_TYPE_ARTERIAL_WHOLE 0x5
#define GLUCOSE_TYPE_ARTERIAL_PLASMA 0x6
#define GLUCOSE_TYPE_UNDETER_WHOLE 0x7
#define GLUCOSE_TYPE_UNDETER_PLASMA 0x8
#define GLUCOSE_TYPE_ISF 0x9
#define GLUCOSE_TYPE_CONTROL 0xA
// Values for Location Nibble
#define GLUCOSE_LOCATION_FINGER 0x10
#define GLUCOSE_LOCATION_AST 0x20
#define GLUCOSE_LOCATION_EARLOBE 0x30
#define GLUCOSE_LOCATION_CONTROL 0x40
#define GLUCOSE_LOCATION_NOT_AVAIL 0xF0
// Values for Annunciation
#define GLUCOSE_ANNUNCIATION_BATT_LOW 0x0001
#define GLUCOSE_ANNUNCIATION_SENS_BAD 0x0002
#define GLUCOSE_ANNUNCIATION_SAMP_SIZE 0x0004
#define GLUCOSE_ANNUNCIATION_INSERT 0x0008
#define GLUCOSE_ANNUNCIATION_STRIP 0x0010
#define GLUCOSE_ANNUNCIATION_TOO_HIGH 0x0020
#define GLUCOSE_ANNUNCIATION_TOO_LOW 0x0040
#define GLUCOSE_ANNUNCIATION_TEMP_HIGH 0x0080
#define GLUCOSE_ANNUNCIATION_TEMP_LOW 0x0100
#define GLUCOSE_ANNUNCIATION_INTERRUPTED 0x0200
#define GLUCOSE_ANNUNCIATION_GENERAL 0x0400
#define GLUCOSE_ANNUNCIATION_TIME 0x0800
// Values for context flags
#define GLUCOSE_CONTEXT_FLAG_CARBO 0x01
#define GLUCOSE_CONTEXT_FLAG_MEAL 0x02
#define GLUCOSE_CONTEXT_FLAG_TESTER_HEALTH 0x04
#define GLUCOSE_CONTEXT_FLAG_EXERCISE 0x08
#define GLUCOSE_CONTEXT_FLAG_MEDICATION 0x10
#define GLUCOSE_CONTEXT_FLAG_MEDICATION_UNITS 0x20
#define GLUCOSE_CONTEXT_FLAG_HbA1c 0x40
#define GLUCOSE_CONTEXT_FLAG_EXTENDED 0x80
//We leave the extended flags out of this all, since there aren't any in the current spec
#define GLUCOSE_CONTEXT_FLAG_ALL (GLUCOSE_CONTEXT_FLAG_CARBO | GLUCOSE_CONTEXT_FLAG_MEAL | GLUCOSE_CONTEXT_FLAG_TESTER_HEALTH | GLUCOSE_CONTEXT_FLAG_EXERCISE | GLUCOSE_CONTEXT_FLAG_MEDICATION | GLUCOSE_CONTEXT_FLAG_MEDICATION_UNITS | GLUCOSE_CONTEXT_FLAG_HbA1c)
// Values for Carbohydratea
#define GLUCOSE_CARBO_BREAKFAST 0x01
#define GLUCOSE_CARBO_LUNCH 0x02
#define GLUCOSE_CARBO_DINNER 0x03
#define GLUCOSE_CARBO_SNACK 0x04
#define GLUCOSE_CARBO_DRINK 0x05
#define GLUCOSE_CARBO_SUPPER 0x06
#define GLUCOSE_CARBO_BRUNCH 0x07
// Values for Meal
#define GLUCOSE_MEAL_PREPRANDIAL 0x1
#define GLUCOSE_MEAL_POSTPRANDIAL 0x2
#define GLUCOSE_MEAL_FASTING 0x3
#define GLUCOSE_MEAL_CASUAL 0x4
// Values for Tester Nibble
#define GLUCOSE_TESTER_SELF 0x1
#define GLUCOSE_TESTER_PROFESSIONAL 0x2
#define GLUCOSE_TESTER_LAB_TEST 0x3
#define GLUCOSE_TESTER_UNAVAILABLE 0xF
// Values for Health Nibble
#define GLUCOSE_HEALTH_MINOR 0x10
#define GLUCOSE_HEALTH_MAJOR 0x20
#define GLUCOSE_HEALTH_MENSES 0x30
#define GLUCOSE_HEALTH_STRESS 0x40
#define GLUCOSE_HEALTH_NONE 0x50
#define GLUCOSE_HEALTH_UNAVAILABLE 0xF0
// Values for Medication ID
#define GLUCOSE_MEDICATION_RAPID 0x1
#define GLUCOSE_MEDICATION_SHORT 0x2
#define GLUCOSE_MEDICATION_INTERMEDIATE 0x3
#define GLUCOSE_MEDICATION_LONG 0x4
#define GLUCOSE_MEDICATION_PRE_MIXED 0x5
// Values for Glucose Features
#define GLUCOSE_FEAT_LOW_BAT_SUP 0x0001
#define GLUCOSE_FEAT_MALFUNC_SUP 0x0002
#define GLUCOSE_FEAT_SAMPLE_SIZE_SUP 0x0004
#define GLUCOSE_FEAT_INSERT_ERR_SUP 0x0008
#define GLUCOSE_FEAT_TYPE_ERR_SUP 0x0010
#define GLUCOSE_FEAT_RESULT_DET_SUP 0x0020
#define GLUCOSE_FEAT_TEMP_DET_SUP 0x0040
#define GLUCOSE_FEAT_READ_INT_SUP 0x0080
#define GLUCOSE_FEAT_GENERAL_FAULT_SUP 0x0100
#define GLUCOSE_FEAT_TIME_FAULT_SUP 0x0200
#define GLUCOSE_FEAT_MULTIPLE_BOND_SUP 0x0400
#define GLUCOSE_FEAT_ALL (GLUCOSE_FEAT_LOW_BAT_SUP | GLUCOSE_FEAT_MALFUNC_SUP | GLUCOSE_FEAT_SAMPLE_SIZE_SUP | \
GLUCOSE_FEAT_INSERT_ERR_SUP | GLUCOSE_FEAT_TYPE_ERR_SUP | GLUCOSE_FEAT_RESULT_DET_SUP | \
GLUCOSE_FEAT_TEMP_DET_SUP | GLUCOSE_FEAT_READ_INT_SUP | GLUCOSE_FEAT_GENERAL_FAULT_SUP | \
GLUCOSE_FEAT_TIME_FAULT_SUP | GLUCOSE_FEAT_MULTIPLE_BOND_SUP)
// Glucose Service bit fields
#define GLUCOSE_SERVICE 0x00000001
//Record Control Point values
#define CTL_PNT_OP_REQ 0x01
#define CTL_PNT_OP_CLR 0x02
#define CTL_PNT_OP_ABORT 0x03
#define CTL_PNT_OP_GET_NUM 0x04
#define CTL_PNT_OP_NUM_RSP 0x05
#define CTL_PNT_OP_REQ_RSP 0x06
//Record Control Point operator
#define CTL_PNT_OPER_NULL 0x00
#define CTL_PNT_OPER_ALL 0x01
#define CTL_PNT_OPER_LESS_EQUAL 0x02
#define CTL_PNT_OPER_GREATER_EQUAL 0x03
#define CTL_PNT_OPER_RANGE 0x04
#define CTL_PNT_OPER_FIRST 0x05
#define CTL_PNT_OPER_LAST 0x06
//Record Control Point Response Codes
#define CTL_PNT_RSP_SUCCESS 0x01
#define CTL_PNT_RSP_OPCODE_NOT_SUPPORTED 0x02
#define CTL_PNT_RSP_OPER_INVALID 0x03
#define CTL_PNT_RSP_OPER_NOT_SUPPORTED 0x04
#define CTL_PNT_RSP_OPERAND_INVALID 0x05
#define CTL_PNT_RSP_NO_RECORDS 0x06
#define CTL_PNT_RSP_ABORT_FAILED 0x07
#define CTL_PNT_RSP_PROC_NOT_CMPL 0x08
#define CTL_PNT_RSP_FILTER_NOT_SUPPORTED 0x09
//Record Control Point Filter Types
#define CTL_PNT_FILTER_SEQNUM 0x01
#define CTL_PNT_FILTER_TIME 0x02
// Callback events
#define GLUCOSE_MEAS_NTF_ENABLED 1
#define GLUCOSE_MEAS_NTF_DISABLED 2
#define GLUCOSE_CONTEXT_NTF_ENABLED 3
#define GLUCOSE_CONTEXT_NTF_DISABLED 4
#define GLUCOSE_CTL_PNT_IND_ENABLED 5
#define GLUCOSE_CTL_PNT_IND_DISABLED 6
#define GLUCOSE_CTL_PNT_CMD 7
// Procedure timeout in ms
#define GLUCOSE_PROCEDURE_TIMEOUT 30000
// ATT status values
#define GLUCOSE_ERR_IN_PROGRESS 0x80
#define GLUCOSE_ERR_CCC_CONFIG 0x81
/*********************************************************************
* TYPEDEFS
*/
// Glucose Service callback function
typedef void (*glucoseServiceCB_t)(uint8 event, uint8* data, uint8 dataLen);
/*********************************************************************
* MACROS
*/
/*********************************************************************
* Profile Callbacks
*/
/*********************************************************************
* API FUNCTIONS
*/
/*
* Glucose_AddService- Initializes the Glucose service by registering
* GATT attributes with the GATT server.
*
* @param services - services to add. This is a bit map and can
* contain more than one service.
*/
extern bStatus_t Glucose_AddService( uint32 services );
/*
* Glucose_Register - Register a callback function with the
* Glucose Service
*
* @param pfnServiceCB - Callback function.
*/
extern void Glucose_Register( glucoseServiceCB_t pfnServiceCB);
/*
* Glucose_SetParameter - Set a Glucose parameter.
*
* param - Profile parameter ID
* len - length of data to right
* value - pointer to data to write. This is dependent on
* the parameter ID and WILL be cast to the appropriate
* data type (example: data type of uint16 will be cast to
* uint16 pointer).
*/
extern bStatus_t Glucose_SetParameter( uint8 param, uint8 len, void *value );
/*
* Glucose_GetParameter - Get a Glucose parameter.
*
* param - Profile parameter ID
* value - pointer to data to write. This is dependent on
* the parameter ID and WILL be cast to the appropriate
* data type (example: data type of uint16 will be cast to
* uint16 pointer).
*/
extern bStatus_t Glucose_GetParameter( uint8 param, void *value );
/*********************************************************************
* @fn Glucose_MeasSend
*
* @brief Send a glucose measurement.
*
* @param connHandle - connection handle
* @param pNoti - pointer to notification structure
*
* @return Success or Failure
*/
extern bStatus_t Glucose_MeasSend( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId );
/*********************************************************************
* @fn Glucose_ContextSend
*
* @brief Send a glucose measurement context.
*
* @param connHandle - connection handle
* @param pNoti - pointer to notification structure
*
* @return Success or Failure
*/
extern bStatus_t Glucose_ContextSend( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId );
/*********************************************************************
* @fn Glucose_CtlPntIndicate
*
* @brief Send an indication containing a glucose
* measurement.
*
* @param connHandle - connection handle
* @param pInd - pointer to indication structure
*
* @return Success or Failure
*/
extern bStatus_t Glucose_CtlPntIndicate( uint16 connHandle, attHandleValueInd_t *pInd, uint8 taskId );
/*********************************************************************
*********************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* GLUCOSESERVICE_H */