re-added source files for examples
This commit is contained in:
@@ -0,0 +1,577 @@
|
||||
/*******************************************************************************
|
||||
Filename: bpservice.c
|
||||
|
||||
Revised: $Date: 2015-05-12 08:13:18 -0700 (Tue, 12 May 2015) $
|
||||
Revision: $Revision: 43752 $
|
||||
|
||||
Description: This file contains the BloodPressure sample service
|
||||
for use with the BloodPressure sample application.
|
||||
|
||||
Copyright 2011 - 2015 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 "linkdb.h"
|
||||
#include "att.h"
|
||||
#include "gatt.h"
|
||||
#include "gatt_uuid.h"
|
||||
#include "gatt_profile_uuid.h"
|
||||
#include "gattservapp.h"
|
||||
#include "bpservice.h"
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// Position of bloodPressure measurement value in attribute array
|
||||
#define BLOODPRESSURE_MEAS_VALUE_POS 2
|
||||
#define BLOODPRESSURE_MEAS_CONFIG_POS 3
|
||||
#define BLOODPRESSURE_IMEAS_VALUE_POS 5
|
||||
#define BLOODPRESSURE_IMEAS_CONFIG_POS 6
|
||||
|
||||
#define BLOODPRESSURE_MULTI_BOND_BIT 5
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*/
|
||||
|
||||
// BloodPressure service
|
||||
CONST uint8 bloodPressureServUUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(BLOODPRESSURE_SERV_UUID), HI_UINT16(BLOODPRESSURE_SERV_UUID)
|
||||
};
|
||||
|
||||
// BloodPressure temperature characteristic
|
||||
CONST uint8 bloodPressureTempUUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(BLOODPRESSURE_MEAS_UUID), HI_UINT16(BLOODPRESSURE_MEAS_UUID)
|
||||
};
|
||||
|
||||
// BloodPressure Intermediate Cuff Pressure
|
||||
CONST uint8 bloodPressureImeasUUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(IMEDIATE_CUFF_PRESSURE_UUID), HI_UINT16(IMEDIATE_CUFF_PRESSURE_UUID)
|
||||
};
|
||||
|
||||
// BloodPressure Feature
|
||||
CONST uint8 bpFeatureUUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(BLOODPRESSURE_FEATURE_UUID), HI_UINT16(BLOODPRESSURE_FEATURE_UUID)
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL FUNCTIONS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL VARIABLES
|
||||
*/
|
||||
|
||||
static bloodPressureServiceCB_t bloodPressureServiceCB;
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Attributes - variables
|
||||
*/
|
||||
|
||||
// BloodPressure Service attribute.
|
||||
static CONST gattAttrType_t bloodPressureService = { ATT_BT_UUID_SIZE, bloodPressureServUUID };
|
||||
|
||||
// BloodPressure Characteristic.
|
||||
static uint8 bloodPressureTempProps = GATT_PROP_INDICATE;
|
||||
static gattCharCfg_t *bloodPressureMeasConfig;
|
||||
static uint8 bloodPressureTemp = 0;
|
||||
|
||||
// Intermediate Measurement.
|
||||
static uint8 bloodPressureImeasProps = GATT_PROP_NOTIFY;
|
||||
static uint8 bloodPressureImeas=0;
|
||||
static gattCharCfg_t *bloodPressureIMeasConfig;
|
||||
|
||||
// BP Feature
|
||||
/*
|
||||
* bit 0 Body Movement Detection Support bit
|
||||
* bit 1 Cuff Fit Detection Support bit
|
||||
* bit 2 Irregular Pulse Detection Support bit
|
||||
* bit 3 Pulse Rate Range Detection Support bit
|
||||
* bit 4 Measurement Position Detection Support bit
|
||||
* bit 5 Multiple Bond Support bit
|
||||
* bit 6. Reserved for Future Use
|
||||
*/
|
||||
static uint8 bpFeatureProps = GATT_PROP_READ;
|
||||
static uint16 bpFeature = 0x01 << BLOODPRESSURE_MULTI_BOND_BIT;
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Attributes - Table
|
||||
*/
|
||||
|
||||
static gattAttribute_t bloodPressureAttrTbl[] =
|
||||
{
|
||||
// BloodPressure Service
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
|
||||
GATT_PERMIT_READ, /* permissions */
|
||||
0, /* handle */
|
||||
(uint8 *)&bloodPressureService /* pValue */
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// BLOOD PRESSURE MEASUREMENT
|
||||
//////////////////////////////////////////////
|
||||
|
||||
// 1. Characteristic Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&bloodPressureTempProps
|
||||
},
|
||||
|
||||
// 2. Characteristic Value
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, bloodPressureTempUUID },
|
||||
0, //return READ_NOT_PERMITTED
|
||||
0,
|
||||
&bloodPressureTemp
|
||||
},
|
||||
|
||||
// 3.Characteristic Configuration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
|
||||
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
|
||||
0,
|
||||
(uint8 *)&bloodPressureMeasConfig
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// INTERMEDIATE CUFF PRESSURE
|
||||
//////////////////////////////////////////////
|
||||
|
||||
// 4.Characteristic Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&bloodPressureImeasProps
|
||||
},
|
||||
|
||||
// 5.Characteristic Value
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, bloodPressureImeasUUID },
|
||||
0, //return READ_NOT_PERMITTED
|
||||
0,
|
||||
&bloodPressureImeas
|
||||
},
|
||||
|
||||
// 6.Characteristic Configuration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
|
||||
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
|
||||
0,
|
||||
(uint8 *)&bloodPressureIMeasConfig
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// FEATURE
|
||||
//////////////////////////////////////////////
|
||||
|
||||
// 7.Characteristic Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&bpFeatureProps
|
||||
},
|
||||
|
||||
// 8.Characteristic Value
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, bpFeatureUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
(uint8 *)&bpFeature
|
||||
},
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL FUNCTIONS
|
||||
*/
|
||||
static uint8 BloodPressure_ReadAttrCB(uint16_t connHandle,
|
||||
gattAttribute_t *pAttr, uint8_t *pValue,
|
||||
uint16_t *pLen, uint16_t offset,
|
||||
uint16_t maxLen, uint8_t method);
|
||||
static bStatus_t BloodPressure_WriteAttrCB(uint16_t connHandle,
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t len,
|
||||
uint16_t offset, uint8_t method);
|
||||
|
||||
/*********************************************************************
|
||||
* PROFILE CALLBACKS
|
||||
*/
|
||||
// Blood Pressure Service Callbacks
|
||||
CONST gattServiceCBs_t bloodPressureCBs =
|
||||
{
|
||||
BloodPressure_ReadAttrCB, // Read callback function pointer.
|
||||
BloodPressure_WriteAttrCB, // Write callback function pointer.
|
||||
NULL // Authorization callback function pointer.
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* PUBLIC FUNCTIONS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* @fn BloodPressure_AddService
|
||||
*
|
||||
* @brief Initializes the BloodPressure 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 BloodPressure_AddService(uint32 services)
|
||||
{
|
||||
uint8 status;
|
||||
|
||||
// Allocate Client Characteristic Configuration table
|
||||
bloodPressureMeasConfig = (gattCharCfg_t *)ICall_malloc( sizeof(gattCharCfg_t) *
|
||||
linkDBNumConns );
|
||||
if ( bloodPressureMeasConfig == NULL )
|
||||
{
|
||||
return ( bleMemAllocError );
|
||||
}
|
||||
|
||||
// Allocate Client Characteristic Configuration table
|
||||
bloodPressureIMeasConfig = (gattCharCfg_t *)ICall_malloc( sizeof(gattCharCfg_t) *
|
||||
linkDBNumConns );
|
||||
if ( bloodPressureIMeasConfig == NULL )
|
||||
{
|
||||
// Free already allocated data
|
||||
ICall_free( bloodPressureMeasConfig );
|
||||
|
||||
return ( bleMemAllocError );
|
||||
}
|
||||
|
||||
// Initialize Client Characteristic Configuration attributes.
|
||||
GATTServApp_InitCharCfg(INVALID_CONNHANDLE, bloodPressureMeasConfig);
|
||||
GATTServApp_InitCharCfg(INVALID_CONNHANDLE, bloodPressureIMeasConfig);
|
||||
|
||||
if (services & BLOODPRESSURE_SERVICE)
|
||||
{
|
||||
// Register GATT attribute list and CBs with GATT Server App.
|
||||
status = GATTServApp_RegisterService(bloodPressureAttrTbl,
|
||||
GATT_NUM_ATTRS(bloodPressureAttrTbl),
|
||||
GATT_MAX_ENCRYPT_KEY_SIZE,
|
||||
&bloodPressureCBs);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = SUCCESS;
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn BloodPressure_Register
|
||||
*
|
||||
* @brief Register a callback function with the BloodPressure Service.
|
||||
*
|
||||
* @param pfnServiceCB - Callback function.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
extern void BloodPressure_Register(bloodPressureServiceCB_t pfnServiceCB)
|
||||
{
|
||||
bloodPressureServiceCB = pfnServiceCB;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn BloodPressure_SetParameter
|
||||
*
|
||||
* @brief Set a 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 BloodPressure_SetParameter(uint8 param, uint8 len, void *value)
|
||||
{
|
||||
bStatus_t ret = SUCCESS;
|
||||
|
||||
switch (param)
|
||||
{
|
||||
default:
|
||||
ret = INVALIDPARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* BloodPressure_GetParameter - Get a BloodPressure parameter.
|
||||
*
|
||||
* @param param - Profile parameter ID
|
||||
* @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 BloodPressure_GetParameter(uint8 param, void *value)
|
||||
{
|
||||
bStatus_t ret = SUCCESS;
|
||||
|
||||
switch (param)
|
||||
{
|
||||
default:
|
||||
ret = INVALIDPARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn BloodPressure_MeasIndicate
|
||||
*
|
||||
* @brief Send a notification containing a blood pressure
|
||||
* measurement.
|
||||
*
|
||||
* @param connHandle - connection handle
|
||||
* @param pNoti - pointer to notification structure
|
||||
* @param taskId - calling task's Id.
|
||||
*
|
||||
* @return Success or Failure
|
||||
*/
|
||||
bStatus_t BloodPressure_MeasIndicate(uint16 connHandle,
|
||||
attHandleValueInd_t *pNoti,uint8 taskId)
|
||||
{
|
||||
uint16 value = GATTServApp_ReadCharCfg(connHandle, bloodPressureMeasConfig);
|
||||
|
||||
// If indications enabled
|
||||
if (value & GATT_CLIENT_CFG_INDICATE)
|
||||
{
|
||||
// Set the handle.
|
||||
pNoti->handle = bloodPressureAttrTbl[BLOODPRESSURE_MEAS_VALUE_POS].handle;
|
||||
|
||||
// Send the Indication.
|
||||
return GATT_Indication(connHandle, pNoti, FALSE, taskId);
|
||||
}
|
||||
|
||||
return bleIncorrectMode;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* @fn BloodPressure_IMeasNotify
|
||||
*
|
||||
* @brief Send a notification containing a blood pressure
|
||||
* measurement.
|
||||
*
|
||||
* @param connHandle - connection handle
|
||||
* @param pNoti - pointer to notification structure
|
||||
* @param taskId - calling task's Id.
|
||||
*
|
||||
* @return Success or Failure
|
||||
*/
|
||||
bStatus_t BloodPressure_IMeasNotify(uint16 connHandle,
|
||||
attHandleValueNoti_t *pNoti, uint8 taskId)
|
||||
{
|
||||
uint16 value = GATTServApp_ReadCharCfg(connHandle,
|
||||
bloodPressureIMeasConfig);
|
||||
|
||||
// If notifications enabled
|
||||
if (value & GATT_CLIENT_CFG_NOTIFY)
|
||||
{
|
||||
// Set the handle.
|
||||
pNoti->handle = bloodPressureAttrTbl[BLOODPRESSURE_IMEAS_VALUE_POS].handle;
|
||||
|
||||
// Send the Indication.
|
||||
return GATT_Notification(connHandle, pNoti, FALSE);
|
||||
}
|
||||
|
||||
return bleIncorrectMode;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn BloodPressure_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 BloodPressure_ReadAttrCB(uint16_t connHandle,
|
||||
gattAttribute_t *pAttr, uint8_t *pValue,
|
||||
uint16_t *pLen, uint16_t offset,
|
||||
uint16_t maxLen, uint8_t method)
|
||||
{
|
||||
bStatus_t status = SUCCESS;
|
||||
|
||||
// If attribute permissions require authorization to read, return error.
|
||||
if (gattPermitAuthorRead(pAttr->permissions))
|
||||
{
|
||||
// Insufficient authorization.
|
||||
return (ATT_ERR_INSUFFICIENT_AUTHOR);
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
case BLOODPRESSURE_FEATURE_UUID:
|
||||
{
|
||||
*pLen = 2;
|
||||
pValue[0] = LO_UINT16(bpFeature);
|
||||
pValue[1] = HI_UINT16(bpFeature);
|
||||
}
|
||||
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 BloodPressure_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 BloodPressure_WriteAttrCB(uint16_t connHandle,
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t len,
|
||||
uint16_t offset, uint8_t method)
|
||||
{
|
||||
bStatus_t status = SUCCESS;
|
||||
uint16 uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
|
||||
|
||||
switch (uuid)
|
||||
{
|
||||
case GATT_CLIENT_CHAR_CFG_UUID:
|
||||
if (pAttr->handle ==
|
||||
bloodPressureAttrTbl[BLOODPRESSURE_MEAS_CONFIG_POS].handle)
|
||||
{
|
||||
// BloodPressure Indications.
|
||||
status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len,
|
||||
offset,
|
||||
GATT_CLIENT_CFG_INDICATE);
|
||||
if (status == SUCCESS)
|
||||
{
|
||||
uint16 value = BUILD_UINT16(pValue[0], pValue[1]);
|
||||
|
||||
(*bloodPressureServiceCB)((value == GATT_CFG_NO_OPERATION) ?
|
||||
BLOODPRESSURE_MEAS_NOTI_DISABLED :
|
||||
BLOODPRESSURE_MEAS_NOTI_ENABLED);
|
||||
}
|
||||
}
|
||||
else if (pAttr->handle ==
|
||||
bloodPressureAttrTbl[BLOODPRESSURE_IMEAS_CONFIG_POS].handle)
|
||||
{
|
||||
// BloodPressure Notifications.
|
||||
status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len,
|
||||
offset, GATT_CLIENT_CFG_NOTIFY);
|
||||
if (status == SUCCESS)
|
||||
{
|
||||
uint16 value = BUILD_UINT16(pValue[0], pValue[1]);
|
||||
|
||||
(*bloodPressureServiceCB)((value == GATT_CFG_NO_OPERATION) ?
|
||||
BLOODPRESSURE_IMEAS_NOTI_DISABLED :
|
||||
BLOODPRESSURE_IMEAS_NOTI_ENABLED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ATT_ERR_INVALID_HANDLE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
@@ -0,0 +1,213 @@
|
||||
/*******************************************************************************
|
||||
Filename: bpService.h
|
||||
Revised: $Date: 2014-04-21 10:36:34 -0700 (Mon, 21 Apr 2014) $
|
||||
Revision: $Revision: 38229 $
|
||||
|
||||
Description: This file contains the BloodPressure service definitions and
|
||||
prototypes.
|
||||
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef BLOODPRESSURESERVICE_H
|
||||
#define BLOODPRESSURESERVICE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// BloodPressure Service Parameters
|
||||
#define BLOODPRESSURE_MEAS 0
|
||||
#define BLOODPRESSURE_MEAS_CHAR_CFG 1
|
||||
#define BLOODPRESSURE_IMEAS_CHAR_CFG 2
|
||||
#define BLOODPRESSURE_TIMESTAMP 3
|
||||
#define BLOODPRESSURE_PULSE 4
|
||||
#define BLOODPRESSURE_INTERVAL 5
|
||||
|
||||
// Length of measurements
|
||||
#define BLOODPRESSURE_TIMESTAMP_LEN 7 //length of timestamp
|
||||
#define BLOODPRESSURE_TIME_LEN 7 //length of timestamp
|
||||
#define BLOODPRESSURE_INTERVAL_LEN 1
|
||||
|
||||
// Maximum length of blood pressure measurement characteristic
|
||||
#define BLOODPRESSURE_MEAS_MAX (ATT_MTU_SIZE -5)
|
||||
|
||||
// Values for flags
|
||||
#define BLOODPRESSURE_FLAGS_MMHG 0x00
|
||||
#define BLOODPRESSURE_FLAGS_KPA 0x01
|
||||
#define BLOODPRESSURE_FLAGS_TIMESTAMP 0x02
|
||||
#define BLOODPRESSURE_FLAGS_PULSE 0x04
|
||||
#define BLOODPRESSURE_FLAGS_USER 0x08
|
||||
#define BLOODPRESSURE_FLAGS_STATUS 0x10
|
||||
|
||||
|
||||
// Values for sensor location
|
||||
#define BLOODPRESSURE_SITE_ARMPIT 0x01
|
||||
#define BLOODPRESSURE_SITE_BODY 0x02
|
||||
#define BLOODPRESSURE_SITE_EAR 0x03
|
||||
#define BLOODPRESSURE_SITE_FINGER 0x04
|
||||
#define BLOODPRESSURE_SITE_GASTRO 0x05
|
||||
#define BLOODPRESSURE_SITE_MOUTH 0x06
|
||||
#define BLOODPRESSURE_SITE_RECTUM 0x07
|
||||
#define BLOODPRESSURE_SITE_TOE 0x08
|
||||
#define BLOODPRESSURE_SITE_TYMPNUM 0x09
|
||||
|
||||
// BloodPressure Service bit fields
|
||||
#define BLOODPRESSURE_SERVICE 0x00000001
|
||||
|
||||
// Callback events
|
||||
#define BLOODPRESSURE_MEAS_NOTI_ENABLED 1
|
||||
#define BLOODPRESSURE_MEAS_NOTI_DISABLED 2
|
||||
#define BLOODPRESSURE_IMEAS_NOTI_ENABLED 3
|
||||
#define BLOODPRESSURE_IMEAS_NOTI_DISABLED 4
|
||||
#define BLOODPRESSURE_TIME_SET 5
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
// BloodPressure Service callback function
|
||||
typedef void (*bloodPressureServiceCB_t)(uint8 event);
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Callbacks
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* API FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* @fn BloodPressure_AddService
|
||||
*
|
||||
* @brief Initializes the BloodPressure 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
|
||||
*/
|
||||
extern bStatus_t BloodPressure_AddService(uint32 services);
|
||||
|
||||
/*
|
||||
* @fn BloodPressure_Register
|
||||
*
|
||||
* @brief Register a callback function with the BloodPressure Service.
|
||||
*
|
||||
* @param pfnServiceCB - Callback function.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
extern void BloodPressure_Register(bloodPressureServiceCB_t pfnServiceCB);
|
||||
|
||||
/*
|
||||
* BloodPressure_SetParameter - Set a BloodPressure 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
|
||||
*/
|
||||
extern bStatus_t BloodPressure_SetParameter(uint8 param, uint8 len,
|
||||
void *value);
|
||||
|
||||
/*
|
||||
* BloodPressure_GetParameter - Get a BloodPressure parameter.
|
||||
*
|
||||
* @param param - Profile parameter ID
|
||||
* @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
|
||||
*/
|
||||
extern bStatus_t BloodPressure_GetParameter(uint8 param, void *value);
|
||||
|
||||
/*********************************************************************
|
||||
* @fn BloodPressure_MeasIndicate
|
||||
*
|
||||
* @brief Send a notification containing a blood pressure
|
||||
* measurement.
|
||||
*
|
||||
* @param connHandle - connection handle
|
||||
* @param pNoti - pointer to notification structure
|
||||
* @param taskId - calling task's Id.
|
||||
*
|
||||
* @return Success or Failure
|
||||
*/
|
||||
extern bStatus_t BloodPressure_MeasIndicate(uint16 connHandle,
|
||||
attHandleValueInd_t *pNoti,
|
||||
uint8 taskId);
|
||||
|
||||
/*********************************************************************
|
||||
* @fn BloodPressure_IMeasNotify
|
||||
*
|
||||
* @brief Send a notification containing a blood pressure
|
||||
* measurement.
|
||||
*
|
||||
* @param connHandle - connection handle
|
||||
* @param pNoti - pointer to notification structure
|
||||
* @param taskId - calling task's Id.
|
||||
*
|
||||
* @return Success or Failure
|
||||
*/
|
||||
extern bStatus_t BloodPressure_IMeasNotify(uint16 connHandle,
|
||||
attHandleValueNoti_t *pNoti,
|
||||
uint8 taskId);
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLOODPRESSURESERVICE_H */
|
||||
Reference in New Issue
Block a user