initial commit

This commit is contained in:
2022-10-23 23:45:43 -07:00
commit e190fa5193
6450 changed files with 8626944 additions and 0 deletions
@@ -0,0 +1,432 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Alert-related services implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_alert.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef ALERT_SEC_PERMIT_READ
#define ALERT_SEC_PERMIT_READ SVC_SEC_PERMIT_READ
#endif
/*! Characteristic write permissions */
#ifndef ALERT_SEC_PERMIT_WRITE
#define ALERT_SEC_PERMIT_WRITE SVC_SEC_PERMIT_WRITE
#endif
/**************************************************************************************************
Alert-Related Services group
**************************************************************************************************/
/*!
* Alert notification service
*/
/* Alert notification declaration */
static const uint8_t alertAnsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_ALERT_NOTIF_SERVICE)};
static const uint16_t alertAnsLenSvc = sizeof(alertAnsValSvc);
/* Supported new alert category characteristic */
static const uint8_t alertAnsValSnaCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(ALERT_ANS_SNA_HDL), UINT16_TO_BYTES(ATT_UUID_SUP_NEW_ALERT_CAT)};
static const uint16_t alertAnsLenSnaCh = sizeof(alertAnsValSnaCh);
/* Supported new alert category */
static const uint8_t alertAnsUuSna[] = {UINT16_TO_BYTES(ATT_UUID_SUP_NEW_ALERT_CAT)};
static uint8_t alertAnsValSna[] = {0xFF,0x03};
static uint16_t alertAnsLenSna = sizeof(alertAnsValSna);
/* New alert characteristic */
static const uint8_t alertAnsValNewCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(ALERT_ANS_NEW_HDL), UINT16_TO_BYTES(ATT_UUID_NEW_ALERT)};
static const uint16_t alertAnsLenNewCh = sizeof(alertAnsValNewCh);
/* New alert */
static const uint8_t alertAnsUuNew[] = {UINT16_TO_BYTES(ATT_UUID_NEW_ALERT)};
static uint8_t alertAnsValNew[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
static uint16_t alertAnsLenNew = sizeof(alertAnsValNew);
/* New alert client characteristic configuration */
static uint8_t alertAnsValNewChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t alertAnsLenNewChCcc = sizeof(alertAnsValNewChCcc);
/* Supported unread alert category characteristic */
static const uint8_t alertAnsValUnrCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(ALERT_ANS_UNR_HDL), UINT16_TO_BYTES(ATT_UUID_SUP_UNREAD_ALERT_CAT)};
static const uint16_t alertAnsLenUnrCh = sizeof(alertAnsValUnrCh);
/* Supported unread alert category */
static const uint8_t alertAnsUuUnr[] = {UINT16_TO_BYTES(ATT_UUID_SUP_UNREAD_ALERT_CAT)};
static uint8_t alertAnsValUnr[] = {0xFF,0x03};
static uint16_t alertAnsLenUnr = sizeof(alertAnsValUnr);
/* Unread alert status characteristic */
static const uint8_t alertAnsValUasCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(ALERT_ANS_UAS_HDL), UINT16_TO_BYTES(ATT_UUID_UNREAD_ALERT_STATUS)};
static const uint16_t alertAnsLenUasCh = sizeof(alertAnsValUasCh);
/* Unread alert status */
static const uint8_t alertAnsUuUas[] = {UINT16_TO_BYTES(ATT_UUID_UNREAD_ALERT_STATUS)};
static uint8_t alertAnsValUas[] = {0x00,0x00};
static uint16_t alertAnsLenUas = sizeof(alertAnsValUas);
/* Unread alert status client characteristic configuration */
static uint8_t alertAnsValUasChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t alertAnsLenUasChCcc = sizeof(alertAnsValUasChCcc);
/* Alert notification control point characteristic */
static const uint8_t alertAnsValCpCh[] = {ATT_PROP_WRITE, UINT16_TO_BYTES(ALERT_ANS_CP_HDL), UINT16_TO_BYTES(ATT_UUID_ALERT_NOTIF_CP)};
static const uint16_t alertAnsLenCpCh = sizeof(alertAnsValCpCh);
/* Alert notification control point */
static const uint8_t alertAnsUuCp[] = {UINT16_TO_BYTES(ATT_UUID_ALERT_NOTIF_CP)};
static uint8_t alertAnsValCp[] = {0, 0};
static const uint16_t alertAnsLenCp = sizeof(alertAnsValCp);
/*!
* Phone alert status service
*/
/* Alert status client characteristic configuration */
/* Ringer setting characteristic */
/* Ringer setting */
/* Ringer settting client characteristic configuration */
/* Ringer control point characteristic */
/* Ringer control point */
/* Phone alert status service declaration */
static const uint8_t alertPassValSvc[] = {UINT16_TO_BYTES(ATT_UUID_PHONE_ALERT_SERVICE)};
static const uint16_t alertPassLenSvc = sizeof(alertPassValSvc);
/* Alert status characteristic */
static const uint8_t alertPassValAsCh[] = {ATT_PROP_READ | ATT_PROP_NOTIFY, UINT16_TO_BYTES(ALERT_PASS_AS_HDL), UINT16_TO_BYTES(ATT_UUID_ALERT_STATUS)};
static const uint16_t alertPassLenAsCh = sizeof(alertPassValAsCh);
/* Alert status */
static const uint8_t alertPassUuAs[] = {UINT16_TO_BYTES(ATT_UUID_ALERT_STATUS)};
static uint8_t alertPassValAs[] = {0};
static const uint16_t alertPassLenAs = sizeof(alertPassValAs);
/* Alert status client characteristic configuration */
static uint8_t alertPassValAsChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t alertPassLenAsChCcc = sizeof(alertPassValAsChCcc);
/* Ringer setting characteristic */
static const uint8_t alertPassValRsCh[] = {ATT_PROP_READ | ATT_PROP_NOTIFY, UINT16_TO_BYTES(ALERT_PASS_RS_HDL), UINT16_TO_BYTES(ATT_UUID_RINGER_SETTING)};
static const uint16_t alertPassLenRsCh = sizeof(alertPassValRsCh);
/* Ringer setting */
static const uint8_t alertPassUuRs[] = {UINT16_TO_BYTES(ATT_UUID_RINGER_SETTING)};
static uint8_t alertPassValRs[] = {0};
static const uint16_t alertPassLenRs = sizeof(alertPassValRs);
/* Ringer setting client characteristic configuration */
static uint8_t alertPassValRsChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t alertPassLenRsChCcc = sizeof(alertPassValRsChCcc);
/* Ringer control point characteristic */
static const uint8_t alertPassValRcpCh[] = {ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(ALERT_PASS_RCP_HDL), UINT16_TO_BYTES(ATT_UUID_RINGER_CP)};
static const uint16_t alertPassLenRcpCh = sizeof(alertPassValRcpCh);
/* Ringer control point */
static const uint8_t alertPassUuRcp[] = {UINT16_TO_BYTES(ATT_UUID_RINGER_CP)};
static uint8_t alertPassValRcp[] = {0};
static const uint16_t alertPassLenRcp = sizeof(alertPassValRcp);
/*!
* Network availability service
*/
/* Network availability service declaration */
static const uint8_t alertNwsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_NETWORK_AVAIL_SERVICE)};
static const uint16_t alertNwsLenSvc = sizeof(alertNwsValSvc);
/* Network availability characteristic */
static const uint8_t alertNwsValNwaCh[] = {ATT_PROP_READ | ATT_PROP_INDICATE, UINT16_TO_BYTES(ALERT_NWS_NWA_HDL), UINT16_TO_BYTES(ATT_UUID_NETWORK_AVAIL)};
static const uint16_t alertNwsLenNwaCh = sizeof(alertNwsValNwaCh);
/* Network availability */
static const uint8_t alertNwsUuNwa[] = {UINT16_TO_BYTES(ATT_UUID_NETWORK_AVAIL)};
static uint8_t alertNwsValNwa[] = {0};
static const uint16_t alertNwsLenNwa = sizeof(alertNwsValNwa);
/* Network availability client characteristic configuration */
static uint8_t alertNwsValNwaChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t alertNwsLenNwaChCcc = sizeof(alertNwsValNwaChCcc);
/* Attribute list for group */
static const attsAttr_t alertList[] =
{
/* Alert notification service */
{
attPrimSvcUuid,
(uint8_t *) alertAnsValSvc,
(uint16_t *) &alertAnsLenSvc,
sizeof(alertAnsValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) alertAnsValSnaCh,
(uint16_t *) &alertAnsLenSnaCh,
sizeof(alertAnsValSnaCh),
0,
ATTS_PERMIT_READ
},
{
alertAnsUuSna,
alertAnsValSna,
&alertAnsLenSna,
sizeof(alertAnsValSna),
0,
ALERT_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) alertAnsValNewCh,
(uint16_t *) &alertAnsLenNewCh,
sizeof(alertAnsValNewCh),
0,
ATTS_PERMIT_READ
},
{
alertAnsUuNew,
alertAnsValNew,
&alertAnsLenNew,
sizeof(alertAnsValNew),
0,
0
},
{
attCliChCfgUuid,
alertAnsValNewChCcc,
(uint16_t *) &alertAnsLenNewChCcc,
sizeof(alertAnsValNewChCcc),
0,
(ATTS_PERMIT_READ | ALERT_SEC_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) alertAnsValUnrCh,
(uint16_t *) &alertAnsLenUnrCh,
sizeof(alertAnsValUnrCh),
0,
ATTS_PERMIT_READ
},
{
alertAnsUuUnr,
alertAnsValUnr,
&alertAnsLenUnr,
sizeof(alertAnsValUnr),
0,
ALERT_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) alertAnsValUasCh,
(uint16_t *) &alertAnsLenUasCh,
sizeof(alertAnsValUasCh),
0,
ATTS_PERMIT_READ
},
{
alertAnsUuUas,
alertAnsValUas,
&alertAnsLenUas,
sizeof(alertAnsValUas),
0,
0
},
{
attCliChCfgUuid,
alertAnsValUasChCcc,
(uint16_t *) &alertAnsLenUasChCcc,
sizeof(alertAnsValUasChCcc),
0,
(ATTS_PERMIT_READ | ALERT_SEC_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) alertAnsValCpCh,
(uint16_t *) &alertAnsLenCpCh,
sizeof(alertAnsValCpCh),
0,
ATTS_PERMIT_READ
},
{
alertAnsUuCp,
alertAnsValCp,
(uint16_t *) &alertAnsLenCp,
sizeof(alertAnsValCp),
0,
ALERT_SEC_PERMIT_WRITE
},
/* Phone alert status service */
{
attPrimSvcUuid,
(uint8_t *) alertPassValSvc,
(uint16_t *) &alertPassLenSvc,
sizeof(alertPassValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) alertPassValAsCh,
(uint16_t *) &alertPassLenAsCh,
sizeof(alertPassValAsCh),
0,
ATTS_PERMIT_READ
},
{
alertPassUuAs,
alertPassValAs,
(uint16_t *) &alertPassLenAs,
sizeof(alertPassValAs),
0,
ALERT_SEC_PERMIT_READ
},
{
attCliChCfgUuid,
alertPassValAsChCcc,
(uint16_t *) &alertPassLenAsChCcc,
sizeof(alertPassValAsChCcc),
0,
(ATTS_PERMIT_READ | ALERT_SEC_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) alertPassValRsCh,
(uint16_t *) &alertPassLenRsCh,
sizeof(alertPassValRsCh),
0,
ATTS_PERMIT_READ
},
{
alertPassUuRs,
alertPassValRs,
(uint16_t *) &alertPassLenRs,
sizeof(alertPassValRs),
0,
ALERT_SEC_PERMIT_READ
},
{
attCliChCfgUuid,
alertPassValRsChCcc,
(uint16_t *) &alertPassLenRsChCcc,
sizeof(alertPassValRsChCcc),
0,
(ATTS_PERMIT_READ | ALERT_SEC_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) alertPassValRcpCh,
(uint16_t *) &alertPassLenRcpCh,
sizeof(alertPassValRcpCh),
0,
ATTS_PERMIT_READ
},
{
alertPassUuRcp,
alertPassValRcp,
(uint16_t *) &alertPassLenRcp,
sizeof(alertPassValRcp),
0,
ALERT_SEC_PERMIT_WRITE
},
/* Network availability service */
{
attPrimSvcUuid,
(uint8_t *) alertNwsValSvc,
(uint16_t *) &alertNwsLenSvc,
sizeof(alertNwsValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) alertNwsValNwaCh,
(uint16_t *) &alertNwsLenNwaCh,
sizeof(alertNwsValNwaCh),
0,
ATTS_PERMIT_READ
},
{
alertNwsUuNwa,
alertNwsValNwa,
(uint16_t *) &alertNwsLenNwa,
sizeof(alertNwsValNwa),
0,
ALERT_SEC_PERMIT_READ
},
{
attCliChCfgUuid,
alertNwsValNwaChCcc,
(uint16_t *) &alertNwsLenNwaChCcc,
sizeof(alertNwsValNwaChCcc),
0,
(ATTS_PERMIT_READ | ALERT_SEC_PERMIT_WRITE)
},
};
/* Alert group structure */
static attsGroup_t svcAlertGroup =
{
NULL,
(attsAttr_t *) alertList,
NULL,
NULL,
ALERT_START_HDL,
ALERT_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcAlertAddGroup(void)
{
AttsAddGroup(&svcAlertGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcAlertRemoveGroup(void)
{
AttsRemoveGroup(ALERT_START_HDL);
}
@@ -0,0 +1,115 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Alert-related service implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_ALERT_H
#define SVC_ALERT_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup ALERT-RELATED_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Alert Handles
*
*/
/**@{*/
#define ALERT_START_HDL 0xA0 /*!< \brief Start handle. */
#define ALERT_END_HDL (ALERT_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Alert-Related Service Handles */
enum
{
ALERT_ANS_SVC_HDL = ALERT_START_HDL, /*!< \brief Alert notification service declaration */
ALERT_ANS_SNA_CH_HDL, /*!< \brief Supported new alert category characteristic */
ALERT_ANS_SNA_HDL, /*!< \brief Supported new alert category */
ALERT_ANS_NEW_CH_HDL, /*!< \brief New alert characteristic */
ALERT_ANS_NEW_HDL, /*!< \brief New alert */
ALERT_ANS_NEW_CH_CCC_HDL, /*!< \brief New alert client characteristic configuration */
ALERT_ANS_UNR_CH_HDL, /*!< \brief Supported unread alert category characteristic */
ALERT_ANS_UNR_HDL, /*!< \brief Supported unread alert category */
ALERT_ANS_UAS_CH_HDL, /*!< \brief Unread alert status characteristic */
ALERT_ANS_UAS_HDL, /*!< \brief Unread alert status */
ALERT_ANS_UAS_CH_CCC_HDL, /*!< \brief Unread alert status client characteristic configuration */
ALERT_ANS_CP_CH_HDL, /*!< \brief Alert notification control point characteristic */
ALERT_ANS_CP_HDL, /*!< \brief Alert notification control point */
ALERT_PASS_SVC_HDL, /*!< \brief Phone alert status service declaration */
ALERT_PASS_AS_CH_HDL, /*!< \brief Alert status characteristic */
ALERT_PASS_AS_HDL, /*!< \brief Alert status */
ALERT_PASS_AS_CCC_HDL, /*!< \brief Alert status client characteristic configuration */
ALERT_PASS_RS_CH_HDL, /*!< \brief Ringer setting characteristic */
ALERT_PASS_RS_HDL, /*!< \brief Ringer setting */
ALERT_PASS_RS_CCC_HDL, /*!< \brief Ringer settting client characteristic configuration */
ALERT_PASS_RCP_CH_HDL, /*!< \brief Ringer control point characteristic */
ALERT_PASS_RCP_HDL, /*!< \brief Ringer control point */
ALERT_NWS_SVC_HDL, /*!< \brief Network availability service declaration */
ALERT_NWS_NWA_CH_HDL, /*!< \brief Network availability characteristic */
ALERT_NWS_NWA_HDL, /*!< \brief Network availability */
ALERT_NWS_NWA_CH_CCC_HDL, /*!< \brief Network availability client characteristic configuration */
ALERT_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcAlertAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcAlertRemoveGroup(void);
/*! \} */ /* ALERT-RELATED_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_ALERT_H */
@@ -0,0 +1,196 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Battery service implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "util/bstream.h"
#include "svc_batt.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef BATT_SEC_PERMIT_READ
#define BATT_SEC_PERMIT_READ SVC_SEC_PERMIT_READ
#endif
/*! Characteristic write permissions */
#ifndef BATT_SEC_PERMIT_WRITE
#define BATT_SEC_PERMIT_WRITE SVC_SEC_PERMIT_WRITE
#endif
/**************************************************************************************************
Battery Service group
**************************************************************************************************/
/*!
* Battery service
*/
/* Battery service declaration */
static const uint8_t battValSvc[] = {UINT16_TO_BYTES(ATT_UUID_BATTERY_SERVICE)};
static const uint16_t battLenSvc = sizeof(battValSvc);
/* Battery level characteristic */
static const uint8_t battValLvlCh[] = {ATT_PROP_READ | ATT_PROP_NOTIFY, UINT16_TO_BYTES(BATT_LVL_HDL), UINT16_TO_BYTES(ATT_UUID_BATTERY_LEVEL)};
static const uint16_t battLenLvlCh = sizeof(battValLvlCh);
/* Battery level */
static uint8_t battValLvl[] = {0};
static const uint16_t battLenLvl = sizeof(battValLvl);
/* Battery level client characteristic configuration */
static uint8_t battValLvlChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t battLenLvlChCcc = sizeof(battValLvlChCcc);
/* Attribute list for group */
static const attsAttr_t battList[] =
{
/* Service declaration */
{
attPrimSvcUuid,
(uint8_t *) battValSvc,
(uint16_t *) &battLenSvc,
sizeof(battValSvc),
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration */
{
attChUuid,
(uint8_t *) battValLvlCh,
(uint16_t *) &battLenLvlCh,
sizeof(battValLvlCh),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
attBlChUuid,
battValLvl,
(uint16_t *) &battLenLvl,
sizeof(battValLvl),
ATTS_SET_READ_CBACK,
BATT_SEC_PERMIT_READ
},
/* Characteristic CCC descriptor */
{
attCliChCfgUuid,
battValLvlChCcc,
(uint16_t *) &battLenLvlChCcc,
sizeof(battValLvlChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | BATT_SEC_PERMIT_WRITE)
}
};
/* Battery group structure */
static attsGroup_t svcBattGroup =
{
NULL,
(attsAttr_t *) battList,
NULL,
NULL,
BATT_START_HDL,
BATT_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBattAddGroup(void)
{
AttsAddGroup(&svcBattGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBattRemoveGroup(void)
{
AttsRemoveGroup(BATT_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBattCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcBattGroup.readCback = readCback;
svcBattGroup.writeCback = writeCback;
}
/*************************************************************************************************/
/*!
* \brief Add the battery service using the dynamic attribute subsystem.
*
* \return None.
*/
/*************************************************************************************************/
void *SvcBattAddGroupDyn()
{
void *pSHdl;
uint8_t initCcc[] = {UINT16_TO_BYTES(0x0000)};
uint8_t initBatVal[] = {0};
/* Create the service */
pSHdl = AttsDynCreateGroup(BATT_START_HDL, BATT_END_HDL);
if (pSHdl != NULL)
{
/* Primary service */
AttsDynAddAttrConst(pSHdl, attPrimSvcUuid, battValSvc, sizeof(battValSvc), 0, ATTS_PERMIT_READ);
/* Battery level characteristic */
AttsDynAddAttrConst(pSHdl, attChUuid, battValLvlCh, sizeof(battValLvlCh), 0, ATTS_PERMIT_READ);
/* Battery level value */
AttsDynAddAttr(pSHdl, attBlChUuid, initBatVal, sizeof(uint8_t), sizeof(uint8_t),
ATTS_SET_READ_CBACK, ATTS_PERMIT_READ);
/* Battery level CCC descriptor */
AttsDynAddAttr(pSHdl, attCliChCfgUuid, initCcc, sizeof(uint16_t), sizeof(uint16_t),
ATTS_SET_CCC, ATTS_PERMIT_READ | ATTS_PERMIT_WRITE);
}
return pSHdl;
}
@@ -0,0 +1,111 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Battery service implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_BATT_H
#define SVC_BATT_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup BATTERY_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Battery Service Handles
*
*/
/**@{*/
#define BATT_START_HDL 0x60 /*!< \brief Service start handle. */
#define BATT_END_HDL (BATT_MAX_HDL - 1) /*!< \brief Service end handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Battery Service Handles */
enum
{
BATT_SVC_HDL = BATT_START_HDL, /*!< \brief Battery service declaration */
BATT_LVL_CH_HDL, /*!< \brief Battery level characteristic */
BATT_LVL_HDL, /*!< \brief Battery level */
BATT_LVL_CH_CCC_HDL, /*!< \brief Battery level CCCD */
BATT_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBattAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBattRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBattCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*************************************************************************************************/
/*!
* \brief Add the battery service using the dynamic attribute subsystem.
*
* \return None.
*/
/*************************************************************************************************/
void *SvcBattAddGroupDyn(void);
/*! \} */ /* BATTERY_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_BATT_H */
@@ -0,0 +1,247 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Blood Pressure service implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_bps.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef BPS_SEC_PERMIT_READ
#define BPS_SEC_PERMIT_READ (ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC)
#endif
/*! Characteristic write permissions */
#ifndef BPS_SEC_PERMIT_WRITE
#define BPS_SEC_PERMIT_WRITE (ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC)
#endif
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Blood pressure service declaration */
static const uint8_t bpsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_BLOOD_PRESSURE_SERVICE)};
static const uint16_t bpsLenSvc = sizeof(bpsValSvc);
/* Blood pressure measurement characteristic */
static const uint8_t bpsValBpmCh[] = {ATT_PROP_INDICATE, UINT16_TO_BYTES(BPS_BPM_HDL), UINT16_TO_BYTES(ATT_UUID_BP_MEAS)};
static const uint16_t bpsLenBpmCh = sizeof(bpsValBpmCh);
/* Blood pressure measurement */
/* Note these are dummy values */
static const uint8_t bpsValBpm[] = {0};
static const uint16_t bpsLenBpm = sizeof(bpsValBpm);
/* Blood pressure measurement client characteristic configuration */
static uint8_t bpsValBpmChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t bpsLenBpmChCcc = sizeof(bpsValBpmChCcc);
/* Intermediate cuff pressure characteristic */
static const uint8_t bpsValIcpCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(BPS_ICP_HDL), UINT16_TO_BYTES(ATT_UUID_INTERMEDIATE_BP)};
static const uint16_t bpsLenIcpCh = sizeof(bpsValIcpCh);
/* Intermediate cuff pressure */
/* Note these are dummy values */
static const uint8_t bpsValIcp[] = {0};
static const uint16_t bpsLenIcp = sizeof(bpsValIcp);
/* Intermediate cuff pressure client characteristic configuration */
static uint8_t bpsValIcpChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t bpsLenIcpChCcc = sizeof(bpsValIcpChCcc);
/* Blood pressure feature characteristic */
static const uint8_t bpsValBpfCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(BPS_BPF_HDL), UINT16_TO_BYTES(ATT_UUID_BP_FEATURE)};
static const uint16_t bpsLenBpfCh = sizeof(bpsValBpfCh);
/* Blood pressure feature */
static uint8_t bpsValBpf[] = {UINT16_TO_BYTES(CH_BPF_FLAG_MOVEMENT | CH_BPF_FLAG_CUFF_FIT | CH_BPF_FLAG_IRR_PULSE |
CH_BPF_FLAG_PULSE_RANGE | CH_BPF_FLAG_MEAS_POS)};
static const uint16_t bpsLenBpf = sizeof(bpsValBpf);
/* Attribute list for BPS group */
static const attsAttr_t bpsList[] =
{
/* Blood pressure service declaration */
{
attPrimSvcUuid,
(uint8_t *) bpsValSvc,
(uint16_t *) &bpsLenSvc,
sizeof(bpsValSvc),
0,
ATTS_PERMIT_READ
},
/* Blood pressure measurement characteristic */
{
attChUuid,
(uint8_t *) bpsValBpmCh,
(uint16_t *) &bpsLenBpmCh,
sizeof(bpsValBpmCh),
0,
ATTS_PERMIT_READ
},
/* Blood pressure measurement */
{
attBpmChUuid,
(uint8_t *) bpsValBpm,
(uint16_t *) &bpsLenBpm,
sizeof(bpsValBpm),
0,
0
},
/* Blood pressure measurement client characteristic configuration */
{
attCliChCfgUuid,
(uint8_t *) bpsValBpmChCcc,
(uint16_t *) &bpsLenBpmChCcc,
sizeof(bpsValBpmChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | BPS_SEC_PERMIT_WRITE)
},
/* Intermediate cuff pressure characteristic */
{
attChUuid,
(uint8_t *) bpsValIcpCh,
(uint16_t *) &bpsLenIcpCh,
sizeof(bpsValIcpCh),
0,
ATTS_PERMIT_READ
},
/* Intermediate cuff pressure */
{
attIcpChUuid,
(uint8_t *) bpsValIcp,
(uint16_t *) &bpsLenIcp,
sizeof(bpsValIcp),
0,
0
},
/* Intermediate cuff pressure client characteristic configuration */
{
attCliChCfgUuid,
(uint8_t *) bpsValIcpChCcc,
(uint16_t *) &bpsLenIcpChCcc,
sizeof(bpsValIcpChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | BPS_SEC_PERMIT_WRITE)
},
/* Blood pressure feature characteristic */
{
attChUuid,
(uint8_t *) bpsValBpfCh,
(uint16_t *) &bpsLenBpfCh,
sizeof(bpsValBpfCh),
0,
ATTS_PERMIT_READ
},
/* Blood pressure feature */
{
attBpfChUuid,
bpsValBpf,
(uint16_t *) &bpsLenBpf,
sizeof(bpsValBpf),
0,
BPS_SEC_PERMIT_READ
}
};
/* BPS group structure */
static attsGroup_t svcBpsGroup =
{
NULL,
(attsAttr_t *) bpsList,
NULL,
NULL,
BPS_START_HDL,
BPS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBpsAddGroup(void)
{
AttsAddGroup(&svcBpsGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBpsRemoveGroup(void)
{
AttsRemoveGroup(BPS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBpsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcBpsGroup.readCback = readCback;
svcBpsGroup.writeCback = writeCback;
}
/*************************************************************************************************/
/*!
* \brief Toggle flag values.
*
* \param flag Flag to manipulate.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBpsToggleFeatureFlags(uint8_t flag)
{
if (bpsValBpf[0] & flag)
{
bpsValBpf[0] &= ~flag;
}
else
{
bpsValBpf[0] |= flag;
}
}
@@ -0,0 +1,117 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Blood Pressure service implementation.
*
* Copyright (c) 2012-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_BPS_H
#define SVC_BPS_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup BLOOD_PRESSURE_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Blood Pressure Service Handles
*
*/
/**@{*/
#define BPS_START_HDL 0xE0 /*!< \brief Start handle. */
#define BPS_END_HDL (BPS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Blood Pressure Service Handles */
enum
{
BPS_SVC_HDL = BPS_START_HDL, /*!< \brief Blood pressure service declaration */
BPS_BPM_CH_HDL, /*!< \brief Blood pressure measurement characteristic */
BPS_BPM_HDL, /*!< \brief Blood pressure measurement */
BPS_BPM_CH_CCC_HDL, /*!< \brief Blood pressure measurement client characteristic configuration */
BPS_ICP_CH_HDL, /*!< \brief Intermediate cuff pressure characteristic */
BPS_ICP_HDL, /*!< \brief Intermediate cuff pressure */
BPS_ICP_CH_CCC_HDL, /*!< \brief Intermediate cuff pressure client characteristic configuration */
BPS_BPF_CH_HDL, /*!< \brief Blood pressure feature characteristic */
BPS_BPF_HDL, /*!< \brief Blood pressure feature */
BPS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBpsAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBpsRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBpsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*************************************************************************************************/
/*!
* \brief Toggle flag values.
*
* \param flag Flag to manipulate.
*
* \return None.
*/
/*************************************************************************************************/
void SvcBpsToggleFeatureFlags(uint8_t flag);
/*! \} */ /* BLOOD_PRESSURE_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_BPS_H */
@@ -0,0 +1,54 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Service configuration.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_CFG_H
#define SVC_CFG_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup SERVICE_CONFIGURATION
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief Default read security permissions for service characteristics */
#ifndef SVC_SEC_PERMIT_READ
#define SVC_SEC_PERMIT_READ ATTS_PERMIT_READ
#endif
/*! \brief Default write security permissions for service characteristics */
#ifndef SVC_SEC_PERMIT_WRITE
#define SVC_SEC_PERMIT_WRITE ATTS_PERMIT_WRITE
#endif
/*! \} */ /* SERVICE_CONFIGURATION */
#ifdef __cplusplus
};
#endif
#endif /* SVC_CFG_H */
@@ -0,0 +1,708 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Characteristic constants.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_CH_H
#define SVC_CH_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup SERVICE_CONSTANTS
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/** \name Appearance Values
*
*/
/**@{*/
#define CH_APPEAR_UNKNOWN 0 /*!< \brief Unknown */
#define CH_APPEAR_PHONE 64 /*!< \brief Generic Phone */
#define CH_APPEAR_COMPUTER 128 /*!< \brief Generic Computer */
#define CH_APPEAR_WATCH 192 /*!< \brief Generic Watch */
#define CH_APPEAR_WATCH_SPORTS 193 /*!< \brief Watch: Sports Watch */
#define CH_APPEAR_CLOCK 256 /*!< \brief Generic Clock */
#define CH_APPEAR_DISPLAY 320 /*!< \brief Generic Display */
#define CH_APPEAR_REMOTE 384 /*!< \brief Generic Remote Control */
#define CH_APPEAR_GLASSES 448 /*!< \brief Generic Eye-glasses */
#define CH_APPEAR_TAG 512 /*!< \brief Generic Tag */
#define CH_APPEAR_KEYRING 576 /*!< \brief Generic Keyring */
#define CH_APPEAR_PLAYER 640 /*!< \brief Generic Media Player */
#define CH_APPEAR_BARCODE 704 /*!< \brief Generic Barcode Scanner */
#define CH_APPEAR_THERM 768 /*!< \brief Generic Thermometer */
#define CH_APPEAR_THERM_EAR 769 /*!< \brief Thermometer: Ear */
#define CH_APPEAR_HR 832 /*!< \brief Generic Heart rate Sensor */
#define CH_APPEAR_HR_BELT 833 /*!< \brief Heart Rate Sensor: Heart Rate Belt */
#define CH_APPEAR_BP 896 /*!< \brief Generic Blood Pressure */
#define CH_APPEAR_BP_ARM 897 /*!< \brief Blood Pressure: Arm */
#define CH_APPEAR_BP_WRIST 898 /*!< \brief Blood Pressure: Wrist */
#define CH_APPEAR_HID 960 /*!< \brief Human Interface Device (HID) */
#define CH_APPEAR_HID_KEYBOARD 961 /*!< \brief Keyboard */
#define CH_APPEAR_HID_MOUSE 962 /*!< \brief Mouse */
#define CH_APPEAR_HID_JOYSTICK 963 /*!< \brief Joystick */
#define CH_APPEAR_HID_GAMEPAD 964 /*!< \brief Gamepad */
#define CH_APPEAR_HID_TABLET 965 /*!< \brief Digitizer Tablet */
#define CH_APPEAR_HID_READER 966 /*!< \brief Card Reader */
#define CH_APPEAR_HID_PEN 967 /*!< \brief Digital Pen */
#define CH_APPEAR_HID_BARCODE 968 /*!< \brief Barcode Scanner */
#define CH_APPEAR_GLUCOSE 1024 /*!< \brief Generic Glucose Meter */
#define CH_APPEAR_RUN 1088 /*!< \brief Generic: Running Walking Sensor */
#define CH_APPEAR_RUN_IN_SHOE 1089 /*!< \brief Running Walking Sensor: In-Shoe */
#define CH_APPEAR_RUN_ON_SHOE 1090 /*!< \brief Running Walking Sensor: On-Shoe */
#define CH_APPEAR_RUN_ON_HIP 1091 /*!< \brief Running Walking Sensor: On-Hip */
#define CH_APPEAR_CYCL 1152 /*!< \brief Generic: Cycling */
#define CH_APPEAR_CYCL_COMP 1153 /*!< \brief Cycling: Cycling Computer */
#define CH_APPEAR_CYCL_SPEED 1154 /*!< \brief Cycling: Speed Sensor */
#define CH_APPEAR_CYCL_CAD 1155 /*!< \brief Cycling: Cadence Sensor */
#define CH_APPEAR_CYCL_POWER 1156 /*!< \brief Cycling: Power Sensor */
#define CH_APPEAR_CYCL_SPEED_CAD 1157 /*!< \brief Cycling: Speed and Cadence Sensor */
#define CH_APPEAR_LEN 2 /*!< \brief Length in bytes*/
/**@}*/
/** \name Alert Level Values
*
*/
/**@{*/
#define CH_ALERT_LVL_NONE 0 /*!< \brief No Alert */
#define CH_ALERT_LVL_MILD 1 /*!< \brief Mild Alert */
#define CH_ALERT_LVL_HIGH 2 /*!< \brief High Alert */
#define CH_ALERT_LVL_LEN 1 /*!< \brief Length in bytes*/
/**@}*/
/** \name Heart Rate Measurement Flags
*
*/
/**@{*/
#define CH_HRM_FLAGS_VALUE_8BIT 0x00 /*!< \brief Heart Rate Value Format is set to UINT8 */
#define CH_HRM_FLAGS_VALUE_16BIT 0x01 /*!< \brief Heart Rate Value Format is set to UINT16 */
#define CH_HRM_FLAGS_SENSOR_NOT_SUP 0x00 /*!< \brief Sensor Contact feature is not supported */
#define CH_HRM_FLAGS_SENSOR_NOT_DET 0x04 /*!< \brief Sensor Contact feature is supported, but contact is not detected */
#define CH_HRM_FLAGS_SENSOR_DET 0x06 /*!< \brief Sensor Contact feature is supported and contact is detected */
#define CH_HRM_FLAGS_ENERGY_EXP 0x08 /*!< \brief Energy Expended field is present */
#define CH_HRM_FLAGS_RR_INTERVAL 0x10 /*!< \brief One or more RR-Interval values are present */
/**@}*/
/** \name Heart Rate Measurement Field Lengths
*
*/
/**@{*/
#define CH_HRM_LEN_VALUE_8BIT 1 /*!< \brief Heart rate measurement 8-bit value length. */
#define CH_HRM_LEN_VALUE_16BIT 2 /*!< \brief Heart rate measurement 16-bit value length. */
#define CH_HRM_LEN_ENERGY_EXP 2 /*!< \brief Heart rate measurement exponent value length. */
#define CH_HRM_LEN_RR_INTERVAL 2 /*!< \brief Heart rate measurement RR interval value length. */
/**@}*/
/** \name Body Sensor Locations
*
*/
/**@{*/
#define CH_BSENSOR_LOC_OTHER 0 /*!< \brief Other */
#define CH_BSENSOR_LOC_CHEST 1 /*!< \brief Chest */
#define CH_BSENSOR_LOC_WRIST 2 /*!< \brief Wrist */
#define CH_BSENSOR_LOC_FINGER 3 /*!< \brief Finger */
#define CH_BSENSOR_LOC_HAND 4 /*!< \brief Hand */
#define CH_BSENSOR_LOC_EARLOBE 5 /*!< \brief Ear Lobe */
#define CH_BSENSOR_LOC_FOOT 6 /*!< \brief Foot */
#define CH_BSENSOR_LOC_LEN 1 /*!< \brief Length in bytes */
/**@}*/
/** \name Heart Rate Control Point
*
*/
/**@{*/
#define CH_HRCP_RESET_ENERGY_EXP 1 /*!< \brief Reset Energy Expended */
/**@}*/
/** \name Alert Notification Control Point
*
*/
/**@{*/
#define CH_ANCP_ENABLE_NEW 0 /*!< \brief Enable New Incoming Alert Notification */
#define CH_ANCP_ENABLE_UNREAD 1 /*!< \brief Enable Unread Category Status Notification */
#define CH_ANCP_DISABLE_NEW 2 /*!< \brief Disable New Incoming Alert Notification */
#define CH_ANCP_DISABLE_UNREAD 3 /*!< \brief Disable Unread Category Status Notification */
#define CH_ANCP_NOTIFY_NEW 4 /*!< \brief Notify New Incoming Alert immediately */
#define CH_ANCP_NOTIFY_UNREAD 5 /*!< \brief Notify Unread Category Status immediately */
/**@}*/
/** \name Alert Category ID
*
*/
/**@{*/
#define CH_ALERT_CAT_ID_SIMPLE 0 /*!< \brief Simple Alert: General text alert or non-text alert */
#define CH_ALERT_CAT_ID_EMAIL 1 /*!< \brief Email: Alert when Email messages arrives */
#define CH_ALERT_CAT_ID_NEWS 2 /*!< \brief News: News feeds such as RSS, Atom */
#define CH_ALERT_CAT_ID_CALL 3 /*!< \brief Call: Incoming call */
#define CH_ALERT_CAT_ID_MISSED 4 /*!< \brief Missed call: Missed Call */
#define CH_ALERT_CAT_ID_SMS 5 /*!< \brief SMS/MMS: SMS/MMS message arrives */
#define CH_ALERT_CAT_ID_VMAIL 6 /*!< \brief Voice mail: Voice mail */
#define CH_ALERT_CAT_ID_SCHED 7 /*!< \brief Schedule: Alert occurred on calendar, planner */
#define CH_ALERT_CAT_ID_ALERT 8 /*!< \brief High Prioritized Alert: Alert that should be handled as high priority */
#define CH_ALERT_CAT_ID_IM 9 /*!< \brief Instant Message: Alert for incoming instant messages */
#define CH_ALERT_CAT_ID_ALL 0xFF /*!< \brief All Categories */
/**@}*/
/** \name Alert Category ID Bit Mask
*
*/
/**@{*/
#define CH_ALERT_CAT_MASK_SIMPLE 0x0001 /*!< \brief Simple Alert: General text alert or non-text alert */
#define CH_ALERT_CAT_MASK_EMAIL 0x0002 /*!< \brief Email: Alert when Email messages arrives */
#define CH_ALERT_CAT_MASK_NEWS 0x0004 /*!< \brief News: News feeds such as RSS, Atom */
#define CH_ALERT_CAT_MASK_CALL 0x0008 /*!< \brief Call: Incoming call */
#define CH_ALERT_CAT_MASK_MISSED 0x0010 /*!< \brief Missed call: Missed Call */
#define CH_ALERT_CAT_MASK_SMS 0x0020 /*!< \brief SMS/MMS: SMS/MMS message arrives */
#define CH_ALERT_CAT_MASK_VMAIL 0x0040 /*!< \brief Voice mail: Voice mail */
#define CH_ALERT_CAT_MASK_SCHED 0x0080 /*!< \brief Schedule: Alert occurred on calendar, planner */
#define CH_ALERT_CAT_MASK_ALERT 0x0100 /*!< \brief High Prioritized Alert: Alert that should be handled as high priority */
#define CH_ALERT_CAT_MASK_IM 0x0200 /*!< \brief Instant Message: Alert for incoming instant messages */
/**@}*/
/** \name Ringer Control Point
*
*/
/**@{*/
#define CH_RCP_SILENT 1 /*!< \brief Silent Mode */
#define CH_RCP_MUTE_ONCE 2 /*!< \brief Mute Once */
#define CH_RCP_CANCEL_SILENT 3 /*!< \brief Cancel Silent Mode */
/**@}*/
/** \name Ringer Setting
*
*/
/**@{*/
#define CH_RINGER_SET_SILENT 0 /*!< \brief Ringer Silent */
#define CH_RINGER_SET_NORMAL 1 /*!< \brief Ringer Normal */
/**@}*/
/** \name Alert Status
*
*/
/**@{*/
#define CH_ALERT_STATUS_RINGER 0x01 /*!< \brief Ringer State active */
#define CH_ALERT_STATUS_VIBRATE 0x02 /*!< \brief Vibrate State active */
#define CH_ALERT_STATUS_DISPLAY 0x04 /*!< \brief Display Alert Status State active */
/**@}*/
/*! \brief System ID */
#define CH_SYSTEM_ID_LEN 8 /*!< \brief System ID value length. */
/*! \brief Battery Level */
#define CH_BATT_LEVEL_LEN 1 /*!< \brief Battery level value length. */
/** \name Blood Pressure Measurement Flags
*
*/
/**@{*/
#define CH_BPM_FLAG_UNITS_MMHG 0x00 /*!< \brief Blood pressure in units of mmHg */
#define CH_BPM_FLAG_UNITS_KPA 0x01 /*!< \brief Blood pressure in units of kPa */
#define CH_BPM_FLAG_TIMESTAMP 0x02 /*!< \brief Time Stamp Flag */
#define CH_BPM_FLAG_PULSE_RATE 0x04 /*!< \brief Pulse Rate Flag */
#define CH_BPM_FLAG_USER_ID 0x08 /*!< \brief User ID Flag */
#define CH_BPM_FLAG_MEAS_STATUS 0x10 /*!< \brief Measurement Status Flag */
/**@}*/
/** \name Blood Pressure Measurement: Measurement Status Bitmasks
*
*/
/**@{*/
/*! \brief Blood Pressure Measurement measurement status bitmasks */
#define CH_BPM_MS_BIT_MOVEMENT 0x0001 /*!< \brief Body Movement Detection */
#define CH_BPM_MS_BIT_CUFF_FIT 0x0002 /*!< \brief Cuff Fit Detection */
#define CH_BPM_MS_BIT_IRR_PULSE 0x0004 /*!< \brief Irregular Pulse Detection */
#define CH_BPM_MS_BIT_PULSE_RANGE 0x0018 /*!< \brief Pulse Rate Range Detection */
#define CH_BPM_MS_BIT_MEAS_POS 0x0020 /*!< \brief Measurement Position Detection */
/**@}*/
/** \name Blood Pressure Measurement: measurement status flags
*
*/
/**@{*/
#define CH_BPM_MS_FLAG_MOVEMENT_NONE 0x0000 /*!< \brief No body movement */
#define CH_BPM_MS_FLAG_MOVEMENT 0x0001 /*!< \brief Body movement */
#define CH_BPM_MS_FLAG_CUFF_FIT_OK 0x0000 /*!< \brief Cuff fit ok */
#define CH_BPM_MS_FLAG_CUFF_FIT_LOOSE 0x0002 /*!< \brief Cuff fit loose */
#define CH_BPM_MS_FLAG_IRR_PULSE_NONE 0x0000 /*!< \brief No irregular pulse detected */
#define CH_BPM_MS_FLAG_IRR_PULSE 0x0004 /*!< \brief Irregular pulse detected */
#define CH_BPM_MS_FLAG_PULSE_RANGE_OK 0x0000 /*!< \brief Pulse rate is within the range */
#define CH_BPM_MS_FLAG_PULSE_RANGE_HIGH 0x0008 /*!< \brief Pulse rate exceeds upper limit */
#define CH_BPM_MS_FLAG_PULSE_RANGE_LOW 0x0010 /*!< \brief Pulse rate is less than lower limit */
#define CH_BPM_MS_FLAG_MEAS_POS 0x0000 /*!< \brief Proper measurement position */
#define CH_BPM_MS_FLAG_MEAS_POS_ERR 0x0020 /*!< \brief Improper measurement position */
/**@}*/
/** \name Blood Pressure Measurement Field Lengths
*
*/
/**@{*/
#define CH_BPM_FLAGS_LEN 1 /*!< \brief Blood pressure measurement flags length. */
#define CH_BPM_MEAS_LEN 6 /*!< \brief Blood pressure measurement measurement length. */
#define CH_BPM_TIMESTAMP_LEN 7 /*!< \brief Blood pressure measurement timestamp length. */
#define CH_BPM_PULSE_RATE_LEN 2 /*!< \brief Blood pressure measurement pulse rate length. */
#define CH_BPM_USER_ID_LEN 1 /*!< \brief Blood pressure measurement user ID length. */
#define CH_BPM_MEAS_STATUS_LEN 2 /*!< \brief Blood pressure measurement status length. */
/**@}*/
/** \name Blood Pressure Feature Flags
*
*/
/**@{*/
#define CH_BPF_FLAG_MOVEMENT 0x0001 /*!< \brief Body Movement Detection Support bit */
#define CH_BPF_FLAG_CUFF_FIT 0x0002 /*!< \brief Cuff Fit Detection Support bit */
#define CH_BPF_FLAG_IRR_PULSE 0x0004 /*!< \brief Irregular Pulse Detection Support bit */
#define CH_BPF_FLAG_PULSE_RANGE 0x0008 /*!< \brief Pulse Rate Range Detection Support bit */
#define CH_BPF_FLAG_MEAS_POS 0x0010 /*!< \brief Measurement Position Detection Support bit */
#define CH_BPF_FLAG_MULTI_BOND 0x0020 /*!< \brief Multiple bond support bit */
/**@}*/
/** \name SFLOAT Special Values
*
*/
/**@{*/
#define CH_SFLOAT_NAN 0x07FF /*!< \brief Not a number */
#define CH_SFLOAT_NRES 0x07FF /*!< \brief Not at this resolution */
#define CH_SFLOAT_POS_INF 0x07FE /*!< \brief Positive infinity */
#define CH_SFLOAT_NEG_INF 0x0802 /*!< \brief Negative infinity */
#define CH_SFLOAT_RSVD 0x0801 /*!< \brief Not at this resolution */
/**@}*/
/** \name Glucose Feature
*
*/
/**@{*/
#define CH_GLF_LOW_BATT 0x0001 /*!< \brief Low Battery Detection During Measurement Supported */
#define CH_GLF_MALFUNC 0x0002 /*!< \brief Sensor Malfunction Detection Supported */
#define CH_GLF_SAMPLE_SIZE 0x0004 /*!< \brief Sensor Sample Size Supported */
#define CH_GLF_INSERT_ERR 0x0008 /*!< \brief Sensor Strip Insertion Error Detection Supported */
#define CH_GLF_TYPE_ERR 0x0010 /*!< \brief Sensor Strip Type Error Detection Supported */
#define CH_GLF_RES_HIGH_LOW 0x0020 /*!< \brief Sensor Result High-Low Detection Supported */
#define CH_GLF_TEMP_HIGH_LOW 0x0040 /*!< \brief Sensor Temperature High-Low Detection Supported */
#define CH_GLF_READ_INT 0x0080 /*!< \brief Sensor Read Interrupt Detection Supported */
#define CH_GLF_GENERAL_FAULT 0x0100 /*!< \brief General Device Fault Supported */
#define CH_GLF_TIME_FAULT 0x0200 /*!< \brief Time Fault Supported */
#define CH_GLF_MULTI_BOND 0x0400 /*!< \brief Multiple Bond Supported */
/**@}*/
/** \name Glucose Measurement Flags
*
*/
/**@{*/
#define CH_GLM_FLAG_TIME_OFFSET 0x01 /*!< \brief Time Offset Present */
#define CH_GLM_FLAG_CONC_TYPE_LOC 0x02 /*!< \brief Glucose Concentration, Type, and Sample Location Present */
#define CH_GLM_FLAG_UNITS_KG_L 0x00 /*!< \brief Glucose Concentration Units kg/L */
#define CH_GLM_FLAG_UNITS_MOL_L 0x04 /*!< \brief Glucose Concentration Units mol/L */
#define CH_GLM_FLAG_SENSOR_STATUS 0x08 /*!< \brief Sensor Status Annunciation Present */
#define CH_GLM_FLAG_CONTEXT_INFO 0x10 /*!< \brief Context Information Follows */
/**@}*/
/** \name Glucose Measurement Type
*
*/
/**@{*/
#define CH_GLM_TYPE_CAP_BLOOD 1 /*!< \brief Capillary whole blood */
#define CH_GLM_TYPE_CAP_PLASMA 2 /*!< \brief Capillary plasma */
#define CH_GLM_TYPE_VEN_BLOOD 3 /*!< \brief Venous whole blood */
#define CH_GLM_TYPE_VEN_PLASMA 4 /*!< \brief Venous plasma */
#define CH_GLM_TYPE_ART_BLOOD 5 /*!< \brief Arterial whole blood */
#define CH_GLM_TYPE_ART_PLASMA 6 /*!< \brief Arterial plasma */
#define CH_GLM_TYPE_UNDET_BLOOD 7 /*!< \brief Undetermined whole blood */
#define CH_GLM_TYPE_UNDET_PLASMA 8 /*!< \brief Undetermined plasma */
#define CH_GLM_TYPE_FLUID 9 /*!< \brief Interstitial fluid (ISF) */
#define CH_GLM_TYPE_CONTROL 10 /*!< \brief Control solution */
/**@}*/
/** \name Glucose Measurement Location
*
*/
/**@{*/
#define CH_GLM_LOC_FINGER 1 /*!< \brief Finger */
#define CH_GLM_LOC_AST 2 /*!< \brief Alternate Site Test (AST) */
#define CH_GLM_LOC_EAR 3 /*!< \brief Earlobe */
#define CH_GLM_LOC_CONTROL 4 /*!< \brief Control solution */
#define CH_GLM_LOC_NOT_AVAIL 15 /*!< \brief Sample Location value not available */
/**@}*/
/** \name Glucose Sensor Status Annunciation
*
*/
/**@{*/
#define CH_GLM_STATUS_BATT_LOW 0x0001 /*!< \brief Device battery low at time of measurement */
#define CH_GLM_STATUS_SENSOR_FAULT 0x0002 /*!< \brief Sensor malfunction or faulting at time of measurement */
#define CH_GLM_STATUS_SAMPLE_SIZE 0x0004 /*!< \brief Sample size for blood or control solution insufficient at time of measurement */
#define CH_GLM_STATUS_STRIP_INSERT 0x0008 /*!< \brief Strip insertion error */
#define CH_GLM_STATUS_STRIP_TYPE 0x0010 /*!< \brief Strip type incorrect for device */
#define CH_GLM_STATUS_RESULT_HIGH 0x0020 /*!< \brief Sensor result higher than the device can process */
#define CH_GLM_STATUS_RESULT_LOW 0x0040 /*!< \brief Sensor result lower than the device can process */
#define CH_GLM_STATUS_TEMP_HIGH 0x0080 /*!< \brief Sensor temperature too high for valid test/result at time of measurement */
#define CH_GLM_STATUS_TEMP_LOW 0x0100 /*!< \brief Sensor temperature too low for valid test/result at time of measurement */
#define CH_GLM_STATUS_STRIP_PULL 0x0200 /*!< \brief Sensor read interrupted because strip was pulled too soon at time of measurement */
#define CH_GLM_STATUS_GENERAL_FAULT 0x0400 /*!< \brief General device fault has occurred in the sensor */
#define CH_GLM_STATUS_TIME_FAULT 0x0800 /*!< \brief Time fault has occurred in the sensor and time may be inaccurate */
/**@}*/
/** \name Glucose Measurement Field Lengths
*
*/
/**@{*/
#define CH_GLM_FLAGS_LEN 1 /*!< \brief Glucose measurement flags length. */
#define CH_GLM_SEQNUM_LEN 2 /*!< \brief Glucose measurement sequence number length. */
#define CH_GLM_TIMESTAMP_LEN 7 /*!< \brief Glucose measurement timestamp length. */
#define CH_GLM_TIME_OFFSET_LEN 2 /*!< \brief Glucose measurement time offset length. */
#define CH_GLM_CONC_TYPE_LOC_LEN 3 /*!< \brief Glucose measurement concentration type location length. */
#define CH_GLM_SENSOR_STATUS_LEN 2 /*!< \brief Glucose measurement sensor status length. */
/**@}*/
/** \name Glucose Measurement Context Flags
*
*/
/**@{*/
#define CH_GLMC_FLAG_CARB 0x01 /*!< \brief Carbohydrate id and carbohydrate present */
#define CH_GLMC_FLAG_MEAL 0x02 /*!< \brief Meal present */
#define CH_GLMC_FLAG_TESTER 0x04 /*!< \brief Tester-health present */
#define CH_GLMC_FLAG_EXERCISE 0x08 /*!< \brief Exercise duration and exercise intensity present */
#define CH_GLMC_FLAG_MED 0x10 /*!< \brief Medication ID and medication present */
#define CH_GLMC_FLAG_MED_KG 0x00 /*!< \brief Medication value units, kilograms */
#define CH_GLMC_FLAG_MED_L 0x20 /*!< \brief Medication value units, liters */
#define CH_GLMC_FLAG_HBA1C 0x40 /*!< \brief Hba1c present */
#define CH_GLMC_FLAG_EXT 0x80 /*!< \brief Extended flags present */
/**@}*/
/** \name Glucose Measurement Context Field Lenths
*
*/
/**@{*/
#define CH_GLMC_FLAGS_LEN 1 /*!< \brief Glucose measurement context flags length. */
#define CH_GLMC_SEQNUM_LEN 2 /*!< \brief Glucose measurement context sequence number length. */
#define CH_GLMC_CARB_LEN 3 /*!< \brief Glucose measurement context carbohydrate ID a d carbohydrate length. */
#define CH_GLMC_MEAL_LEN 1 /*!< \brief Glucose measurement context meal present length. */
#define CH_GLMC_TESTER_LEN 1 /*!< \brief Glucose measurement context tester-health length. */
#define CH_GLMC_EXERCISE_LEN 3 /*!< \brief Glucose measurement context exercise duration and exercise intensity length. */
#define CH_GLMC_MED_LEN 3 /*!< \brief Glucose measurement context medication ID length. */
#define CH_GLMC_HBA1C_LEN 2 /*!< \brief Glucose measurement context Hba1c length. */
#define CH_GLMC_EXT_LEN 1 /*!< \brief Glucose measurement context extended length. */
/**@}*/
/** \name Glucose measurement context carbohydrate ID
*
*/
/**@{*/
#define CH_GLMC_CARB_BREAKFAST 1 /*!< \brief Breakfast */
#define CH_GLMC_CARB_LUNCH 2 /*!< \brief Lunch */
#define CH_GLMC_CARB_DINNER 3 /*!< \brief Dinner */
#define CH_GLMC_CARB_SNACK 4 /*!< \brief Snack */
#define CH_GLMC_CARB_DRINK 5 /*!< \brief Drink */
#define CH_GLMC_CARB_SUPPER 6 /*!< \brief Supper */
#define CH_GLMC_CARB_BRUNCH 7 /*!< \brief Brunch */
/**@}*/
/** \name Glucose Measurement Context Meal
*
*/
/**@{*/
#define CH_GLMC_MEAL_PREPRANDIAL 1 /*!< \brief Preprandial (before meal) */
#define CH_GLMC_MEAL_POSTPRANDIAL 2 /*!< \brief Postprandial (after meal) */
#define CH_GLMC_MEAL_FASTING 3 /*!< \brief Fasting */
#define CH_GLMC_MEAL_CASUAL 4 /*!< \brief Casual (snacks, drinks, etc.) */
#define CH_GLMC_MEAL_BEDTIME 5 /*!< \brief Bedtime */
/**@}*/
/** \name Glucose Measurement Context Tester
*
*/
/**@{*/
#define CH_GLMC_TESTER_SELF 1 /*!< \brief Self */
#define CH_GLMC_TESTER_PRO 2 /*!< \brief Health care professional */
#define CH_GLMC_TESTER_LAB 3 /*!< \brief Lab test */
#define CH_GLMC_TESTER_NOT_AVAIL 15 /*!< \brief Tester value not available */
/**@}*/
/** \name Glucose measurement Context Health
*
*/
/**@{*/
#define CH_GLMC_HEALTH_MINOR 1 /*!< \brief Minor health issues */
#define CH_GLMC_HEALTH_MAJOR 2 /*!< \brief Major health issues */
#define CH_GLMC_HEALTH_MENSES 3 /*!< \brief During menses */
#define CH_GLMC_HEALTH_STRESS 4 /*!< \brief Under stress */
#define CH_GLMC_HEALTH_NONE 5 /*!< \brief No health issues */
#define CH_GLMC_HEALTH_NOT_AVAIL 15 /*!< \brief Health value not available */
/**@}*/
/** \name Glucose Measurement Context Medication ID
*
*/
/**@{*/
#define CH_GLMC_MED_RAPID 1 /*!< \brief Rapid acting insulin */
#define CH_GLMC_MED_SHORT 2 /*!< \brief Short acting insulin */
#define CH_GLMC_MED_INTERMED 3 /*!< \brief Intermediate acting insulin */
#define CH_GLMC_MED_LONG 4 /*!< \brief Long acting insulin */
#define CH_GLMC_MED_PREMIX 5 /*!< \brief Pre-mixed insulin */
/**@}*/
/** \name Record Access Control Point Opcode
*
*/
/**@{*/
#define CH_RACP_OPCODE_REPORT 1 /*!< \brief Report stored records */
#define CH_RACP_OPCODE_DELETE 2 /*!< \brief Delete stored records */
#define CH_RACP_OPCODE_ABORT 3 /*!< \brief Abort operation */
#define CH_RACP_OPCODE_REPORT_NUM 4 /*!< \brief Report number of stored records */
#define CH_RACP_OPCODE_NUM_RSP 5 /*!< \brief Number of stored records response */
#define CH_RACP_OPCODE_RSP 6 /*!< \brief Response code */
/** \name Record Access Control Point Operator
*
*/
/**@{*/
#define CH_RACP_OPERATOR_NULL 0 /*!< \brief Null operator */
#define CH_RACP_OPERATOR_ALL 1 /*!< \brief All records */
#define CH_RACP_OPERATOR_LTEQ 2 /*!< \brief Less than or equal to */
#define CH_RACP_OPERATOR_GTEQ 3 /*!< \brief Greater than or equal to */
#define CH_RACP_OPERATOR_RANGE 4 /*!< \brief Within range of (inclusive) */
#define CH_RACP_OPERATOR_FIRST 5 /*!< \brief First record(i.e. oldest record) */
#define CH_RACP_OPERATOR_LAST 6 /*!< \brief Last record (i.e. most recent record) */
/**@}*/
/** \name Record Access Control Point Response Code Values
*
*/
/**@{*/
#define CH_RACP_RSP_SUCCESS 1 /*!< \brief Success */
#define CH_RACP_RSP_OPCODE_NOT_SUP 2 /*!< \brief Op code not supported */
#define CH_RACP_RSP_INV_OPERATOR 3 /*!< \brief Invalid operator */
#define CH_RACP_RSP_OPERATOR_NOT_SUP 4 /*!< \brief Operator not supported */
#define CH_RACP_RSP_INV_OPERAND 5 /*!< \brief Invalid operand */
#define CH_RACP_RSP_NO_RECORDS 6 /*!< \brief No records found */
#define CH_RACP_RSP_ABORT_FAILED 7 /*!< \brief Abort unsuccessful */
#define CH_RACP_RSP_PROC_NOT_COMP 8 /*!< \brief Procedure not completed */
#define CH_RACP_RSP_OPERAND_NOT_SUP 9 /*!< \brief Operand not supported */
/**@}*/
/** \name Glucose Service Operand Filter Types And Field Lengths
*
*/
/**@{*/
#define CH_RACP_GLS_FILTER_SEQ 1 /*!< \brief Sequence number */
#define CH_RACP_GLS_FILTER_TIME 2 /*!< \brief User facing time */
#define CH_RACP_GLS_FILTER_SEQ_LEN 2 /*!< \brief Sequence number filter length */
#define CH_RACP_GLS_FILTER_TIME_LEN 7 /*!< \brief User facing time filter length */
/**@}*/
/** \name Service Changed Length
*
*/
/**@{*/
#define CH_SC_LEN 4 /*!< \brief Length of service changed */
/**@}*/
/** \name Temperature Measurement flags
*
*/
/**@{*/
#define CH_TM_FLAG_UNITS_C 0x00 /*!< \brief Temperature in units of C */
#define CH_TM_FLAG_UNITS_F 0x01 /*!< \brief Temperature in units of F */
#define CH_TM_FLAG_TIMESTAMP 0x02 /*!< \brief Time Stamp Flag */
#define CH_TM_FLAG_TEMP_TYPE 0x04 /*!< \brief Temperature Type Flag */
/**@}*/
/** \name Temperature Measurement Field Lengths
*
*/
/**@{*/
#define CH_TM_FLAGS_LEN 1 /*!< \brief Temperature measurement flags length. */
#define CH_TM_MEAS_LEN 4 /*!< \brief Temperature measurement measurement length. */
#define CH_TM_TIMESTAMP_LEN 7 /*!< \brief Temperature measurement timestamp length. */
#define CH_TM_TEMP_TYPE_LEN 1 /*!< \brief Temperature measurement type length. */
/**@}*/
/** \name Temperature Type
*
*/
/**@{*/
#define CH_TT_ARMPIT 1 /*!< \brief Armpit */
#define CH_TT_BODY 2 /*!< \brief Body (general) */
#define CH_TT_EAR 3 /*!< \brief Ear (usually ear lobe) */
#define CH_TT_FINGER 4 /*!< \brief Finger */
#define CH_TT_GI 5 /*!< \brief Gastro-intestinal Tract */
#define CH_TT_MOUTH 6 /*!< \brief Mouth */
#define CH_TT_RECTUM 7 /*!< \brief Rectum */
#define CH_TT_TOE 8 /*!< \brief Toe */
#define CH_TT_TYMPANUM 9 /*!< \brief Tympanum (ear drum) */
/**@}*/
/** \name Weight Scale Feature Flags
*
*/
/**@{*/
#define CH_WSF_FLAG_TIMESTAMP 0x0001 /*!< \brief Time Stamp Supported bit */
#define CH_WSF_FLAG_MULTIUSER 0x0002 /*!< \brief Multiple Users Supported bit */
#define CH_WSF_FLAG_BMI 0x0004 /*!< \brief BMI Supported bit */
/**@}*/
/** \name Weight Scale Measurement Flags
*
*/
/**@{*/
#define CH_WSM_FLAG_UNITS_KG 0x00 /*!< \brief Weight in units of kilograms */
#define CH_WSM_FLAG_UNITS_LBS 0x01 /*!< \brief Weight in units of pounds */
#define CH_WSM_FLAG_TIMESTAMP 0x02 /*!< \brief Time stamp present */
#define CH_WSM_FLAG_USER_ID 0x04 /*!< \brief User ID present */
#define CH_WSM_FLAG_BMI_HEIGHT 0x08 /*!< \brief BMI and height present */
/**@}*/
/** \name Weight Scale Measurement Field Lengths
*
*/
/**@{*/
#define CH_WSM_FLAGS_LEN 1 /*!< \brief Weight scale measurement flags length. */
#define CH_WSM_MEAS_LEN 2 /*!< \brief Weight scale measurement measurement length. */
#define CH_WSM_TIMESTAMP_LEN 7 /*!< \brief Weight scale measurement timestamp length. */
#define CH_WSM_USER_ID_LEN 1 /*!< \brief Weight scale measurement user ID length. */
#define CH_WSM_BMI_HEIGHT_LEN 4 /*!< \brief Weight scale measurement BMI-height length. */
/**@}*/
/** \name Scan Parameter Profile Field Lengths
*
*/
/**@{*/
#define CH_SCPP_INTERVAL_WINDOW_LEN 4 /*!< \brief Scan parameter profile interval window length. */
#define CH_SCPP_REFRESH_LEN 0 /*!< \brief Scan parameter profile refresh length. */
/**@}*/
/** \name Cycle Power Profile field Lengths
*
*/
/**@{*/
#define CH_CPS_MEASUREMENT_LEN 34 /*!< \brief Cycling power profile measurement length. */
/**@}*/
/** \name Cycle Speed Profile Field Lengths
*
*/
/**@{*/
#define CH_CSCS_MEASUREMENT_LEN 11 /*!< \brief Cycling speed profile measurement length. */
/**@}*/
/** \name Running Speed Profile Field Lengths
*
*/
/**@{*/
#define CH_RSCS_MEASUREMENT_LEN 10 /*!< \brief Running speed profile measurement length. */
/**@}*/
/** \name Pulse Oximiter Profile Field Lengths
*
*/
/**@{*/
#define CH_PLXS_SPOT_CHECK_LEN 19 /*!< \brief Pulse oximiter profile spot check length. */
#define CH_PLXS_CONTINUOUS_LEN 16 /*!< \brief Pulse oximiter profile continuous length. */
/**@}*/
/** \name Pulse Oximeter Common Field Lenths
*
*/
/**@{*/
#define CH_PLX_FLAGS_LEN 1 /*!< \brief Pulse oximiter flags length. */
#define CH_PLX_SPO2_LEN 2 /*!< \brief Pulse oximiter SPO2 length, */
#define CH_PLX_PULSE_LEN 2 /*!< \brief Pulse oximiter pulse length. */
#define CH_PLX_MEASUREMENT_STATUS_LEN 2 /*!< \brief Pulse oximiter measurement status length. */
#define CH_PLX_SENSOR_STATUS_LEN 3 /*!< \brief Pulse oximiter sensor status length. */
#define CH_PLX_PULSE_AMP_INDX_LEN 2 /*!< \brief Pulse AMP index length. */
/**@}*/
/** \name Pulse Oximeter Spot Check Measurement Field Lenths
*
*/
/**@{*/
#define CH_PLXSC_TIMESTAMP_LEN 7 /*!< \brief Pulse oximiter spot check measurement timestamp length. */
/**@}*/
/** \name Pulse Oximeter Continuous Measurement Field Lenths
*
*/
/**@{*/
#define CH_PLXC_SPO2PR_FAST_LEN 2 /*!< \brief Pulse oximiter continuous measurement SPO2PR fast length. */
#define CH_PLXC_SPO2PR_SLOW_LEN 2 /*!< \brief Pulse oximiter continuous measurement SPO2PR slow length. */
/**@}*/
/** \name Pulse Oximeter Features Field Lenths
*
*/
/**@{*/
#define CH_PLXF_MIN_FEATURES_LEN 2 /*!< \brief Pulse oximiter minimum features length. */
#define CH_PLXF_MAX_FEATURES_LEN 7 /*!< \brief Pulse oximiter maximum features length. */
#define CH_PLXF_SENSOR_SUPPORT_LEN 2 /*!< \brief Pulse oximiter sensor support length. */
#define CH_PLXF_MEASUREMENT_SUPPORT_LEN 2 /*!< \brief Pulse oximeter measurement suppported length. */
/**@}*/
/** \name Pulse Oximeter Spot Check Measurement Flags
*
*/
/**@{*/
#define CH_PLXSC_FLAG_TIMESTAMP 0x01 /*!< \brief Timestamp field is present */
#define CH_PLXSC_FLAG_MEASUREMENT_STATUS 0x02 /*!< \brief Measurement Status Field Present */
#define CH_PLXSC_FLAG_SENSOR_STATUS 0x04 /*!< \brief Device and Sensor Status Field Present */
#define CH_PLXSC_FLAG_PULSE_AMP_INDX 0x08 /*!< \brief Pulse Amplitude Index field is present */
#define CH_PLXSC_FLAG_CLOCK_NOT_SET 0x10 /*!< \brief Device Clock is Not Set */
/**@}*/
/** \name Pulse Oximeter Continuous Measurement Flags
*
*/
/**@{*/
#define CH_PLXC_FLAG_SPO2PR_FAST 0x01 /*!< \brief SpO2PR-Fast field is present */
#define CH_PLXC_FLAG_SPO2PR_SLOW 0x02 /*!< \brief SpO2PR-Slow field is present */
#define CH_PLXC_FLAG_MEASUREMENT_STATUS 0x04 /*!< \brief Measurement Status Field Present */
#define CH_PLXC_FLAG_SENSOR_STATUS 0x08 /*!< \brief Device and Sensor Status Field Present */
#define CH_PLXC_FLAG_PULSE_AMP_INDX 0x10 /*!< \brief Pulse Amplitude Index field is present */
/**@}*/
/** \name Pulse Oximeter Features
*
*/
/**@{*/
#define CH_PLF_FLAG_MEAS_STATUS_SUP 0x01 /*!< \brief Measurement Status support is present */
#define CH_PLF_FLAG_SENSOR_STATUS_SUP 0x02 /*!< \brief Device and Sensor Status support is present */
#define CH_PLF_FLAG_SPOT_CHECK_STORAGE_SUP 0x04 /*!< \brief Measurement Storage for Spot-check measurements is supported */
#define CH_PLF_FLAG_SPOT_CHECK_SUP 0x08 /*!< \brief Timestamp for Spot-check measurements is supported */
#define CH_PLF_FLAG_SPO2PR_FAST_SUP 0x10 /*!< \brief SpO2PR-Fast metric is supported */
#define CH_PLF_FLAG_SPO2PR_SLOW_SUP 0x20 /*!< \brief SpO2PR-Slow metric is supported */
#define CH_PLF_FLAG_PULSE_AMP_SUP 0x40 /*!< \brief Pulse Amplitude Index field is supported */
#define CH_PLF_FLAG_MULTI_BOND_SUP 0x80 /*!< \brief Multiple Bonds Supported */
/**@}*/
/*! \} */ /* SERVICE_CONSTANTS */
#ifdef __cplusplus
};
#endif
#endif /* SVC_CH_H */
@@ -0,0 +1,387 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example GATT and GAP service implementations.
*
* Copyright (c) 2009-2019 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "app_db.h"
#include "app_api.h"
#include "att_api.h"
#include "att_uuid.h"
#include "util/bstream.h"
#include "svc_core.h"
#include "svc_ch.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef CORE_SEC_PERMIT_READ
#define CORE_SEC_PERMIT_READ SVC_SEC_PERMIT_READ
#endif
/*! Characteristic write permissions */
#ifndef CORE_SEC_PERMIT_WRITE
#define CORE_SEC_PERMIT_WRITE SVC_SEC_PERMIT_WRITE
#endif
/*! Default device name */
#define CORE_DEFAULT_DEV_NAME "Cordio"
/*! Length of default device name */
#define CORE_DEFAULT_DEV_NAME_LEN 6
/**************************************************************************************************
GAP group
**************************************************************************************************/
/* service */
static const uint8_t gapValSvc[] = {UINT16_TO_BYTES(ATT_UUID_GAP_SERVICE)};
static const uint16_t gapLenSvc = sizeof(gapValSvc);
/* device name characteristic */
// static const uint8_t gapValDnCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(GAP_DN_HDL), UINT16_TO_BYTES(ATT_UUID_DEVICE_NAME)};
// static const uint16_t gapLenDnCh = sizeof(gapValDnCh);
/* device name */
// static uint8_t gapValDn[ATT_DEFAULT_PAYLOAD_LEN] = CORE_DEFAULT_DEV_NAME;
// static uint16_t gapLenDn = CORE_DEFAULT_DEV_NAME_LEN;
/* appearance characteristic */
static const uint8_t gapValApCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(GAP_AP_HDL), UINT16_TO_BYTES(ATT_UUID_APPEARANCE)};
static const uint16_t gapLenApCh = sizeof(gapValApCh);
/* appearance */
static uint8_t gapValAp[] = {UINT16_TO_BYTES(CH_APPEAR_UNKNOWN)};
static const uint16_t gapLenAp = sizeof(gapValAp);
/* central address resolution characteristic */
static const uint8_t gapValCarCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(GAP_CAR_HDL), UINT16_TO_BYTES(ATT_UUID_CAR)};
static const uint16_t gapLenCarCh = sizeof(gapValCarCh);
/* central address resolution */
static uint8_t gapValCar[] = {FALSE};
static const uint16_t gapLenCar = sizeof(gapValCar);
/* resolvable private address only characteristic */
static const uint8_t gapValRpaoCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(GAP_RPAO_HDL), UINT16_TO_BYTES(ATT_UUID_RPAO)};
static const uint16_t gapLenRpaoCh = sizeof(gapValRpaoCh);
/* resolvable private address only */
static uint8_t gapValRpao[] = {0};
static const uint16_t gapLenRpao = sizeof(gapValRpao);
/* Attribute list for GAP group */
static const attsAttr_t gapList[] =
{
{
attPrimSvcUuid,
(uint8_t *) gapValSvc,
(uint16_t *) &gapLenSvc,
sizeof(gapValSvc),
0,
ATTS_PERMIT_READ
},
// {
// attChUuid,
// (uint8_t *) gapValDnCh,
// (uint16_t *) &gapLenDnCh,
// sizeof(gapValDnCh),
// 0,
// ATTS_PERMIT_READ
// },
// {
// attDnChUuid,
// gapValDn,
// &gapLenDn,
// sizeof(gapValDn),
// (ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
// (ATTS_PERMIT_READ | CORE_SEC_PERMIT_WRITE)
// },
{
attChUuid,
(uint8_t *) gapValApCh,
(uint16_t *) &gapLenApCh,
sizeof(gapValApCh),
0,
ATTS_PERMIT_READ
},
{
attApChUuid,
gapValAp,
(uint16_t *) &gapLenAp,
sizeof(gapValAp),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) gapValCarCh,
(uint16_t *) &gapLenCarCh,
sizeof(gapValCarCh),
0,
ATTS_PERMIT_READ
},
{
attCarChUuid,
gapValCar,
(uint16_t *) &gapLenCar,
sizeof(gapValCar),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) gapValRpaoCh,
(uint16_t *) &gapLenRpaoCh,
sizeof(gapValRpaoCh),
0,
ATTS_PERMIT_READ
},
{
attRpaoChUuid,
gapValRpao,
(uint16_t *) &gapLenRpao,
sizeof(gapValRpao),
0,
ATTS_PERMIT_READ
}
};
/* GAP group structure */
static attsGroup_t svcGapGroup =
{
NULL,
(attsAttr_t *) gapList,
NULL,
NULL,
GAP_START_HDL,
GAP_END_HDL
};
/**************************************************************************************************
GATT group
**************************************************************************************************/
/* service */
static const uint8_t gattValSvc[] = {UINT16_TO_BYTES(ATT_UUID_GATT_SERVICE)};
static const uint16_t gattLenSvc = sizeof(gattValSvc);
/* service changed characteristic */
static const uint8_t gattValScCh[] = {ATT_PROP_INDICATE, UINT16_TO_BYTES(GATT_SC_HDL), UINT16_TO_BYTES(ATT_UUID_SERVICE_CHANGED)};
static const uint16_t gattLenScCh = sizeof(gattValScCh);
/* service changed */
static const uint8_t gattValSc[] = {UINT16_TO_BYTES(0x0001), UINT16_TO_BYTES(0xFFFF)};
static const uint16_t gattLenSc = sizeof(gattValSc);
/* service changed client characteristic configuration */
static uint8_t gattValScChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t gattLenScChCcc = sizeof(gattValScChCcc);
/* client supported features characteristic */
static const uint8_t gattValCsfCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(GATT_CSF_HDL), UINT16_TO_BYTES(ATT_UUID_CLIENT_SUPPORTED_FEATURES)};
static const uint16_t gattLenCsfCh = sizeof(gattValCsfCh);
/* client supported features */
static uint8_t gattValCsf[ATT_CSF_LEN] = { 0 };
static const uint16_t gattLenCsf = sizeof(gattValCsf);
/* database hash characteristic */
static const uint8_t gattValDbhCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(GATT_DBH_HDL), UINT16_TO_BYTES(ATT_UUID_DATABASE_HASH)};
static const uint16_t gattLenDbhCh = sizeof(gattValDbhCh);
/* database hash */
static uint8_t gattValDbh[ATT_DATABASE_HASH_LEN] = { 0 };
static const uint16_t gattLenDbh = sizeof(gattValDbh);
/* Attribute list for GATT group */
static const attsAttr_t gattList[] =
{
{
attPrimSvcUuid,
(uint8_t *) gattValSvc,
(uint16_t *) &gattLenSvc,
sizeof(gattValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) gattValScCh,
(uint16_t *) &gattLenScCh,
sizeof(gattValScCh),
0,
ATTS_PERMIT_READ
},
{
attScChUuid,
(uint8_t *) gattValSc,
(uint16_t *) &gattLenSc,
sizeof(gattValSc),
0,
0
},
{
attCliChCfgUuid,
gattValScChCcc,
(uint16_t *) &gattLenScChCcc,
sizeof(gattValScChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | CORE_SEC_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) gattValCsfCh,
(uint16_t *) &gattLenCsfCh,
sizeof(gattValCsfCh),
0,
(ATTS_PERMIT_READ | CORE_SEC_PERMIT_READ)
},
{
attGattCsfChUuid,
(uint8_t *)gattValCsf,
(uint16_t *)&gattLenCsf,
sizeof(gattValCsf),
(ATTS_SET_READ_CBACK | ATTS_SET_WRITE_CBACK),
(ATTS_PERMIT_READ | ATTS_PERMIT_WRITE | CORE_SEC_PERMIT_READ | CORE_SEC_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) gattValDbhCh,
(uint16_t *) &gattLenDbhCh,
sizeof(gattValDbhCh),
0,
(ATTS_PERMIT_READ | CORE_SEC_PERMIT_READ)
},
{
attGattDbhChUuid,
(uint8_t *) gattValDbh,
(uint16_t *) &gattLenDbh,
sizeof(gattValDbh),
ATTS_SET_READ_CBACK,
(ATTS_PERMIT_READ | CORE_SEC_PERMIT_READ)
}
};
/* GATT group structure */
static attsGroup_t svcGattGroup =
{
NULL,
(attsAttr_t *) gattList,
NULL,
NULL,
GATT_START_HDL,
GATT_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreAddGroup(void)
{
AttsAddGroup(&svcGapGroup);
AttsAddGroup(&svcGattGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreRemoveGroup(void)
{
AttsRemoveGroup(GAP_START_HDL);
AttsRemoveGroup(GATT_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGapCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcGapGroup.readCback = readCback;
svcGapGroup.writeCback = writeCback;
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGattCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcGattGroup.readCback = readCback;
svcGattGroup.writeCback = writeCback;
}
/*************************************************************************************************/
/*!
* \brief Update the central address resolution attribute value.
*
* \param value New value.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGapCentAddrResUpdate(bool_t value)
{
gapValCar[0] = value;
}
/*************************************************************************************************/
/*!
* \brief Add the Resolvable Private Address Only (RPAO) characteristic to the GAP service.
* The RPAO characteristic should be added only when DM Privacy is enabled.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGapAddRpaoCh(void)
{
/* if RPAO characteristic not already in GAP service */
if (svcGapGroup.endHandle < GAP_RPAO_HDL)
{
svcGapGroup.endHandle = GAP_RPAO_HDL;
}
}
@@ -0,0 +1,173 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example GATT and GAP service implementations.
*
* Copyright (c) 2009-2019 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_CORE_H
#define SVC_CORE_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup GATT_AND_GAP_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name GAP Service Handles
* \note GAP -- RPAO characterstic added only when DM Privacy enabled
*/
/**@{*/
#define GAP_START_HDL 0x01 /*!< \brief GAP start handle */
#define GAP_END_HDL (GAP_MAX_HDL - 3) /*!< \brief GAP end handle */
/**@}*/
/** \name GATT Service Handles
*
*/
/**@{*/
#define GATT_START_HDL 0x10 /*!< \brief GATT start handle */
#define GATT_END_HDL (GATT_MAX_HDL - 1) /*!< \brief GATT end handle */
/**@}*/
/**************************************************************************************************
Handles
**************************************************************************************************/
/** \name GAP Service Handles
*
*/
/**@{*/
/*! \brief GAP service handle */
enum
{
GAP_SVC_HDL = GAP_START_HDL, /*!< \brief GAP service declaration */
GAP_DN_CH_HDL, /*!< \brief Device name characteristic */
GAP_DN_HDL, /*!< \brief Device name */
GAP_AP_CH_HDL, /*!< \brief Appearance characteristic */
GAP_AP_HDL, /*!< \brief Appearance */
GAP_CAR_CH_HDL, /*!< \brief Central address resolution characteristic */
GAP_CAR_HDL, /*!< \brief Central address resolution */
GAP_RPAO_CH_HDL, /*!< \brief Resolvable private address only characteristic */
GAP_RPAO_HDL, /*!< \brief Resolvable private address only */
GAP_MAX_HDL /*!< \brief GAP maximum handle */
};
/**@}*/
/** \name GATT Service Handles
*
*/
/**@{*/
/*! \brief GATT service handles */
enum
{
GATT_SVC_HDL = GATT_START_HDL, /*!< \brief GATT service declaration */
GATT_SC_CH_HDL, /*!< \brief Service changed characteristic */
GATT_SC_HDL, /*!< \brief Service changed */
GATT_SC_CH_CCC_HDL, /*!< \brief Service changed client characteristic configuration descriptor */
GATT_CSF_CH_HDL, /*!< \brief Client supported features characteristic */
GATT_CSF_HDL, /*!< \brief Client supported features */
GATT_DBH_CH_HDL, /*!< \brief Database hash characteristic */
GATT_DBH_HDL, /*!< \brief Database hash */
GATT_MAX_HDL /*!< \brief GATT maximum handle */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGattCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGapCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*************************************************************************************************/
/*!
* \brief Update the central address resolution attribute value.
*
* \param value New value.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGapCentAddrResUpdate(bool_t value);
/*************************************************************************************************/
/*!
* \brief Add the Resolvable Private Address Only (RPAO) characteristic to the GAP service.
* The RPAO characteristic should be added only when DM Privacy is enabled.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCoreGapAddRpaoCh(void);
/*! \} */ /* GATT_AND_GAP_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_CORE_H */
@@ -0,0 +1,216 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Cycling Power Service Server implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "att_uuid.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_cps.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef CPS_SEC_PERMIT_READ
#define CPS_SEC_PERMIT_READ (ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC)
#endif
/*! Characteristic write permissions */
#ifndef CPS_SEC_PERMIT_WRITE
#define CPS_SEC_PERMIT_WRITE (ATTS_PERMIT_WRITE | ATTS_PERMIT_READ_ENC)
#endif
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Cycling Power service declaration */
static const uint8_t cpsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_CYCLING_POWER_SERVICE)};
static const uint16_t cpsLenSvc = sizeof(cpsValSvc);
/* Cycling Power Feature characteristic */
static const uint8_t cpsValFeatureCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(CPS_CPF_HDL), UINT16_TO_BYTES(ATT_UUID_CYCLING_POWER_FEATURE)};
static const uint16_t cpsLenFeatureCh = sizeof(cpsValFeatureCh);
/* Cycling Power Feature */
/* TODO: Set Supported Feature Bits */
static uint32_t cpsValFeature[] = { CPP_PPBS_FEATURE_BIT };
static const uint16_t cpsLenFeature = sizeof(cpsValFeature);
/* Cycling Power Measurement characteristic */
static const uint8_t cpsValMeasurementCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(CPS_CPM_HDL), UINT16_TO_BYTES(ATT_UUID_CYCLING_POWER_MEASUREMENT)};
static const uint16_t cpsLenMeasurementCh = sizeof(cpsValMeasurementCh);
/* Cycling Power Measurement */
/* Note these are dummy values */
static const uint8_t cpsValMeasurement[] = { 0 };
static const uint16_t cpsLenMeasurement = CH_CPS_MEASUREMENT_LEN;
/* Cycling Power Measurement client characteristic configuration */
static uint8_t cpsValMeasurementChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t cpsLenMeasurementChCcc = sizeof(cpsValMeasurementChCcc);
/* Cycling Power Sensor Location characteristic */
static const uint8_t cpsValLocationCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(CPS_CPSL_HDL), UINT16_TO_BYTES(ATT_UUID_SENSOR_LOCATION)};
static const uint16_t cpsLenLocationCh = sizeof(cpsValLocationCh);
/* Cycling Power Sensor Location */
/* Note these are dummy values */
static uint8_t cpsValLocation[] = { 0 };
static const uint16_t cpsLenLocation = sizeof(cpsValLocation);
/* Attribute list for CPS group */
static const attsAttr_t cpsList[] =
{
/* Cycling Power Service declaration */
{
attPrimSvcUuid,
(uint8_t *) cpsValSvc,
(uint16_t *) &cpsLenSvc,
sizeof(cpsValSvc),
0,
ATTS_PERMIT_READ
},
/* Cycling Power Feature characteristic */
{
attChUuid,
(uint8_t *)cpsValFeatureCh,
(uint16_t *) &cpsLenFeatureCh,
sizeof(cpsValFeatureCh),
0,
ATTS_PERMIT_READ
},
/* Cycling Power Feature value */
{
attCpfChUuid,
(uint8_t *)cpsValFeature,
(uint16_t *) &cpsLenFeature,
sizeof(cpsValFeature),
0,
CPS_SEC_PERMIT_READ
},
/* Cycling Power Measurement characteristic */
{
attChUuid,
(uint8_t *)cpsValMeasurementCh,
(uint16_t *)&cpsLenMeasurementCh,
sizeof(cpsValMeasurementCh),
0,
ATTS_PERMIT_READ
},
/* Cycling Power Measurement value */
{
attCpmChUuid,
(uint8_t *)cpsValMeasurement,
(uint16_t *)&cpsLenMeasurement,
sizeof(cpsValMeasurement),
0,
0
},
/* Characteristic CCC descriptor */
{
attCliChCfgUuid,
cpsValMeasurementChCcc,
(uint16_t *)&cpsLenMeasurementChCcc,
sizeof(cpsValMeasurementChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | CPS_SEC_PERMIT_WRITE)
},
/* Cycling Power Sensor Location characteristic */
{
attChUuid,
(uint8_t *)cpsValLocationCh,
(uint16_t *)&cpsLenLocationCh,
sizeof(cpsValLocationCh),
0,
ATTS_PERMIT_READ
},
/* Cycling Power Sensor Location value */
{
attSlChUuid,
(uint8_t *)cpsValLocation,
(uint16_t *)&cpsLenLocation,
sizeof(cpsValLocation),
0,
CPS_SEC_PERMIT_READ
},
};
/* CPS group structure */
static attsGroup_t svcCpsGroup =
{
NULL,
(attsAttr_t *) cpsList,
NULL,
NULL,
CPS_START_HDL,
CPS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCpsAddGroup(void)
{
AttsAddGroup(&svcCpsGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCpsRemoveGroup(void)
{
AttsRemoveGroup(CPS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCpsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcCpsGroup.readCback = readCback;
svcCpsGroup.writeCback = writeCback;
}
@@ -0,0 +1,141 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Cycling Power Service Server implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_CPS_H
#define SVC_CPS_H
#include "att_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup CYCLING_POWER_SERVICE
* \{ */
/**************************************************************************************************
Constants
**************************************************************************************************/
/** \name Cycling Power Feature Bits
* Cycle Power Feature Bits of the Feature Characteristic.
*/
/**@{*/
#define CPP_PPBS_FEATURE_BIT (1<<0) /*!< \brief Pedal Power Balance Supported Feature Mask Bit */
#define CPP_ATS_FEATURE_BIT (1<<1) /*!< \brief Accumulated Torque Supported Feature Mask Bit */
#define CPP_WRDS_FEATURE_BIT (1<<2) /*!< \brief Wheel Revolution Data Supported Feature Mask Bit */
#define CPP_CRDS_FEATURE_BIT (1<<3) /*!< \brief Crank Revolution Data Supported Feature Mask Bit */
#define CPP_EMS_FEATURE_BIT (1<<4) /*!< \brief Extreme Magnitudes Supported Feature Mask Bit */
#define CPP_EAS_FEATURE_BIT (1<<5) /*!< \brief Extreme Angles Supported Feature Mask Bit */
#define CPP_TABDSAS_FEATURE_BIT (1<<6) /*!< \brief Top and Bottom Dead Spot Angles Supported Feature Mask Bit */
#define CPP_AES_FEATURE_BIT (1<<7) /*!< \brief Accumulated Energy Supported Feature Mask Bit */
#define CPP_OCIS_FEATURE_BIT (1<<8) /*!< \brief Offset Compensation Indicator Supported Feature Mask Bit */
#define CPP_OCS_FEATURE_BIT (1<<9) /*!< \brief Offset Compensation Supported Feature Mask Bit */
#define CPP_CPMCCM_FEATURE_BIT (1<<10) /*!< \brief Cycling Power Measurement Characteristic Content Masking Supported Offset Compensation Supported Feature Mask Bit */
#define CPP_MSLS_FEATURE_BIT (1<<11) /*!< \brief Multiple Sensor Locations Supported Feature Mask Bit */
#define CPP_CLAS_FEATURE_BIT (1<<12) /*!< \brief Crank Length Adjustment Supported Feature Mask Bit */
#define CPP_CHLAS_FEATURE_BIT (1<<13) /*!< \brief Chain Length Adjustment Supported Feature Mask Bit */
#define CPP_CHWAS_FEATURE_BIT (1<<14) /*!< \brief Chain Weight Adjustment Supported Feature Mask Bit */
#define CPP_SLAS_FEATURE_BIT (1<<15) /*!< \brief Span Length Adjustment Supported Feature Mask Bit */
#define CPP_SMC_FEATURE_BIT (1<<16) /*!< \brief Sensor Measurement Contex (0: FORCE, 1: TORQUE) */
#define CPP_IMDS_FEATURE_BIT (1<<17) /*!< \brief Instantaneous Measurement Direction Supported */
#define CPP_FCDS_FEATURE_BIT (1<<18) /*!< \brief Factory Calibration Date Supported Feature Mask Bit */
#define CPP_EOCS_FEATURE_BIT (1<<19) /*!< \brief Enhanced Offset Compensation Supported Feature Mask Bit */
#define CPP_DSS_FEATURE_BIT (1<<20) /*!< \brief Distribute System Support Feature Mask Bit */
/*! \brief TODO: Set to all supported features */
#define CPP_ALL_FEATURES (0xff) /*!< \brief All Supported Feature Mask */
/**@}*/
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Cycling Power Service Handles
*
*/
/**@{*/
#define CPS_START_HDL 0x0400 /*!< \brief Start handle. */
#define CPS_END_HDL (CPS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Cycling Power Service Handles */
enum
{
CPS_SVC_HDL = CPS_START_HDL, /*!< \brief Cycling Power Server Service declaration */
CPS_CPF_CH_HDL, /*!< \brief Cycling Power Feature characteristic */
CPS_CPF_HDL, /*!< \brief Cycling Power Feature */
CPS_CPM_CH_HDL, /*!< \brief Cycling Power Measurement characteristic */
CPS_CPM_HDL, /*!< \brief Cycling Power Measurement */
CPS_CPM_CH_CCC_HDL, /*!< \brief Cycling Power Measurement Client Characteristic Configuration Descriptor */
CPS_CPSL_CH_HDL, /*!< \brief Cycling Power Sensor Location characteristic */
CPS_CPSL_HDL, /*!< \brief Cycling Power Sensor Location */
CPS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCpsAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCpsRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCpsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*! \} */ /* CYCLING_POWER_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_CPS_H */
@@ -0,0 +1,216 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Cycling Speed and Cadence Service Server implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "att_uuid.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_cscs.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef CSCS_SEC_PERMIT_READ
#define CSCS_SEC_PERMIT_READ (ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC)
#endif
/*! Characteristic write permissions */
#ifndef CSCS_SEC_PERMIT_WRITE
#define CSCS_SEC_PERMIT_WRITE (ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC)
#endif
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Cycling Speed service declaration */
static const uint8_t cscsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_CYCLING_SPEED_SERVICE)};
static const uint16_t cscsLenSvc = sizeof(cscsValSvc);
/* Cycling Speed Feature characteristic */
static const uint8_t cscsValFeatureCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(CSCS_CSF_HDL), UINT16_TO_BYTES(ATT_UUID_CYCLING_SPEED_FEATURE)};
static const uint16_t cscsLenFeatureCh = sizeof(cscsValFeatureCh);
/* Cycling Speed Feature */
/* TODO: Set Supported Feature Bits */
static uint16_t cscsValFeature[] = {CSCS_WRDS_FEATURE_BIT};
static const uint16_t cscsLenFeature = sizeof(cscsValFeature);
/* Cycling Speed Measurement characteristic */
static const uint8_t cscsValMeasurementCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(CSCS_CSM_HDL), UINT16_TO_BYTES(ATT_UUID_CYCLING_SPEED_MEASUREMENT)};
static const uint16_t cscsLenMeasurementCh = sizeof(cscsValMeasurementCh);
/* Cycling Speed Measurement */
/* Note these are dummy values */
static const uint8_t cscsValMeasurement[] = { 0 };
static const uint16_t cscsLenMeasurement = CH_CSCS_MEASUREMENT_LEN;
/* Cycling Speed Measurement client characteristic configuration */
static uint8_t cscsValMeasurementChCcc[] = {UINT16_TO_BYTES(0x0000) };
static const uint16_t cscsLenMeasurementChCcc = sizeof(cscsValMeasurementChCcc);
/* Cycling Speed Sensor Location characteristic */
static const uint8_t cscsValLocationCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(CSCS_SL_HDL), UINT16_TO_BYTES(ATT_UUID_SENSOR_LOCATION)};
static const uint16_t cscsLenLocationCh = sizeof(cscsValLocationCh);
/* Cycling Speed Sensor Location */
/* Note these are dummy values */
static uint8_t cscsValLocation[] = { 0 };
static const uint16_t cscsLenLocation = sizeof(cscsValLocation);
/* Attribute list for CSCS group */
static const attsAttr_t cscsList[] =
{
/* Cycling Speed Service declaration */
{
attPrimSvcUuid,
(uint8_t *) cscsValSvc,
(uint16_t *) &cscsLenSvc,
sizeof(cscsValSvc),
0,
ATTS_PERMIT_READ
},
/* Cycling Speed Feature characteristic */
{
attChUuid,
(uint8_t *)cscsValFeatureCh,
(uint16_t *) &cscsLenFeatureCh,
sizeof(cscsValFeatureCh),
0,
ATTS_PERMIT_READ
},
/* Cycling Speed Feature value */
{
attCsfChUuid,
(uint8_t *)cscsValFeature,
(uint16_t *) &cscsLenFeature,
sizeof(cscsValFeature),
0,
CSCS_SEC_PERMIT_READ
},
/* Cycling Speed Measurement characteristic */
{
attChUuid,
(uint8_t *)cscsValMeasurementCh,
(uint16_t *)&cscsLenMeasurementCh,
sizeof(cscsValMeasurementCh),
0,
ATTS_PERMIT_READ
},
/* Cycling Speed Measurement value */
{
attCsmChUuid,
(uint8_t *)cscsValMeasurement,
(uint16_t *)&cscsLenMeasurement,
sizeof(cscsValMeasurement),
0,
0
},
/* Characteristic CCC descriptor */
{
attCliChCfgUuid,
cscsValMeasurementChCcc,
(uint16_t *)&cscsLenMeasurementChCcc,
sizeof(cscsValMeasurementChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | CSCS_SEC_PERMIT_WRITE)
},
/* Cycling Speed Sensor Location characteristic */
{
attChUuid,
(uint8_t *)cscsValLocationCh,
(uint16_t *)&cscsLenLocationCh,
sizeof(cscsValLocationCh),
0,
ATTS_PERMIT_READ
},
/* Cycling Speed Sensor Location value */
{
attSlChUuid,
(uint8_t *)cscsValLocation,
(uint16_t *)&cscsLenLocation,
sizeof(cscsValLocation),
0,
CSCS_SEC_PERMIT_READ
},
};
/* CSCS group structure */
static attsGroup_t svcCscsGroup =
{
NULL,
(attsAttr_t *) cscsList,
NULL,
NULL,
CSCS_START_HDL,
CSCS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCscsAddGroup(void)
{
AttsAddGroup(&svcCscsGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCscsRemoveGroup(void)
{
AttsRemoveGroup(CSCS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCscsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcCscsGroup.readCback = readCback;
svcCscsGroup.writeCback = writeCback;
}
@@ -0,0 +1,124 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Cycling Speed and Cadence Service Server implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_CSCS_H
#define SVC_CSCS_H
#include "att_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup CYCLING_SPEED_AND_CADENCE_SERVICE
* \{ */
/**************************************************************************************************
Constants
**************************************************************************************************/
/** \name CSC Feature Bits
* Cycle Speed and Cadence Feature Bits of the Feature Characteristic.
*/
/**@{*/
#define CSCS_WRDS_FEATURE_BIT (1<<0) /*!< \brief Wheel Revolution Data Supported Feature Mask Bit */
#define CSCS_CRDS_FEATURE_BIT (1<<1) /*!< \brief Crank Revolution Data Supported Feature Mask Bit */
#define CSCS_MSLS_FEATURE_BIT (1<<2) /*!< \brief Multiple Sensor Locations Supporte Feature Mask Bit */
/*! \brief TODO: Set to all supported features */
#define CSCS_ALL_FEATURES (0x3) /*!< \brief All Supported Feature Mask */
/**@}*/
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Cycling Speed and Cadence Service Handles
*
*/
/**@{*/
#define CSCS_START_HDL 0x0450 /*!< \brief Start handle. */
#define CSCS_END_HDL (CSCS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Cycling Speed Service Handles */
enum
{
CSCS_SVC_HDL = CSCS_START_HDL, /*!< \brief Cycling Speed Server Service declaration */
CSCS_CSF_CH_HDL, /*!< \brief Cycling Speed Feature characteristic */
CSCS_CSF_HDL, /*!< \brief Cycling Speed Feature */
CSCS_CSM_CH_HDL, /*!< \brief Cycling Speed Measurement characteristic */
CSCS_CSM_HDL, /*!< \brief Cycling Speed Measurement */
CSCS_CSM_CH_CCC_HDL, /*!< \brief Cycling Speed Measurement Client Characteristic Configuration Descriptor */
CSCS_SL_CH_HDL, /*!< \brief Cycling Speed Sensor Location characteristic */
CSCS_SL_HDL, /*!< \brief Cycling Speed Sensor Location */
CSCS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCscsAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCscsRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCscsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*! \} */ /* CYCLING_SPEED_AND_CADENCE_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_CSCS_H */
@@ -0,0 +1,259 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Constant Tone Extension Service implementation.
*
* Copyright (c) 2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_cte.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions. */
#ifndef CTE_SEC_PERMIT_READ
#define CTE_SEC_PERMIT_READ SVC_SEC_PERMIT_READ
#endif
/*! Characteristic write permissions. */
#ifndef CTE_SEC_PERMIT_WRITE
#define CTE_SEC_PERMIT_WRITE SVC_SEC_PERMIT_WRITE
#endif
/**************************************************************************************************
Static Variables
**************************************************************************************************/
/*! Constant Tone Extension service declaration. */
static const uint8_t cteValSvc[] = {UINT16_TO_BYTES(ATT_UUID_CONSTANT_TONE_SERVICE)};
static const uint16_t cteLenSvc = sizeof(cteValSvc);
/*! Constant Tone Extension enable characteristic. */
static const uint8_t cteValEnableCh[] = {ATT_PROP_WRITE, UINT16_TO_BYTES(CTE_ENABLE_HDL), UINT16_TO_BYTES(ATT_UUID_CTE_ENABLE)};
static const uint16_t cteLenEnableCh = sizeof(cteValEnableCh);
/*! Constant Tone Extension enable value. */
static uint8_t cteValEnable[] = {0};
static const uint16_t cteLenEnable = sizeof(cteValEnable);
/*! Constant Tone Extension minimum length characteristic. */
static const uint8_t cteValMinLenCh[] = {ATT_PROP_WRITE, UINT16_TO_BYTES(CTE_MIN_LEN_HDL), UINT16_TO_BYTES(ATT_UUID_CTE_MIN_LEN)};
static const uint16_t cteLenMinLenCh = sizeof(cteValMinLenCh);
/*! Constant Tone Extension minimum length value. */
static uint8_t cteValMinLen[] = {0};
static const uint16_t cteLenMinLen = sizeof(cteValMinLen);
/*! Constant Tone Extension minimum transmit count characteristic. */
static const uint8_t cteValMinTxCntCh[] = {ATT_PROP_WRITE, UINT16_TO_BYTES(CTE_ADV_MIN_TX_CNT_HDL), UINT16_TO_BYTES(ATT_UUID_CTE_TX_CNT)};
static const uint16_t cteLenMinTxCntCh = sizeof(cteValMinTxCntCh);
/*! Constant Tone Extension minimum transmit count value. */
static uint8_t cteValMinTxCnt[] = {0};
static const uint16_t cteLenMinTxCnt = sizeof(cteValMinTxCnt);
/*! Constant Tone Extension transmit duration characteristic */
static const uint8_t cteValTxDurCh[] = {ATT_PROP_WRITE, UINT16_TO_BYTES(CTE_ADV_TX_DURATION_HDL), UINT16_TO_BYTES(ATT_UUID_CTE_TX_DURATION)};
static const uint16_t cteLenTxDurCh = sizeof(cteValTxDurCh);
/*! Constant Tone Extension transmit duration value. */
static uint8_t cteValTxDur[] = {0};
static const uint16_t cteLenTxDur = sizeof(cteValTxDur);
/*! Constant Tone Extension interval characteristic. */
static const uint8_t cteValIntervalCh[] = {ATT_PROP_WRITE, UINT16_TO_BYTES(CTE_ADV_INTERVAL_HDL), UINT16_TO_BYTES(ATT_UUID_CTE_INTERVAL)};
static const uint16_t cteLenIntervalCh = sizeof(cteValIntervalCh);
/*! Constant Tone Extension interval value. */
static uint16_t cteValInterval[] = {0};
static const uint16_t cteLenInterval = sizeof(cteValInterval);
/*! Constant Tone Extension PHY characteristic. */
static const uint8_t cteValPhyCh[] = {ATT_PROP_WRITE, UINT16_TO_BYTES(CTE_ADV_EXT_PHY_HDL), UINT16_TO_BYTES(ATT_UUID_CTE_PHY)};
static const uint16_t cteLenPhyCh = sizeof(cteValPhyCh);
/*! Constant Tone Extension PHY value. */
static uint8_t cteValPhy[] = {0};
static const uint16_t cteLenPhy = sizeof(cteValPhy);
/*! Attribute list for CTE group. */
static const attsAttr_t cteList[] =
{
/* Constant Tone Extension service declaration. */
{
attPrimSvcUuid,
(uint8_t *) cteValSvc,
(uint16_t *) &cteLenSvc,
sizeof(cteValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) cteValEnableCh,
(uint16_t *) &cteLenEnableCh,
sizeof(cteValEnableCh),
0,
ATTS_PERMIT_READ
},
{
attCteEnChUuid,
(uint8_t *) cteValEnable,
(uint16_t *) &cteLenEnable,
sizeof(cteValEnable),
ATTS_SET_WRITE_CBACK,
SVC_SEC_PERMIT_WRITE
},
{
attChUuid,
(uint8_t *) cteValMinLenCh,
(uint16_t *) &cteLenMinLenCh,
sizeof(cteValMinLenCh),
0,
ATTS_PERMIT_READ
},
{
attCteMinLenChUuid,
(uint8_t *) cteValMinLen,
(uint16_t *) &cteLenMinLen,
sizeof(cteValMinLen),
ATTS_SET_WRITE_CBACK,
SVC_SEC_PERMIT_WRITE
},
{
attChUuid,
(uint8_t *) cteValMinTxCntCh,
(uint16_t *) &cteLenMinTxCntCh,
sizeof(cteValMinTxCntCh),
0,
ATTS_PERMIT_READ
},
{
attCteTxCntChUuid,
(uint8_t *) cteValMinTxCnt,
(uint16_t *) &cteLenMinTxCnt,
sizeof(cteValMinTxCnt),
ATTS_SET_WRITE_CBACK,
SVC_SEC_PERMIT_WRITE
},
{
attChUuid,
(uint8_t *) cteValTxDurCh,
(uint16_t *) &cteLenTxDurCh,
sizeof(cteValTxDurCh),
0,
ATTS_PERMIT_READ
},
{
attCteTxDurChUuid,
(uint8_t *) cteValTxDur,
(uint16_t *) &cteLenTxDur,
sizeof(cteValTxDur),
ATTS_SET_WRITE_CBACK,
SVC_SEC_PERMIT_WRITE
},
{
attChUuid,
(uint8_t *) cteValIntervalCh,
(uint16_t *) &cteLenIntervalCh,
sizeof(cteValIntervalCh),
0,
ATTS_PERMIT_READ
},
{
attCteIntChUuid,
(uint8_t *) cteValInterval,
(uint16_t *) &cteLenInterval,
sizeof(cteValInterval),
ATTS_SET_WRITE_CBACK,
SVC_SEC_PERMIT_WRITE
},
{
attChUuid,
(uint8_t *) cteValPhyCh,
(uint16_t *) &cteLenPhyCh,
sizeof(cteValPhyCh),
0,
ATTS_PERMIT_READ
},
{
attCtePhyChUuid,
(uint8_t *) cteValPhy,
(uint16_t *) &cteLenPhy,
sizeof(cteValPhy),
ATTS_SET_WRITE_CBACK,
SVC_SEC_PERMIT_WRITE
},
};
/*! CTE group structure. */
static attsGroup_t svcCteGroup =
{
NULL,
(attsAttr_t *) cteList,
NULL,
NULL,
CTE_START_HDL,
CTE_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCteAddGroup(void)
{
AttsAddGroup(&svcCteGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCteRemoveGroup(void)
{
AttsRemoveGroup(CTE_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCteCbackRegister(attsWriteCback_t writeCback)
{
svcCteGroup.writeCback = writeCback;
}
@@ -0,0 +1,134 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Constant Tone Extension Service implementation.
*
* Copyright (c) 2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_CTE_H
#define SVC_CTE_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup CTE-RELATED_SERVICE
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Enable bits */
#define CTE_ENABLE_NONE 0x00 /*!< CTE disable bitmask. */
#define CTE_ENABLE_ACL_BIT (0x01 << 0) /*!< ACL CTE Enable bit. */
#define CTE_ENABLE_ADV_BIT (0x01 << 1) /*!< Advertising CTE Enable bit. */
/*! Minimum length range */
#define CTE_MAX_MIN_LEN 20 /*!< Maximum CTE min length. */
#define CTE_MIN_MIN_LEN 2 /*!< Minimum CTE min length. */
/*! Minimum tx count range */
#define CTE_MAX_MIN_TX_CNT 15 /*!< Maximum CTE min tx count. */
#define CTE_MIN_MIN_TX_CNT 1 /*!< Minimum CTE min tx count. */
/*! Minimum interval (1.25 sec) */
#define CTE_MIN_INTERVAL 6 /*!< Minimum CTE interval. */
/*! PHY types */
#define CTE_PHY_1M 0 /*!< 1 Mbs CTE PHY type. */
#define CTE_PHY_2M 1 /*!< 2 Mbs CTE PHY type. */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name CTE Handles
*
*/
/**@{*/
#define CTE_START_HDL 0xB0 /*!< \brief Start handle. */
#define CTE_END_HDL (CTE_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief CTE-Related Service Handles */
enum
{
CTE_SVC_HDL = CTE_START_HDL, /*!< \brief Constant Tone Extension service declaration. */
CTE_ENABLE_CH_HDL, /*!< \brief Constant Tone Extension enable characteristic. */
CTE_ENABLE_HDL, /*!< \brief Constant Tone Extension enable. */
CTE_MIN_LEN_CH_HDL, /*!< \brief Constant Tone Extension minimum length characteristic. */
CTE_MIN_LEN_HDL, /*!< \brief Constant Tone Extension minimum length. */
CTE_ADV_MIN_TX_CNT_CH_HDL, /*!< \brief Constant Tone Extension minimum transmit count characteristic. */
CTE_ADV_MIN_TX_CNT_HDL, /*!< \brief Constant Tone Extension minimum transmit count. */
CTE_ADV_TX_DURATION_CH_HDL, /*!< \brief Constant Tone Extension transmit duration characteristic. */
CTE_ADV_TX_DURATION_HDL, /*!< \brief Constant Tone Extension transmit duration. */
CTE_ADV_INTERVAL_CH_HDL, /*!< \brief Constant Tone Extension interval characteristic. */
CTE_ADV_INTERVAL_HDL, /*!< \brief Constant Tone Extension interval. */
CTE_ADV_EXT_PHY_CH_HDL, /*!< \brief Constant Tone Extension PHY characteristic. */
CTE_ADV_EXT_PHY_HDL, /*!< \brief Constant Tone Extension PHY. */
CTE_MAX_HDL
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCteAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCteRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcCteCbackRegister(attsWriteCback_t writeCback);
/*! \} */ /* CTE-RELATED_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_CTE_H */
@@ -0,0 +1,331 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Device Information Service implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_dis.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef DIS_SEC_PERMIT_READ
#define DIS_SEC_PERMIT_READ SVC_SEC_PERMIT_READ
#endif
/*! Default manufacturer name */
#define DIS_DEFAULT_MFR_NAME "Arm Ltd."
/*! Length of default manufacturer name */
#define DIS_DEFAULT_MFR_NAME_LEN 8
/*! Default model number */
#define DIS_DEFAULT_MODEL_NUM "Cordio model num"
/*! Length of default model number */
#define DIS_DEFAULT_MODEL_NUM_LEN 16
/*! Default serial number */
#define DIS_DEFAULT_SERIAL_NUM "Cordio serial num"
/*! Length of default serial number */
#define DIS_DEFAULT_SERIAL_NUM_LEN 17
/*! Default firmware revision */
#define DIS_DEFAULT_FW_REV "Cordio fw rev"
/*! Length of default firmware revision */
#define DIS_DEFAULT_FW_REV_LEN 13
/*! Default hardware revision */
#define DIS_DEFAULT_HW_REV "Cordio hw rev"
/*! Length of default hardware revision */
#define DIS_DEFAULT_HW_REV_LEN 13
/*! Default software revision */
#define DIS_DEFAULT_SW_REV "Cordio sw rev"
/*! Length of default software revision */
#define DIS_DEFAULT_SW_REV_LEN 13
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Device information service declaration */
static const uint8_t disValSvc[] = {UINT16_TO_BYTES(ATT_UUID_DEVICE_INFO_SERVICE)};
static const uint16_t disLenSvc = sizeof(disValSvc);
/* Manufacturer name string characteristic */
static const uint8_t disValMfrCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(DIS_MFR_HDL), UINT16_TO_BYTES(ATT_UUID_MANUFACTURER_NAME)};
static const uint16_t disLenMfrCh = sizeof(disValMfrCh);
/* Manufacturer name string */
static const uint8_t disUuMfr[] = {UINT16_TO_BYTES(ATT_UUID_MANUFACTURER_NAME)};
static uint8_t disValMfr[DIS_MAXSIZE_MFR_ATT] = DIS_DEFAULT_MFR_NAME;
static uint16_t disLenMfr = DIS_DEFAULT_MFR_NAME_LEN;
/* System ID characteristic */
static const uint8_t disValSidCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(DIS_SID_HDL), UINT16_TO_BYTES(ATT_UUID_SYSTEM_ID)};
static const uint16_t disLenSidCh = sizeof(disValSidCh);
/* System ID */
static const uint8_t disUuSid[] = {UINT16_TO_BYTES(ATT_UUID_SYSTEM_ID)};
static uint8_t disValSid[DIS_SIZE_SID_ATT] = {0x01, 0x02, 0x03, 0x04, 0x05, UINT16_TO_BYTE0(HCI_ID_ARM), UINT16_TO_BYTE1(HCI_ID_ARM), 0x00};
static const uint16_t disLenSid = sizeof(disValSid);
/* Model number string characteristic */
static const uint8_t disValMnCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(DIS_MN_HDL), UINT16_TO_BYTES(ATT_UUID_MODEL_NUMBER)};
static const uint16_t disLenMnCh = sizeof(disValMnCh);
/* Model number string */
static const uint8_t disUuMn[] = {UINT16_TO_BYTES(ATT_UUID_MODEL_NUMBER)};
static uint8_t disValMn[DIS_MAXSIZE_MN_ATT] = DIS_DEFAULT_MODEL_NUM;
static uint16_t disLenMn = DIS_DEFAULT_MODEL_NUM_LEN;
/* Serial number string characteristic */
static const uint8_t disValSnCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(DIS_SN_HDL), UINT16_TO_BYTES(ATT_UUID_SERIAL_NUMBER)};
static const uint16_t disLenSnCh = sizeof(disValSnCh);
/* Serial number string */
static const uint8_t disUuSn[] = {UINT16_TO_BYTES(ATT_UUID_SERIAL_NUMBER)};
static uint8_t disValSn[DIS_MAXSIZE_SN_ATT] = DIS_DEFAULT_SERIAL_NUM;
static uint16_t disLenSn = DIS_DEFAULT_SERIAL_NUM_LEN;
/* Firmware revision string characteristic */
static const uint8_t disValFwrCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(DIS_FWR_HDL), UINT16_TO_BYTES(ATT_UUID_FIRMWARE_REV)};
static const uint16_t disLenFwrCh = sizeof(disValFwrCh);
/* Firmware revision string */
static const uint8_t disUuFwr[] = {UINT16_TO_BYTES(ATT_UUID_FIRMWARE_REV)};
static uint8_t disValFwr[DIS_MAXSIZE_FWR_ATT] = DIS_DEFAULT_FW_REV;
static uint16_t disLenFwr = DIS_DEFAULT_FW_REV_LEN;
/* Hardware revision string characteristic */
static const uint8_t disValHwrCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(DIS_HWR_HDL), UINT16_TO_BYTES(ATT_UUID_HARDWARE_REV)};
static const uint16_t disLenHwrCh = sizeof(disValHwrCh);
/* Hardware revision string */
static const uint8_t disUuHwr[] = {UINT16_TO_BYTES(ATT_UUID_HARDWARE_REV)};
static uint8_t disValHwr[DIS_MAXSIZE_HWR_ATT] = DIS_DEFAULT_HW_REV;
static uint16_t disLenHwr = DIS_DEFAULT_HW_REV_LEN;
/* Software revision string characteristic */
static const uint8_t disValSwrCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(DIS_SWR_HDL), UINT16_TO_BYTES(ATT_UUID_SOFTWARE_REV)};
static const uint16_t disLenSwrCh = sizeof(disValSwrCh);
/* Software revision string */
static const uint8_t disUuSwr[] = {UINT16_TO_BYTES(ATT_UUID_SOFTWARE_REV)};
static uint8_t disValSwr[DIS_MAXSIZE_SWR_ATT] = DIS_DEFAULT_SW_REV;
static uint16_t disLenSwr = DIS_DEFAULT_SW_REV_LEN;
/* Registration certificate data characteristic */
static const uint8_t disValRcdCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(DIS_RCD_HDL), UINT16_TO_BYTES(ATT_UUID_11073_CERT_DATA)};
static const uint16_t disLenRcdCh = sizeof(disValRcdCh);
/* Registration certificate data */
static const uint8_t disUuRcd[] = {UINT16_TO_BYTES(ATT_UUID_11073_CERT_DATA)};
static uint8_t disValRcd[DIS_SIZE_RCD_ATT] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static const uint16_t disLenRcd = sizeof(disValRcd);
/* Attribute list for dis group */
static const attsAttr_t disList[] =
{
{
attPrimSvcUuid,
(uint8_t *) disValSvc,
(uint16_t *) &disLenSvc,
sizeof(disValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) disValMfrCh,
(uint16_t *) &disLenMfrCh,
sizeof(disValMfrCh),
0,
ATTS_PERMIT_READ
},
{
disUuMfr,
(uint8_t *) disValMfr,
(uint16_t *) &disLenMfr,
sizeof(disValMfr),
ATTS_SET_VARIABLE_LEN,
DIS_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) disValSidCh,
(uint16_t *) &disLenSidCh,
sizeof(disValSidCh),
0,
ATTS_PERMIT_READ
},
{
disUuSid,
disValSid,
(uint16_t *) &disLenSid,
sizeof(disValSid),
0,
DIS_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) disValMnCh,
(uint16_t *) &disLenMnCh,
sizeof(disValMnCh),
0,
ATTS_PERMIT_READ
},
{
disUuMn,
(uint8_t *) disValMn,
(uint16_t *) &disLenMn,
sizeof(disValMn),
ATTS_SET_VARIABLE_LEN,
DIS_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) disValSnCh,
(uint16_t *) &disLenSnCh,
sizeof(disValSnCh),
0,
ATTS_PERMIT_READ
},
{
disUuSn,
(uint8_t *) disValSn,
(uint16_t *) &disLenSn,
sizeof(disValSn),
ATTS_SET_VARIABLE_LEN,
DIS_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) disValFwrCh,
(uint16_t *) &disLenFwrCh,
sizeof(disValFwrCh),
0,
ATTS_PERMIT_READ
},
{
disUuFwr,
(uint8_t *) disValFwr,
(uint16_t *) &disLenFwr,
sizeof(disValFwr),
ATTS_SET_VARIABLE_LEN,
DIS_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) disValHwrCh,
(uint16_t *) &disLenHwrCh,
sizeof(disValHwrCh),
0,
ATTS_PERMIT_READ
},
{
disUuHwr,
(uint8_t *) disValHwr,
(uint16_t *) &disLenHwr,
sizeof(disValHwr),
ATTS_SET_VARIABLE_LEN,
DIS_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) disValSwrCh,
(uint16_t *) &disLenSwrCh,
sizeof(disValSwrCh),
0,
ATTS_PERMIT_READ
},
{
disUuSwr,
(uint8_t *) disValSwr,
(uint16_t *) &disLenSwr,
sizeof(disValSwr),
ATTS_SET_VARIABLE_LEN,
DIS_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) disValRcdCh,
(uint16_t *) &disLenRcdCh,
sizeof(disValRcdCh),
0,
ATTS_PERMIT_READ
},
{
disUuRcd,
(uint8_t *) disValRcd,
(uint16_t *) &disLenRcd,
sizeof(disValRcd),
0,
DIS_SEC_PERMIT_READ
},
};
/* DIS group structure */
static attsGroup_t svcDisGroup =
{
NULL,
(attsAttr_t *) disList,
NULL,
NULL,
DIS_START_HDL,
DIS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcDisAddGroup(void)
{
AttsAddGroup(&svcDisGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcDisRemoveGroup(void)
{
AttsRemoveGroup(DIS_START_HDL);
}
@@ -0,0 +1,145 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Device Information Service implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_DIS_H
#define SVC_DIS_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup DEVICE_INFORMATION_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Device Information Service Handles
*
*/
/**@{*/
/*! \brief Device Information Service */
#define DIS_START_HDL 0x30 /*!< \brief Start handle. */
#define DIS_END_HDL (DIS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Device Information Service Handles */
enum
{
DIS_SVC_HDL = DIS_START_HDL, /*!< \brief Information service declaration */
DIS_MFR_CH_HDL, /*!< \brief Manufacturer name string characteristic */
DIS_MFR_HDL, /*!< \brief Manufacturer name string */
DIS_SID_CH_HDL, /*!< \brief System ID characteristic */
DIS_SID_HDL, /*!< \brief System ID */
DIS_MN_CH_HDL, /*!< \brief Model number string characteristic */
DIS_MN_HDL, /*!< \brief Model number string */
DIS_SN_CH_HDL, /*!< \brief Serial number string characteristic */
DIS_SN_HDL, /*!< \brief Serial number string */
DIS_FWR_CH_HDL, /*!< \brief Firmware revision string characteristic */
DIS_FWR_HDL, /*!< \brief Firmware revision string */
DIS_HWR_CH_HDL, /*!< \brief Hardware revision string characteristic */
DIS_HWR_HDL, /*!< \brief Hardware revision string */
DIS_SWR_CH_HDL, /*!< \brief Software revision string characteristic */
DIS_SWR_HDL, /*!< \brief Software revision string */
DIS_RCD_CH_HDL, /*!< \brief Registration certificate data characteristic */
DIS_RCD_HDL, /*!< \brief Registration certificate data */
DIS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Macros
**************************************************************************************************/
/** \name Size of Attributes
*
*/
/**@{*/
#ifndef DIS_MAXSIZE_MFR_ATT
#define DIS_MAXSIZE_MFR_ATT 20 /*!< \brief Size of manufacturer name string attribute */
#endif
#ifndef DIS_MAXSIZE_MN_ATT
#define DIS_MAXSIZE_MN_ATT 20 /*!< \brief Size of model number string attribute */
#endif
#ifndef DIS_MAXSIZE_SN_ATT
#define DIS_MAXSIZE_SN_ATT 20 /*!< \brief Size of serial number string attribute */
#endif
#ifndef DIS_MAXSIZE_FWR_ATT
#define DIS_MAXSIZE_FWR_ATT 16 /*!< \brief Size of firmware revision string attribute */
#endif
#ifndef DIS_MAXSIZE_HWR_ATT
#define DIS_MAXSIZE_HWR_ATT 16 /*!< \brief Size of hardware revision string attribute */
#endif
#ifndef DIS_MAXSIZE_SWR_ATT
#define DIS_MAXSIZE_SWR_ATT 16 /*!< \brief Size of software revision string attribute */
#endif
#ifndef DIS_SIZE_SID_ATT
#define DIS_SIZE_SID_ATT 8 /*!< \brief Size of system id attribute */
#endif
#ifndef DIS_SIZE_RCD_ATT
#define DIS_SIZE_RCD_ATT 6 /*!< \brief Size of registration certificate data attribute */
#endif
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcDisAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcDisRemoveGroup(void);
/*! \} */ /* DEVICE_INFORMATION_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_DIS_H */
@@ -0,0 +1,264 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Glucose service implementation.
*
* Copyright (c) 2012-2019 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_gls.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef GLS_SEC_PERMIT_READ
#define GLS_SEC_PERMIT_READ (ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC)
#endif
/*! Characteristic write permissions */
#ifndef GLS_SEC_PERMIT_WRITE
#define GLS_SEC_PERMIT_WRITE (ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC)
#endif
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Glucose service declaration */
static const uint8_t glsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_GLUCOSE_SERVICE)};
static const uint16_t glsLenSvc = sizeof(glsValSvc);
/* Glucose measurement characteristic */
static const uint8_t glsValGlmCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(GLS_GLM_HDL), UINT16_TO_BYTES(ATT_UUID_GLUCOSE_MEAS)};
static const uint16_t glsLenGlmCh = sizeof(glsValGlmCh);
/* Glucose measurement */
/* Note these are dummy values */
static const uint8_t glsValGlm[] = {0};
static const uint16_t glsLenGlm = sizeof(glsValGlm);
/* Glucose measurement client characteristic configuration */
static uint8_t glsValGlmChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t glsLenGlmChCcc = sizeof(glsValGlmChCcc);
/* Glucose measurement context characteristic */
static const uint8_t glsValGlmcCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(GLS_GLMC_HDL), UINT16_TO_BYTES(ATT_UUID_GLUCOSE_MEAS_CONTEXT)};
static const uint16_t glsLenGlmcCh = sizeof(glsValGlmcCh);
/* Glucose measurement context */
/* Note these are dummy values */
static const uint8_t glsValGlmc[] = {0};
static const uint16_t glsLenGlmc = sizeof(glsValGlmc);
/* Glucose measurement context client characteristic configuration */
static uint8_t glsValGlmcChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t glsLenGlmcChCcc = sizeof(glsValGlmcChCcc);
/* Glucose feature characteristic */
static const uint8_t glsValGlfCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(GLS_GLF_HDL), UINT16_TO_BYTES(ATT_UUID_GLUCOSE_FEATURE)};
static const uint16_t glsLenGlfCh = sizeof(glsValGlfCh);
/* Glucose feature */
static uint8_t glsValGlf[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t glsLenGlf = sizeof(glsValGlf);
/* Control point characteristic */
static const uint8_t glsValRacpCh[] = {(ATT_PROP_INDICATE | ATT_PROP_WRITE), UINT16_TO_BYTES(GLS_RACP_HDL), UINT16_TO_BYTES(ATT_UUID_RACP)};
static const uint16_t glsLenRacpCh = sizeof(glsValRacpCh);
/* Record access control point */
/* Note these are dummy values */
static const uint8_t glsValRacp[] = {0};
static const uint16_t glsLenRacp = sizeof(glsValRacp);
/* Record access control point client characteristic configuration */
static uint8_t glsValRacpChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t glsLenRacpChCcc = sizeof(glsValRacpChCcc);
/* Attribute list for GLS group */
static const attsAttr_t glsList[] =
{
/* Service declaration */
{
attPrimSvcUuid,
(uint8_t *) glsValSvc,
(uint16_t *) &glsLenSvc,
sizeof(glsValSvc),
0,
ATTS_PERMIT_READ
},
/* Glucose measurement characteristic declaration */
{
attChUuid,
(uint8_t *) glsValGlmCh,
(uint16_t *) &glsLenGlmCh,
sizeof(glsValGlmCh),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
attGlmChUuid,
(uint8_t *) glsValGlm,
(uint16_t *) &glsLenGlm,
sizeof(glsValGlm),
0,
0
},
/* Client characteristic configuration descriptor */
{
attCliChCfgUuid,
(uint8_t *) glsValGlmChCcc,
(uint16_t *) &glsLenGlmChCcc,
sizeof(glsValGlmChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | GLS_SEC_PERMIT_WRITE)
},
/* Glucose measurement context characteristic declaration */
{
attChUuid,
(uint8_t *) glsValGlmcCh,
(uint16_t *) &glsLenGlmcCh,
sizeof(glsValGlmcCh),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
attGlmcChUuid,
(uint8_t *) glsValGlmc,
(uint16_t *) &glsLenGlmc,
sizeof(glsValGlmc),
0,
0
},
/* Client characteristic configuration descriptor */
{
attCliChCfgUuid,
(uint8_t *) glsValGlmcChCcc,
(uint16_t *) &glsLenGlmcChCcc,
sizeof(glsValGlmcChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | GLS_SEC_PERMIT_WRITE)
},
/* Glucose feature characteristic declaration */
{
attChUuid,
(uint8_t *) glsValGlfCh,
(uint16_t *) &glsLenGlfCh,
sizeof(glsValGlfCh),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
attGlfChUuid,
glsValGlf,
(uint16_t *) &glsLenGlf,
sizeof(glsValGlf),
0,
GLS_SEC_PERMIT_READ
},
/* Record access control point characteristic delclaration */
{
attChUuid,
(uint8_t *) glsValRacpCh,
(uint16_t *) &glsLenRacpCh,
sizeof(glsValRacpCh),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
attRacpChUuid,
(uint8_t *) glsValRacp,
(uint16_t *) &glsLenRacp,
ATT_DEFAULT_PAYLOAD_LEN,
(ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
GLS_SEC_PERMIT_WRITE
},
/* Client characteristic configuration descriptor */
{
attCliChCfgUuid,
(uint8_t *) glsValRacpChCcc,
(uint16_t *) &glsLenRacpChCcc,
sizeof(glsValRacpChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | GLS_SEC_PERMIT_WRITE)
},
};
/* GLS group structure */
static attsGroup_t svcGlsGroup =
{
NULL,
(attsAttr_t *) glsList,
NULL,
NULL,
GLS_START_HDL,
GLS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGlsAddGroup(void)
{
AttsAddGroup(&svcGlsGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGlsRemoveGroup(void)
{
AttsRemoveGroup(GLS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGlsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcGlsGroup.readCback = readCback;
svcGlsGroup.writeCback = writeCback;
}
@@ -0,0 +1,121 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Glucose service implementation.
*
* Copyright (c) 2012-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_GLS_H
#define SVC_GLS_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup GLUCOSE_SERVICE
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/** \name Error Codes
*
*/
/**@{*/
#define GLS_ERR_IN_PROGRESS 0x80 /*!< \brief Procedure already in progress */
#define GLS_ERR_CCCD 0x81 /*!< \brief CCCD improperly configured */
/**@}*/
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Glucose Service Handles
*
*/
/**@{*/
#define GLS_START_HDL 0xF0 /*!< \brief Start handle. */
#define GLS_END_HDL (GLS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Glucose Service Handles */
enum
{
GLS_SVC_HDL = GLS_START_HDL, /*!< \brief Glucose service declaration */
GLS_GLM_CH_HDL, /*!< \brief Glucose measurement characteristic */
GLS_GLM_HDL, /*!< \brief Glucose measurement */
GLS_GLM_CH_CCC_HDL, /*!< \brief Glucose measurement client characteristic configuration */
GLS_GLMC_CH_HDL, /*!< \brief Glucose measurement context characteristic */
GLS_GLMC_HDL, /*!< \brief Glucose measurement context */
GLS_GLMC_CH_CCC_HDL, /*!< \brief Glucose measurement context client characteristic configuration */
GLS_GLF_CH_HDL, /*!< \brief Glucose feature characteristic */
GLS_GLF_HDL, /*!< \brief Glucose feature */
GLS_RACP_CH_HDL, /*!< \brief Record access control point characteristic */
GLS_RACP_HDL, /*!< \brief Record access control point */
GLS_RACP_CH_CCC_HDL, /*!< \brief Record access control point client characteristic configuration */
GLS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGlsAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGlsRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGlsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*! \} */ /* GLUCOSE_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_GLS_H */
@@ -0,0 +1,307 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example gyroscope sensor service implementation.
*
* Copyright (c) 2015-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_cfg.h"
#include "svc_gyro.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
#define GYRO_UUID_SVC 0x3000
#define GYRO_UUID_CHR_DATA 0x3001
#define GYRO_UUID_CHR_TEMPDATA 0x3002
#define GYRO_UUID_CHR_CONFIG 0x3003
#define GYRO_UUID_CHR_PERIOD 0x3004
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Gyroscope service declaration. */
static const uint8_t gyroValSvc[] = {UINT16_TO_BYTES(GYRO_UUID_SVC)};
static const uint16_t gyroLenSvc = sizeof(gyroValSvc);
/* Gyroscope data characteristic. */
static const uint8_t gyroValDataChr[] = {ATT_PROP_READ | ATT_PROP_NOTIFY,
UINT16_TO_BYTES(GYRO_HANDLE_DATA),
UINT16_TO_BYTES(GYRO_UUID_CHR_DATA)};
static const uint16_t gyroLenDataChr = sizeof(gyroValDataChr);
/* Gyroscope data. */
static const uint8_t gyroUuidData[] = {UINT16_TO_BYTES(GYRO_UUID_CHR_DATA)};
static uint8_t gyroValData[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static const uint16_t gyroLenData = sizeof(gyroValData);
/* Gyroscope data client characteristic configuration. */
static uint8_t gyroValDataClientChrConfig[] = {0x00, 0x00};
static const uint16_t gyroLenDataClientChrConfig = sizeof(gyroValDataClientChrConfig);
/* Gyroscope data characteristic user description. */
static const uint8_t gyroValDataChrUsrDescr[] = "SMD Gyro Data";
static const uint16_t gyroLenDataChrUsrDescr = sizeof(gyroValDataChrUsrDescr) - 1u;
/* Gyroscope tempdata characteristic. */
static const uint8_t gyroValTempDataChr[] = {ATT_PROP_READ | ATT_PROP_NOTIFY,
UINT16_TO_BYTES(GYRO_HANDLE_TEMPDATA),
UINT16_TO_BYTES(GYRO_UUID_CHR_TEMPDATA)};
static const uint16_t gyroLenTempDataChr = sizeof(gyroValTempDataChr);
/* Gyroscope tempdata. */
static const uint8_t gyroUuidTempData[] = {UINT16_TO_BYTES(GYRO_UUID_CHR_TEMPDATA)};
static uint8_t gyroValTempData[] = {0x00, 0x00};
static const uint16_t gyroLenTempData = sizeof(gyroValTempData);
/* Gyroscope tempdata client characteristic configuration. */
static uint8_t gyroValTempDataClientChrConfig[] = {0x00, 0x00};
static const uint16_t gyroLenTempDataClientChrConfig = sizeof(gyroValTempDataClientChrConfig);
/* Gyroscope tempdata characteristic user description. */
static const uint8_t gyroValTempDataChrUsrDescr[] = "SMD Gyro Temp Data";
static const uint16_t gyroLenTempDataChrUsrDescr = sizeof(gyroValTempDataChrUsrDescr) - 1u;
/* Gyroscope config characteristic. */
static const uint8_t gyroValConfigChr[] = {ATT_PROP_READ | ATT_PROP_WRITE,
UINT16_TO_BYTES(GYRO_HANDLE_CONFIG),
UINT16_TO_BYTES(GYRO_UUID_CHR_CONFIG)};
static const uint16_t gyroLenConfigChr = sizeof(gyroValConfigChr);
/* Gyroscope config. */
static const uint8_t gyroUuidConfig[] = {UINT16_TO_BYTES(GYRO_UUID_CHR_CONFIG)};
static uint8_t gyroValConfig[] = {0x00};
static const uint16_t gyroLenConfig = sizeof(gyroValConfig);
/* Gyroscope config characteristic user description. */
static const uint8_t gyroValConfigChrUsrDescr[] = "SMD Gyro Config";
static const uint16_t gyroLenConfigChrUsrDescr = sizeof(gyroValConfigChrUsrDescr) - 1u;
/* Gyroscope period characteristic. */
static const uint8_t gyroValPeriodChr[] = {ATT_PROP_READ | ATT_PROP_WRITE,
UINT16_TO_BYTES(GYRO_HANDLE_PERIOD),
UINT16_TO_BYTES(GYRO_UUID_CHR_PERIOD)};
static const uint16_t gyroLenPeriodChr = sizeof(gyroValPeriodChr);
/* Gyroscope period. */
static const uint8_t gyroUuidPeriod[] = {UINT16_TO_BYTES(GYRO_UUID_CHR_PERIOD)};
static uint8_t gyroValPeriod[] = {GYRO_ATT_PERIOD_DEFAULT};
static const uint16_t gyroLenPeriod = sizeof(gyroValPeriod);
/* Gyroscope period characteristic user description. */
static const uint8_t gyroValPeriodChrUsrDescr[] = "SMD Gyro Period";
static const uint16_t gyroLenPeriodChrUsrDescr = sizeof(gyroValPeriodChrUsrDescr) - 1u;
/* Attribute list for gyro group. */
static const attsAttr_t gyroList[] =
{
/* Service declaration. */
{
attPrimSvcUuid,
(uint8_t *) gyroValSvc,
(uint16_t *) &gyroLenSvc,
sizeof(gyroValSvc),
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration. */
{
attChUuid,
(uint8_t *) gyroValDataChr,
(uint16_t *) &gyroLenDataChr,
sizeof(gyroValDataChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value. */
{
gyroUuidData,
(uint8_t *) gyroValData,
(uint16_t *) &gyroLenData,
sizeof(gyroValData),
0,
ATTS_PERMIT_READ
},
/* Client characteristic configuration. */
{
attCliChCfgUuid,
(uint8_t *) gyroValDataClientChrConfig,
(uint16_t *) &gyroLenDataClientChrConfig,
sizeof(gyroValDataClientChrConfig),
ATTS_SET_CCC,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description. */
{
attChUserDescUuid,
(uint8_t *) gyroValDataChrUsrDescr,
(uint16_t *) &gyroLenDataChrUsrDescr,
sizeof(gyroValDataChrUsrDescr) - 1,
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration. */
{
attChUuid,
(uint8_t *) gyroValTempDataChr,
(uint16_t *) &gyroLenTempDataChr,
sizeof(gyroValTempDataChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value. */
{
gyroUuidTempData,
(uint8_t *) gyroValTempData,
(uint16_t *) &gyroLenTempData,
sizeof(gyroValTempData),
0, /*ATTS_SET_UUID_128, */
ATTS_PERMIT_READ
},
/* Client characteristic configuration. */
{
attCliChCfgUuid,
(uint8_t *) gyroValTempDataClientChrConfig,
(uint16_t *) &gyroLenTempDataClientChrConfig,
sizeof(gyroValTempDataClientChrConfig),
ATTS_SET_CCC,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description. */
{
attChUserDescUuid,
(uint8_t *) gyroValTempDataChrUsrDescr,
(uint16_t *) &gyroLenTempDataChrUsrDescr,
sizeof(gyroValTempDataChrUsrDescr),
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration. */
{
attChUuid,
(uint8_t *) gyroValConfigChr,
(uint16_t *) &gyroLenConfigChr,
sizeof(gyroValConfigChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value. */
{
gyroUuidConfig,
(uint8_t *) gyroValConfig,
(uint16_t *) &gyroLenConfig,
sizeof(gyroValConfig),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description. */
{
attChUserDescUuid,
(uint8_t *) gyroValConfigChrUsrDescr,
(uint16_t *) &gyroLenConfigChrUsrDescr,
sizeof(gyroValConfigChrUsrDescr),
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration. */
{
attChUuid,
(uint8_t *) gyroValPeriodChr,
(uint16_t *) &gyroLenPeriodChr,
sizeof(gyroValPeriodChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value. */
{
gyroUuidPeriod,
(uint8_t *) gyroValPeriod,
(uint16_t *) &gyroLenPeriod,
sizeof(gyroValPeriod),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description. */
{
attChUserDescUuid,
(uint8_t *) gyroValPeriodChrUsrDescr,
(uint16_t *) &gyroLenPeriodChrUsrDescr,
sizeof(gyroValPeriodChrUsrDescr),
0,
ATTS_PERMIT_READ
}
};
/* Gyro group structure. */
static attsGroup_t gyroGroup =
{
NULL,
(attsAttr_t *) gyroList,
NULL,
NULL,
GYRO_HANDLE_START,
GYRO_HANDLE_END
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGyroAddGroup(void)
{
AttsAddGroup(&gyroGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGyroRemoveGroup(void)
{
AttsRemoveGroup(GYRO_HANDLE_START);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGyroCbackRegister(attsWriteCback_t writeCback)
{
gyroGroup.writeCback = writeCback;
}
@@ -0,0 +1,144 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example gyroscope sensor service implementation.
*
* Copyright (c) 2015-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_GYRO_H
#define SVC_GYRO_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup GYROSCOPE_SENSOR_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Gyroscope Sensor Service Handles
*
*/
/**@{*/
#define GYRO_HANDLE_START 0x50 /*!< \brief Start handle. */
#define GYRO_HANDLE_END (GYRO_HANDLE_END_PLUS_ONE - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Gyroscope service handles. */
enum
{
GYRO_HANDLE_SVC = GYRO_HANDLE_START, /*!< \brief Service declaration. */
GYRO_HANDLE_DATA_CHR, /*!< \brief Data characteristic declaration. */
GYRO_HANDLE_DATA, /*!< \brief Data characteristic value. */
GYRO_HANDLE_DATA_CLIENT_CHR_CONFIG, /*!< \brief Data characteristic CCCD. */
GYRO_HANDLE_DATA_CHR_USR_DESCR, /*!< \brief Data characteristic user description. */
GYRO_HANDLE_TEMPDATA_CHR, /*!< \brief Temporary data characteristic declaration. */
GYRO_HANDLE_TEMPDATA, /*!< \brief Temporary data characteristic value. */
GYRO_HANDLE_TEMPDATA_CLIENT_CHR_CONFIG, /*!< \brief Temporary data characteristic CCCD. */
GYRO_HANDLE_TEMPDATA_CHR_USR_DESCR, /*!< \brief Temporary data characteristic user description. */
GYRO_HANDLE_CONFIG_CHR, /*!< \brief Configuration characteristic delcaration. */
GYRO_HANDLE_CONFIG, /*!< \brief Configuration characteristic value. */
GYRO_HANDLE_CONFIG_CHR_USR_DESCR, /*!< \brief Configuration characteristic user description. */
GYRO_HANDLE_PERIOD_CHR, /*!< \brief Period characteristic declaration. */
GYRO_HANDLE_PERIOD, /*!< \brief Period characteristic value. */
GYRO_HANDLE_PERIOD_CHR_USR_DESCR, /*!< \brief Period characteristic user description. */
GYRO_HANDLE_END_PLUS_ONE /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Macros
**************************************************************************************************/
/** \name Values for Config Attributes
*
*/
/**@{*/
#define GYRO_ATT_CONFIG_DISABLE 0x00u /*!< \brief Disable */
#define GYRO_ATT_CONFIG_ENABLE 0x01u /*!< \brief Enable */
/**@}*/
/** \name Values for Period Attributes.
*
*/
/**@{*/
#define GYRO_ATT_PERIOD_MAX 250u /*!< \brief Maximum period */
#define GYRO_ATT_PERIOD_DEFAULT 100u /*!< \brief Default period */
#define GYRO_ATT_PERIOD_MIN 10u /*!< \brief Minimum period */
/**@}*/
/*! \brief Sizes of attributes. */
#define GYRO_SIZE_CONFIG_ATT 1u /*!< \brief Configuration attribute size */
#define GYRO_SIZE_PERIOD_ATT 1u /*!< \brief Period attribute size */
#define GYRO_SIZE_DATA_ATT 6u /*!< \brief Data attribute size */
#define GYRO_SIZE_TEMPDATA_ATT 2u /*!< \brief Temp data attribute size */
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGyroAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGyroRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcGyroCbackRegister(attsWriteCback_t writeCback);
/*! \} */ /* GYROSCOPE_SENSOR_SERVICE */
#ifdef __cplusplus
}
#endif
#endif /* SVC_GYRO_H */
@@ -0,0 +1,676 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Human Interface Device service implementation.
*
* Copyright (c) 2015-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "util/bstream.h"
#include "att_api.h"
#include "svc_hid.h"
#include "wsf_trace.h"
#include "svc_ch.h"
#include "svc_cfg.h"
#include "svc_batt.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef HID_SEC_PERMIT_READ
#define HID_SEC_PERMIT_READ (ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC)
#endif
/*! Characteristic write permissions */
#ifndef HID_SEC_PERMIT_WRITE
#define HID_SEC_PERMIT_WRITE (ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC)
#endif
/**************************************************************************************************
Static Variables
**************************************************************************************************/
/* UUIDs */
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Proprietary Service Declaration */
static const uint8_t hidValSvc[] = {UINT16_TO_BYTES(ATT_UUID_HID_SERVICE)};
static const uint16_t hidLenSvc = sizeof(hidValSvc);
/* HID Info Characteristic */
static const uint8_t hidInfoCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(HID_INFO_HDL), UINT16_TO_BYTES(ATT_UUID_HID_INFORMATION)};
static const uint16_t hidLenInfoCh = sizeof(hidInfoCh);
/* HID Info Value: HID Spec version, country code, flags */
static const uint8_t hidInfoVal[] = {UINT16_TO_BYTES(HID_VERSION), 0x00, 0x00};
static const uint16_t hidLenInfoVal = sizeof(hidInfoVal);
/* HID Report Map Characteristic */
static const uint8_t hidRmCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(HID_REPORT_MAP_HDL), UINT16_TO_BYTES(ATT_UUID_HID_REPORT_MAP)};
static const uint16_t hidLenRmCh = sizeof(hidRmCh);
/* HID Report Map Value */
/* Note: The hidReportMap and hidReportMapLen variables should be defined in the application */
extern const uint8_t hidReportMap[];
extern const uint16_t hidReportMapLen;
/* HID External Report Reference Descriptor */
static const uint8_t hidExtReport[] = {UINT16_TO_BYTES(ATT_UUID_BATTERY_LEVEL)};
static const uint16_t hidLenExtReport = sizeof(hidExtReport);
/* HID Control Point Characteristic */
static const uint8_t hidCpCh[] = {ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(HID_CONTROL_POINT_HDL), UINT16_TO_BYTES(ATT_UUID_HID_CONTROL_POINT)};
static const uint16_t hidLenCpCh = sizeof(hidCpCh);
/* HID Control Point Value */
static uint8_t hidCpVal[] = {0};
static const uint16_t hidLenCpVal = sizeof(hidCpVal);
/* HID Boot Keyboard In Characteristic */
static const uint8_t hidBkiCh[] = {ATT_PROP_READ | ATT_PROP_NOTIFY, UINT16_TO_BYTES(HID_KEYBOARD_BOOT_IN_HDL), UINT16_TO_BYTES(ATT_UUID_HID_BOOT_KEYBOARD_IN)};
static const uint16_t hidLenBkiCh = sizeof(hidBkiCh);
/* HID Boot Keyboard In Value */
static uint8_t hidBkiVal[HID_MAX_REPORT_LEN];
static uint16_t hidLenBkiVal = sizeof(hidBkiVal);
/* HID Boot Keyboard In client characteristic configuration */
static uint8_t hidValBkiChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t hidLenBkiChCcc = sizeof(hidValBkiChCcc);
/* HID Boot Keyboard Out Characteristic */
static const uint8_t hidBkoCh[] = {ATT_PROP_READ | ATT_PROP_WRITE | ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(HID_KEYBOARD_BOOT_OUT_HDL), UINT16_TO_BYTES(ATT_UUID_HID_BOOT_KEYBOARD_OUT)};
static const uint16_t hidLenBkoCh = sizeof(hidBkoCh);
/* HID Boot Keyboard Out Value */
static uint8_t hidBkoVal[HID_MAX_REPORT_LEN];
static uint16_t hidLenBkoVal = sizeof(hidBkoVal);
/* HID Boot Mouse In Characteristic */
static const uint8_t hidBmiCh[] = {ATT_PROP_READ | ATT_PROP_NOTIFY, UINT16_TO_BYTES(HID_MOUSE_BOOT_IN_HDL), UINT16_TO_BYTES(ATT_UUID_HID_BOOT_MOUSE_IN)};
static const uint16_t hidLenBmiCh = sizeof(hidBmiCh);
/* HID Boot Mouse In Value */
static uint8_t hidBmiVal[HID_MAX_REPORT_LEN];
static uint16_t hidLenBmiVal = sizeof(hidBmiVal);
/* HID Boot Mouse In client characteristic configuration */
static uint8_t hidValBmiChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t hidLenBmiChCcc = sizeof(hidValBmiChCcc);
/* HID Input Report #1 Characteristic */
static const uint8_t hidIRep1Ch[] = {ATT_PROP_READ | ATT_PROP_NOTIFY, UINT16_TO_BYTES(HID_INPUT_REPORT_1_HDL), UINT16_TO_BYTES(ATT_UUID_HID_REPORT)};
static const uint16_t hidLenIRep1Ch = sizeof(hidIRep1Ch);
/* HID Input Report Value */
static uint8_t hidIRep1Val[HID_MAX_REPORT_LEN];
static uint16_t hidLenIRep1Val = sizeof(hidIRep1Val);
/* HID Input Report client characteristic configuration */
static uint8_t hidValIRep1ChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t hidLenIRep1ChCcc = sizeof(hidValIRep1ChCcc);
/* HID Input Report Reference - ID, Type */
static const uint8_t hidValIRep1IdMap[] = {0x01, HID_REPORT_TYPE_INPUT};
static const uint16_t hidLenIRep1IdMap = sizeof(hidValIRep1IdMap);
/* HID Input Report #2 Characteristic */
static const uint8_t hidIRep2Ch[] = {ATT_PROP_READ | ATT_PROP_NOTIFY, UINT16_TO_BYTES(HID_INPUT_REPORT_2_HDL), UINT16_TO_BYTES(ATT_UUID_HID_REPORT)};
static const uint16_t hidLenIRep2Ch = sizeof(hidIRep2Ch);
/* HID Input Report Value */
static uint8_t hidIRep2Val[HID_MAX_REPORT_LEN];
static uint16_t hidLenIRep2Val = sizeof(hidIRep2Val);
/* HID Input Report client characteristic configuration */
static uint8_t hidValIRep2ChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t hidLenIRep2ChCcc = sizeof(hidValIRep2ChCcc);
/* HID Input Report Reference - ID, Type */
static const uint8_t hidValIRep2IdMap[] = {0x02, HID_REPORT_TYPE_INPUT};
static const uint16_t hidLenIRep2IdMap = sizeof(hidValIRep2IdMap);
/* HID Input Report #3 Characteristic */
static const uint8_t hidIRep3Ch[] = {ATT_PROP_READ | ATT_PROP_NOTIFY, UINT16_TO_BYTES(HID_INPUT_REPORT_3_HDL), UINT16_TO_BYTES(ATT_UUID_HID_REPORT)};
static const uint16_t hidLenIRep3Ch = sizeof(hidIRep3Ch);
/* HID Input Report Value */
static uint8_t hidIRep3Val[HID_MAX_REPORT_LEN];
static uint16_t hidLenIRep3Val = sizeof(hidIRep3Val);
/* HID Input Report client characteristic configuration */
static uint8_t hidValIRep3ChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t hidLenIRep3ChCcc = sizeof(hidValIRep3ChCcc);
/* HID Input Report Reference - ID, Type */
static const uint8_t hidValIRep3IdMap[] = {0x03, HID_REPORT_TYPE_INPUT};
static const uint16_t hidLenIRep3IdMap = sizeof(hidValIRep3IdMap);
/* HID Output Report Characteristic */
static const uint8_t hidORepCh[] = {ATT_PROP_READ | ATT_PROP_WRITE | ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(HID_OUTPUT_REPORT_HDL), UINT16_TO_BYTES(ATT_UUID_HID_REPORT)};
static const uint16_t hidLenORepCh = sizeof(hidORepCh);
/* HID Output Report Value */
static uint8_t hidORepVal[HID_MAX_REPORT_LEN];
static uint16_t hidLenORepVal = sizeof(hidORepVal);
/* HID Output Report Reference - ID, Type */
static const uint8_t hidValORepIdMap[] = {0x00, HID_REPORT_TYPE_OUTPUT};
static const uint16_t hidLenORepIdMap = sizeof(hidValORepIdMap);
/* HID Feature Report Characteristic */
static const uint8_t hidFRepCh[] = {ATT_PROP_READ | ATT_PROP_WRITE, UINT16_TO_BYTES(HID_FEATURE_REPORT_HDL), UINT16_TO_BYTES(ATT_UUID_HID_REPORT)};
static const uint16_t hidLenFRepCh = sizeof(hidFRepCh);
/* HID Feature Report Value */
static uint8_t hidFRepVal[HID_MAX_REPORT_LEN];
static uint16_t hidLenFRepVal = sizeof(hidFRepVal);
/* HID Feature Report Reference - ID, Type */
static const uint8_t hidValFRepIdMap[] = {0x00, HID_REPORT_TYPE_FEATURE};
static const uint16_t hidLenFRepIdMap = sizeof(hidValFRepIdMap);
/* HID Protocol Mode Characteristic */
static const uint8_t hidPmCh[] = {ATT_PROP_READ | ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(HID_PROTOCOL_MODE_HDL), UINT16_TO_BYTES(ATT_UUID_HID_PROTOCOL_MODE)};
static const uint16_t hidLenPmCh = sizeof(hidPmCh);
/* HID Protocol Mode Value */
static uint8_t hidPmVal[] = {HID_PROTOCOL_MODE_REPORT};
static const uint16_t hidLenPmVal = sizeof(hidPmVal);
/* Attribute list for HID group */
static const attsAttr_t hidList[] =
{
/* Service Delcaration */
{
attPrimSvcUuid,
(uint8_t *) hidValSvc,
(uint16_t *) &hidLenSvc,
sizeof(hidValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) hidInfoCh,
(uint16_t *) &hidLenInfoCh,
sizeof(hidInfoCh),
0,
ATTS_PERMIT_READ
},
{
attHidiChUuid,
(uint8_t *) hidInfoVal,
(uint16_t *) &hidLenInfoVal,
sizeof(hidInfoVal),
0,
HID_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) hidRmCh,
(uint16_t *) &hidLenRmCh,
sizeof(hidRmCh),
0,
ATTS_PERMIT_READ
},
{
attHidRmChUuid,
(uint8_t *) hidReportMap,
(uint16_t *) &hidReportMapLen,
HID_MAX_REPORT_MAP_LEN,
ATTS_SET_VARIABLE_LEN,
HID_SEC_PERMIT_READ
},
{
attHidErmUuid,
(uint8_t *) hidExtReport,
(uint16_t *) &hidLenExtReport,
sizeof(hidExtReport),
0,
HID_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) hidCpCh,
(uint16_t *) &hidLenCpCh,
sizeof(hidCpCh),
0,
ATTS_PERMIT_READ
},
{
attHidRepChUuid,
(uint8_t *) hidCpVal,
(uint16_t *) &hidLenCpVal,
sizeof(hidCpVal),
ATTS_SET_WRITE_CBACK,
HID_SEC_PERMIT_WRITE
},
{
attChUuid,
(uint8_t *) hidBkiCh,
(uint16_t *) &hidLenBkiCh,
sizeof(hidBkiCh),
0,
ATTS_PERMIT_READ
},
{
attHidBkiChUuid,
(uint8_t *) hidBkiVal,
(uint16_t *) &hidLenBkiVal,
sizeof(hidBkiVal),
ATTS_SET_VARIABLE_LEN,
HID_SEC_PERMIT_READ
},
{
attCliChCfgUuid,
(uint8_t *) hidValBkiChCcc,
(uint16_t *) &hidLenBkiChCcc,
sizeof(hidValBkiChCcc),
ATTS_SET_CCC,
(HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) hidBkoCh,
(uint16_t *) &hidLenBkoCh,
sizeof(hidBkoCh),
0,
ATTS_PERMIT_READ
},
{
attHidBkoChUuid,
(uint8_t *) hidBkoVal,
(uint16_t *) &hidLenBkoVal,
sizeof(hidBkoVal),
(ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN),
(HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) hidBmiCh,
(uint16_t *) &hidLenBmiCh,
sizeof(hidBmiCh),
0,
ATTS_PERMIT_READ
},
{
attHidBmiChUuid,
(uint8_t *) hidBmiVal,
(uint16_t *) &hidLenBmiVal,
sizeof(hidBmiVal),
ATTS_SET_VARIABLE_LEN,
HID_SEC_PERMIT_READ
},
{
attCliChCfgUuid,
(uint8_t *) hidValBmiChCcc,
(uint16_t *) &hidLenBmiChCcc,
sizeof(hidValBmiChCcc),
ATTS_SET_CCC,
(HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) hidIRep1Ch,
(uint16_t *) &hidLenIRep1Ch,
sizeof(hidIRep1Ch),
0,
ATTS_PERMIT_READ
},
{
attHidRepChUuid,
(uint8_t *) hidIRep1Val,
(uint16_t *) &hidLenIRep1Val,
sizeof(hidIRep1Val),
ATTS_SET_VARIABLE_LEN,
HID_SEC_PERMIT_READ
},
{
attCliChCfgUuid,
(uint8_t *) hidValIRep1ChCcc,
(uint16_t *) &hidLenIRep1ChCcc,
sizeof(hidValIRep1ChCcc),
ATTS_SET_CCC,
(HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE)
},
{
attHidRimUuid,
(uint8_t *) hidValIRep1IdMap,
(uint16_t *) &hidLenIRep1IdMap,
sizeof(hidValIRep1IdMap),
0,
HID_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) hidIRep2Ch,
(uint16_t *) &hidLenIRep2Ch,
sizeof(hidIRep2Ch),
0,
ATTS_PERMIT_READ
},
{
attHidRepChUuid,
(uint8_t *) hidIRep2Val,
(uint16_t *) &hidLenIRep2Val,
sizeof(hidIRep2Val),
ATTS_SET_VARIABLE_LEN,
HID_SEC_PERMIT_READ
},
{
attCliChCfgUuid,
(uint8_t *) hidValIRep2ChCcc,
(uint16_t *) &hidLenIRep2ChCcc,
sizeof(hidValIRep2ChCcc),
ATTS_SET_CCC,
(HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE)
},
{
attHidRimUuid,
(uint8_t *) hidValIRep2IdMap,
(uint16_t *) &hidLenIRep2IdMap,
sizeof(hidValIRep2IdMap),
0,
HID_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) hidIRep3Ch,
(uint16_t *) &hidLenIRep3Ch,
sizeof(hidIRep3Ch),
0,
ATTS_PERMIT_READ
},
{
attHidRepChUuid,
(uint8_t *) hidIRep3Val,
(uint16_t *) &hidLenIRep3Val,
sizeof(hidIRep3Val),
ATTS_SET_VARIABLE_LEN,
HID_SEC_PERMIT_READ
},
{
attCliChCfgUuid,
(uint8_t *) hidValIRep3ChCcc,
(uint16_t *) &hidLenIRep3ChCcc,
sizeof(hidValIRep3ChCcc),
ATTS_SET_CCC,
(HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE)
},
{
attHidRimUuid,
(uint8_t *) hidValIRep3IdMap,
(uint16_t *) &hidLenIRep3IdMap,
sizeof(hidValIRep3IdMap),
0,
HID_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) hidORepCh,
(uint16_t *) &hidLenORepCh,
sizeof(hidORepCh),
0,
ATTS_PERMIT_READ
},
{
attHidRepChUuid,
(uint8_t *) hidORepVal,
(uint16_t *) &hidLenORepVal,
sizeof(hidORepVal),
(ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN),
(HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE)
},
{
attHidRimUuid,
(uint8_t *) hidValORepIdMap,
(uint16_t *) &hidLenORepIdMap,
sizeof(hidValORepIdMap),
0,
HID_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) hidFRepCh,
(uint16_t *) &hidLenFRepCh,
sizeof(hidFRepCh),
0,
ATTS_PERMIT_READ
},
{
attHidRepChUuid,
(uint8_t *) hidFRepVal,
(uint16_t *) &hidLenFRepVal,
sizeof(hidFRepVal),
(ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN),
(HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE)
},
{
attHidRimUuid,
(uint8_t *) hidValFRepIdMap,
(uint16_t *) &hidLenFRepIdMap,
sizeof(hidValFRepIdMap),
0,
HID_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) hidPmCh,
(uint16_t *) &hidLenPmCh,
sizeof(hidPmCh),
0,
ATTS_PERMIT_READ
},
{
attHidRepChUuid,
(uint8_t *) hidPmVal,
(uint16_t *) &hidLenPmVal,
sizeof(hidPmVal),
ATTS_SET_WRITE_CBACK,
(HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE)
}
};
/* HID group structure */
static attsGroup_t svcHidkbGroup =
{
NULL,
(attsAttr_t *) hidList,
NULL,
NULL,
HID_START_HDL,
HID_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHidAddGroup(void)
{
AttsAddGroup(&svcHidkbGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHidRemoveGroup(void)
{
AttsRemoveGroup(HID_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register a read and write callback functions for the ATT Group.
*
* \param writeCb Write callback function
* \param readCb Read callback function
*
* \return None.
*/
/*************************************************************************************************/
void SvcHidRegister(attsWriteCback_t writeCb, attsReadCback_t readCb)
{
svcHidkbGroup.writeCback = writeCb;
svcHidkbGroup.readCback = readCb;
}
/*************************************************************************************************/
/*!
* \brief Add the Hid Service using the dynamic attribute subsystem.
*
* \return None.
*/
/*************************************************************************************************/
void *SvcHidAddGroupDyn()
{
void *pSHdl;
uint8_t initCcc[] = {UINT16_TO_BYTES(0x0000)};
/* Create the service */
pSHdl = AttsDynCreateGroup(HID_START_HDL, HID_END_HDL);
if (pSHdl != NULL)
{
/* Primary service */
AttsDynAddAttrConst(pSHdl, attPrimSvcUuid, hidValSvc, sizeof(hidValSvc), 0, ATTS_PERMIT_READ);
/* HID Info */
AttsDynAddAttrConst(pSHdl, attChUuid, hidInfoCh, sizeof(hidInfoCh), 0, ATTS_PERMIT_READ);
AttsDynAddAttrConst(pSHdl, attHidiChUuid, hidInfoVal, sizeof(hidInfoVal), 0, HID_SEC_PERMIT_READ);
/* HID Report Map */
AttsDynAddAttrConst(pSHdl, attChUuid, hidRmCh, sizeof(hidRmCh), 0, ATTS_PERMIT_READ);
AttsDynAddAttrConst(pSHdl, attHidRmChUuid, hidReportMap, hidReportMapLen, 0, HID_SEC_PERMIT_READ);
/* HID External Report Reference */
AttsDynAddAttrConst(pSHdl, attHidErmUuid, hidExtReport, sizeof(hidExtReport), 0, HID_SEC_PERMIT_READ);
/* HID Control Point */
AttsDynAddAttrConst(pSHdl, attChUuid, hidCpCh, sizeof(hidCpCh), 0, ATTS_PERMIT_READ);
AttsDynAddAttr(pSHdl, attHidRepChUuid, NULL, 1, 1, ATTS_SET_WRITE_CBACK, HID_SEC_PERMIT_WRITE);
/* HID Boot Keyboard In */
AttsDynAddAttrConst(pSHdl, attChUuid, hidBkiCh, sizeof(hidBkiCh), 0, ATTS_PERMIT_READ);
AttsDynAddAttr(pSHdl, attHidBkiChUuid, NULL, HID_MAX_REPORT_LEN, HID_MAX_REPORT_LEN,
ATTS_SET_VARIABLE_LEN, HID_SEC_PERMIT_READ);
AttsDynAddAttr(pSHdl, attCliChCfgUuid, initCcc, sizeof(uint16_t), sizeof(uint16_t),
ATTS_SET_CCC, HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE);
/* HID Boot Keyboard Out */
AttsDynAddAttrConst(pSHdl, attChUuid, hidBkoCh, sizeof(hidBkoCh), 0, ATTS_PERMIT_READ);
AttsDynAddAttr(pSHdl, attHidBkoChUuid, NULL, HID_MAX_REPORT_LEN, HID_MAX_REPORT_LEN,
ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN, HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE);
/* HID Boot Mouse In */
AttsDynAddAttrConst(pSHdl, attChUuid, hidBmiCh, sizeof(hidBmiCh), 0, ATTS_PERMIT_READ);
AttsDynAddAttr(pSHdl, attHidBmiChUuid, NULL, HID_MAX_REPORT_LEN, HID_MAX_REPORT_LEN,
ATTS_SET_VARIABLE_LEN, HID_SEC_PERMIT_READ);
AttsDynAddAttr(pSHdl, attCliChCfgUuid, initCcc, sizeof(uint16_t), sizeof(uint16_t),
ATTS_SET_CCC, HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE);
/* HID Input Report #1 (HIDAPP_REMOTE_REPORT_ID) */
AttsDynAddAttrConst(pSHdl, attChUuid, hidIRep1Ch, sizeof(hidIRep1Ch), 0, ATTS_PERMIT_READ);
AttsDynAddAttr(pSHdl, attHidRepChUuid, NULL, HID_MAX_REPORT_LEN, HID_MAX_REPORT_LEN,
ATTS_SET_VARIABLE_LEN, HID_SEC_PERMIT_READ);
AttsDynAddAttr(pSHdl, attCliChCfgUuid, initCcc, sizeof(uint16_t), sizeof(uint16_t),
ATTS_SET_CCC, HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE);
AttsDynAddAttrConst(pSHdl, attHidRimUuid, hidValIRep1IdMap, sizeof(hidValIRep1IdMap),
0, HID_SEC_PERMIT_READ);
/* HID Input Report #2 (HIDAPP_KEYBOARD_REPORT_ID) */
AttsDynAddAttrConst(pSHdl, attChUuid, hidIRep2Ch, sizeof(hidIRep2Ch), 0, ATTS_PERMIT_READ);
AttsDynAddAttr(pSHdl, attHidRepChUuid, NULL, HID_MAX_REPORT_LEN, HID_MAX_REPORT_LEN,
ATTS_SET_VARIABLE_LEN, HID_SEC_PERMIT_READ);
AttsDynAddAttr(pSHdl, attCliChCfgUuid, initCcc, sizeof(uint16_t), sizeof(uint16_t),
ATTS_SET_CCC, HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE);
AttsDynAddAttrConst(pSHdl, attHidRimUuid, hidValIRep2IdMap, sizeof(hidValIRep2IdMap),
0, HID_SEC_PERMIT_READ);
/* HID Input Report #3 (HIDAPP_MOUSE_REPORT_ID) */
AttsDynAddAttrConst(pSHdl, attChUuid, hidIRep3Ch, sizeof(hidIRep3Ch), 0, ATTS_PERMIT_READ);
AttsDynAddAttr(pSHdl, attHidRepChUuid, NULL, HID_MAX_REPORT_LEN, HID_MAX_REPORT_LEN,
ATTS_SET_VARIABLE_LEN, HID_SEC_PERMIT_READ);
AttsDynAddAttr(pSHdl, attCliChCfgUuid, initCcc, sizeof(uint16_t), sizeof(uint16_t),
ATTS_SET_CCC, HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE);
AttsDynAddAttrConst(pSHdl, attHidRimUuid, hidValIRep3IdMap, sizeof(hidValIRep3IdMap),
0, HID_SEC_PERMIT_READ);
/* HID Output Report */
AttsDynAddAttrConst(pSHdl, attChUuid, hidORepCh, sizeof(hidORepCh), 0, ATTS_PERMIT_READ);
AttsDynAddAttr(pSHdl, attHidRepChUuid, NULL, HID_MAX_REPORT_LEN, HID_MAX_REPORT_LEN,
ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN, HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE);
AttsDynAddAttrConst(pSHdl, attHidRimUuid, hidValORepIdMap, sizeof(hidValORepIdMap),
0, HID_SEC_PERMIT_READ);
/* HID Feature Report */
AttsDynAddAttrConst(pSHdl, attChUuid, hidFRepCh, sizeof(hidFRepCh), 0, ATTS_PERMIT_READ);
AttsDynAddAttr(pSHdl, attHidRepChUuid, NULL, HID_MAX_REPORT_LEN, HID_MAX_REPORT_LEN,
ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN, HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE);
AttsDynAddAttrConst(pSHdl, attHidRimUuid, hidValFRepIdMap, sizeof(hidValFRepIdMap),
0, HID_SEC_PERMIT_READ);
/* HID Protocol Mode */
AttsDynAddAttrConst(pSHdl, attChUuid, hidPmCh, sizeof(hidPmCh), 0, ATTS_PERMIT_READ);
AttsDynAddAttr(pSHdl, attHidRepChUuid, hidPmVal, sizeof(hidPmVal), sizeof(hidPmVal),
ATTS_SET_WRITE_CBACK, HID_SEC_PERMIT_READ | HID_SEC_PERMIT_WRITE);
}
return pSHdl;
}
@@ -0,0 +1,187 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Human Interface Device service implementation.
*
* Copyright (c) 2015-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_HID_H
#define SVC_HID_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup HUMAN_INTERFACE_DEVICE_SERVICE
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief HID Service */
#define HID_SVC_UUID ATT_UUID_HID_SERVICE
/** \name HID Spec Version
*
*/
/**@{*/
/*! \brief HID Spec Version: 1.11 */
#define HID_VERSION 0x0111
/**@}*/
/** \name HID Report Types
*
*/
/**@{*/
#define HID_REPORT_TYPE_INPUT 0x01 /*!< \brief Input type. */
#define HID_REPORT_TYPE_OUTPUT 0x02 /*!< \brief Output type. */
#define HID_REPORT_TYPE_FEATURE 0x03 /*!< \brief Feature type. */
/**@}*/
/** \name HID Protocol Mode Types
*
*/
/**@{*/
#define HID_PROTOCOL_MODE_BOOT 0x00 /*!< \brief Boot mode. */
#define HID_PROTOCOL_MODE_REPORT 0x01 /*!< \brief Report mode. */
/**@}*/
/** \name HID Control Point Values
*
*/
/**@{*/
#define HID_CONTROL_POINT_SUSPEND 0x00 /*!< \brief Suspend. */
#define HID_CONTROL_POINT_RESUME 0x01 /*!< \brief Resume. */
/**@}*/
/*! \brief Max length of the report map value */
#define HID_MAX_REPORT_MAP_LEN 512
/*! \brief Max length of an output report value */
#define HID_MAX_REPORT_LEN 32
/*! \brief Initial length of the report map value */
#define HID_INIT_REPORT_MAP_LEN 1
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name HID Service Handles
*
*/
/**@{*/
#define HID_START_HDL 0x50 /*!< \brief Start handle. */
#define HID_END_HDL (HID_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Proprietary Service Handles Common to HID Devices */
enum
{
HID_SVC_HDL = HID_START_HDL, /*!< \brief Proprietary Service Declaration */
HID_INFO_CH_HDL, /*!< \brief HID Information Characteristic Declaration */
HID_INFO_HDL, /*!< \brief HID Information Value */
HID_REPORT_MAP_CH_HDL, /*!< \brief HID Report Map Characteristic Declaration */
HID_REPORT_MAP_HDL, /*!< \brief HID Report Map Value */
HID_EXTERNAL_REPORT_HDL, /*!< \brief HID External Report Descriptor */
HID_CONTROL_POINT_CH_HDL, /*!< \brief HID Control Point Characteristic Declaration */
HID_CONTROL_POINT_HDL, /*!< \brief HID Control Point Value */
HID_KEYBOARD_BOOT_IN_CH_HDL, /*!< \brief HID Keyboard Boot Input Characteristic Declaration */
HID_KEYBOARD_BOOT_IN_HDL, /*!< \brief HID Keyboard Boot Input Value */
HID_KEYBOARD_BOOT_IN_CH_CCC_HDL, /*!< \brief HID Keyboard Boot Input CCC Descriptor */
HID_KEYBOARD_BOOT_OUT_CH_HDL, /*!< \brief HID Keyboard Boot Output Characteristic Declaration */
HID_KEYBOARD_BOOT_OUT_HDL, /*!< \brief HID Keyboard Boot Output Value */
HID_MOUSE_BOOT_IN_CH_HDL, /*!< \brief HID Mouse Boot Input Characteristic Declaration */
HID_MOUSE_BOOT_IN_HDL, /*!< \brief HID Mouse Boot Input Value */
HID_MOUSE_BOOT_IN_CH_CCC_HDL, /*!< \brief HID Mouse Boot Input CCC Descriptor */
HID_INPUT_REPORT_1_CH_HDL, /*!< \brief HID Input Report Characteristic Declaration */
HID_INPUT_REPORT_1_HDL, /*!< \brief HID Input Report Value */
HID_INPUT_REPORT_1_CH_CCC_HDL, /*!< \brief HID Input Report CCC Descriptor */
HID_INPUT_REPORT_1_REFERENCE_HDL, /*!< \brief HID Input Report Reference Descriptor */
HID_INPUT_REPORT_2_CH_HDL, /*!< \brief HID Input Report Characteristic Declaration */
HID_INPUT_REPORT_2_HDL, /*!< \brief HID Input Report Value */
HID_INPUT_REPORT_2_CH_CCC_HDL, /*!< \brief HID Input Report CCC Descriptor */
HID_INPUT_REPORT_2_REFERENCE_HDL, /*!< \brief HID Input Report Reference Descriptor */
HID_INPUT_REPORT_3_CH_HDL, /*!< \brief HID Input Report Characteristic Declaration */
HID_INPUT_REPORT_3_HDL, /*!< \brief HID Input Report Value */
HID_INPUT_REPORT_3_CH_CCC_HDL, /*!< \brief HID Input Report CCC Descriptor */
HID_INPUT_REPORT_3_REFERENCE_HDL, /*!< \brief HID Input Report Reference Descriptor */
HID_OUTPUT_REPORT_CH_HDL, /*!< \brief HID Output Report Characteristic Declaration */
HID_OUTPUT_REPORT_HDL, /*!< \brief HID Output Report Value */
HID_OUTPUT_REPORT_REFERENCE_HDL, /*!< \brief HID Output Report Reference Descriptor */
HID_FEATURE_REPORT_CH_HDL, /*!< \brief HID Feature Report Characteristic Declaration */
HID_FEATURE_REPORT_HDL, /*!< \brief HID Feature Report Value */
HID_FEATURE_REPORT_REFERENCE_HDL, /*!< \brief HID Feature Report Reference Descriptor */
HID_PROTOCOL_MODE_CH_HDL, /*!< \brief HID Protocol Mode Characteristic Declaration */
HID_PROTOCOL_MODE_HDL, /*!< \brief HID Protocol Mode Value */
HID_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHidAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHidRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register a read and write callback functions for the ATT Group.
*
* \param writeCb Write callback function
* \param readCb Read callback function
*
* \return None.
*/
/*************************************************************************************************/
void SvcHidRegister(attsWriteCback_t writeCb, attsReadCback_t readCb);
/*************************************************************************************************/
/*!
* \brief Add the Hid Service using the dynamic attribute subsystem.
*
* \return None.
*/
/*************************************************************************************************/
void *SvcHidAddGroupDyn(void);
/*! \} */ /* HUMAN_INTERFACE_DEVICE_SERVICE */
#ifdef __cplusplus
}
#endif
#endif /* SVC_HID_H */
@@ -0,0 +1,212 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Heart Rate service implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_hrs.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef HRS_SEC_PERMIT_READ
#define HRS_SEC_PERMIT_READ SVC_SEC_PERMIT_READ
#endif
/*! Characteristic write permissions */
#ifndef HRS_SEC_PERMIT_WRITE
#define HRS_SEC_PERMIT_WRITE SVC_SEC_PERMIT_WRITE
#endif
/**************************************************************************************************
Static Variables
**************************************************************************************************/
/* UUIDs */
static const uint8_t svcHrmUuid[] = {UINT16_TO_BYTES(ATT_UUID_HR_MEAS)};
static const uint8_t svcSlUuid[] = {UINT16_TO_BYTES(ATT_UUID_HR_SENSOR_LOC)};
static const uint8_t svcCpUuid[] = {UINT16_TO_BYTES(ATT_UUID_HR_CP)};
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Heart rate service declaration */
static const uint8_t hrsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_HEART_RATE_SERVICE)};
static const uint16_t hrsLenSvc = sizeof(hrsValSvc);
/* Heart rate measurement characteristic */
static const uint8_t hrsValHrmCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(HRS_HRM_HDL), UINT16_TO_BYTES(ATT_UUID_HR_MEAS)};
static const uint16_t hrsLenHrmCh = sizeof(hrsValHrmCh);
/* Heart rate measurement */
/* Note these are dummy values */
static const uint8_t hrsValHrm[] = {0};
static const uint16_t hrsLenHrm = sizeof(hrsValHrm);
/* Heart rate measurement client characteristic configuration */
static uint8_t hrsValHrmChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t hrsLenHrmChCcc = sizeof(hrsValHrmChCcc);
/* Body sensor location characteristic */
static const uint8_t hrsValSlCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(HRS_SL_HDL), UINT16_TO_BYTES(ATT_UUID_HR_SENSOR_LOC)};
static const uint16_t hrsLenSlCh = sizeof(hrsValSlCh);
/* Body sensor location */
static uint8_t hrsValSl[] = {CH_BSENSOR_LOC_WRIST};
static const uint16_t hrsLenSl = sizeof(hrsValSl);
/* Control point characteristic */
static const uint8_t hrsValCpCh[] = {ATT_PROP_WRITE, UINT16_TO_BYTES(HRS_CP_HDL), UINT16_TO_BYTES(ATT_UUID_HR_CP)};
static const uint16_t hrsLenCpCh = sizeof(hrsValCpCh);
/* Control point */
/* Note these are dummy values */
static const uint8_t hrsValCp[] = {0};
static const uint16_t hrsLenCp = sizeof(hrsValCp);
/* Attribute list for HRS group */
static const attsAttr_t hrsList[] =
{
{
attPrimSvcUuid,
(uint8_t *) hrsValSvc,
(uint16_t *) &hrsLenSvc,
sizeof(hrsValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) hrsValHrmCh,
(uint16_t *) &hrsLenHrmCh,
sizeof(hrsValHrmCh),
0,
ATTS_PERMIT_READ
},
{
svcHrmUuid,
(uint8_t *) hrsValHrm,
(uint16_t *) &hrsLenHrm,
sizeof(hrsValHrm),
0,
0
},
{
attCliChCfgUuid,
(uint8_t *) hrsValHrmChCcc,
(uint16_t *) &hrsLenHrmChCcc,
sizeof(hrsValHrmChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | HRS_SEC_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) hrsValSlCh,
(uint16_t *) &hrsLenSlCh,
sizeof(hrsValSlCh),
0,
ATTS_PERMIT_READ
},
{
svcSlUuid,
hrsValSl,
(uint16_t *) &hrsLenSl,
sizeof(hrsValSl),
0,
HRS_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) hrsValCpCh,
(uint16_t *) &hrsLenCpCh,
sizeof(hrsValCpCh),
0,
ATTS_PERMIT_READ
},
{
svcCpUuid,
(uint8_t *) hrsValCp,
(uint16_t *) &hrsLenCp,
sizeof(hrsValCp),
ATTS_SET_WRITE_CBACK,
HRS_SEC_PERMIT_WRITE
}
};
/* HRS group structure */
static attsGroup_t svcHrsGroup =
{
NULL,
(attsAttr_t *) hrsList,
NULL,
NULL,
HRS_START_HDL,
HRS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHrsAddGroup(void)
{
AttsAddGroup(&svcHrsGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHrsRemoveGroup(void)
{
AttsRemoveGroup(HRS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHrsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcHrsGroup.readCback = readCback;
svcHrsGroup.writeCback = writeCback;
}
@@ -0,0 +1,116 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Heart Rate service implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_HRS_H
#define SVC_HRS_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup HEART_RATE_SERVICE
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/** \name Heart Rate Error Codes
*
*/
/**@{*/
#define HRS_ERR_CP_NOT_SUP 0x80 /*!< \brief Control Point value not supported */
/**@}*/
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Heart Rate Service Handles
*
*/
/**@{*/
#define HRS_START_HDL 0x20 /*!< \brief Start handle. */
#define HRS_END_HDL (HRS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Heart Rate Service Handles */
enum
{
HRS_SVC_HDL = HRS_START_HDL, /*!< \brief Heart rate service declaration */
HRS_HRM_CH_HDL, /*!< \brief Heart rate measurement characteristic */
HRS_HRM_HDL, /*!< \brief Heart rate measurement */
HRS_HRM_CH_CCC_HDL, /*!< \brief Heart rate measurement client characteristic configuration */
HRS_SL_CH_HDL, /*!< \brief Body sensor location characteristic */
HRS_SL_HDL, /*!< \brief Body sensor location */
HRS_CP_CH_HDL, /*!< \brief Heart rate control point characteristic */
HRS_CP_HDL, /*!< \brief Heart rate control point */
HRS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHrsAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHrsRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHrsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*! \} */ /* HEART_RATE_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_HRS_H */
@@ -0,0 +1,224 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Health Thermometer service implementation.
*
* Copyright (c) 2012-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_hts.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef HTS_SEC_PERMIT_READ
#define HTS_SEC_PERMIT_READ (ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC)
#endif
/*! Characteristic write permissions */
#ifndef HTS_SEC_PERMIT_WRITE
#define HTS_SEC_PERMIT_WRITE (ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC)
#endif
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Health thermometer service declaration */
static const uint8_t htsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_HEALTH_THERM_SERVICE)};
static const uint16_t htsLenSvc = sizeof(htsValSvc);
/* Temperature measurement characteristic */
static const uint8_t htsValTmCh[] = {ATT_PROP_INDICATE, UINT16_TO_BYTES(HTS_TM_HDL), UINT16_TO_BYTES(ATT_UUID_TEMP_MEAS)};
static const uint16_t htsLenTmCh = sizeof(htsValTmCh);
/* Temperature measurement */
/* Note these are dummy values */
static const uint8_t htsValTm[] = {0};
static const uint16_t htsLenTm = sizeof(htsValTm);
/* Temperature measurement client characteristic configuration */
static uint8_t htsValTmChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t htsLenTmChCcc = sizeof(htsValTmChCcc);
/* Intermediate temperature characteristic */
static const uint8_t htsValItCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(HTS_IT_HDL), UINT16_TO_BYTES(ATT_UUID_INTERMEDIATE_TEMP)};
static const uint16_t htsLenItCh = sizeof(htsValItCh);
/* Intermediate temperature */
/* Note these are dummy values */
static const uint8_t htsValIt[] = {0};
static const uint16_t htsLenIt = sizeof(htsValIt);
/* Intermediate temperature client characteristic configuration */
static uint8_t htsValItChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t htsLenItChCcc = sizeof(htsValItChCcc);
/* Temperature type characteristic */
static const uint8_t htsValTtCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(HTS_TT_HDL), UINT16_TO_BYTES(ATT_UUID_TEMP_TYPE)};
static const uint16_t htsLenTtCh = sizeof(htsValTtCh);
/* Temperature type */
static uint8_t htsValTt[] = {CH_TT_BODY};
static const uint16_t htsLenTt = sizeof(htsValTt);
/* Attribute list for HTS group */
static const attsAttr_t htsList[] =
{
/* Health thermometer service declaration */
{
attPrimSvcUuid,
(uint8_t *) htsValSvc,
(uint16_t *) &htsLenSvc,
sizeof(htsValSvc),
0,
ATTS_PERMIT_READ
},
/* Temperature measurement characteristic */
{
attChUuid,
(uint8_t *) htsValTmCh,
(uint16_t *) &htsLenTmCh,
sizeof(htsValTmCh),
0,
ATTS_PERMIT_READ
},
/* Temperature measurement */
{
attTmChUuid,
(uint8_t *) htsValTm,
(uint16_t *) &htsLenTm,
sizeof(htsValTm),
0,
0
},
/* Temperature measurement client characteristic configuration */
{
attCliChCfgUuid,
(uint8_t *) htsValTmChCcc,
(uint16_t *) &htsLenTmChCcc,
sizeof(htsValTmChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | HTS_SEC_PERMIT_WRITE)
},
/* Intermediate temperature characteristic */
{
attChUuid,
(uint8_t *) htsValItCh,
(uint16_t *) &htsLenItCh,
sizeof(htsValItCh),
0,
ATTS_PERMIT_READ
},
/* Intermediate temperature */
{
attItChUuid,
(uint8_t *) htsValIt,
(uint16_t *) &htsLenIt,
sizeof(htsValIt),
0,
0
},
/* Intermediate temperature client characteristic configuration */
{
attCliChCfgUuid,
(uint8_t *) htsValItChCcc,
(uint16_t *) &htsLenItChCcc,
sizeof(htsValItChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | HTS_SEC_PERMIT_WRITE)
},
/* Temperature type characteristic */
{
attChUuid,
(uint8_t *) htsValTtCh,
(uint16_t *) &htsLenTtCh,
sizeof(htsValTtCh),
0,
ATTS_PERMIT_READ
},
/* Temperature type */
{
attTtChUuid,
(uint8_t *) htsValTt,
(uint16_t *) &htsLenTt,
sizeof(htsValTt),
0,
HTS_SEC_PERMIT_READ
}
};
/* HTS group structure */
static attsGroup_t svcHtsGroup =
{
NULL,
(attsAttr_t *) htsList,
NULL,
NULL,
HTS_START_HDL,
HTS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHtsAddGroup(void)
{
AttsAddGroup(&svcHtsGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHtsRemoveGroup(void)
{
AttsRemoveGroup(HTS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHtsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcHtsGroup.readCback = readCback;
svcHtsGroup.writeCback = writeCback;
}
@@ -0,0 +1,106 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Health Thermometer service implementation.
*
* Copyright (c) 2012-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_HTS_H
#define SVC_HTS_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup HEALTH_THERMOMETER_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Health Thermometer Service Handles
*
*/
/**@{*/
#define HTS_START_HDL 0x0120 /*!< \brief Start handle. */
#define HTS_END_HDL (HTS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Health Thermometer Service Handles */
enum
{
HTS_SVC_HDL = HTS_START_HDL, /*!< \brief Health thermometer service declaration */
HTS_TM_CH_HDL, /*!< \brief Temperature measurement characteristic */
HTS_TM_HDL, /*!< \brief Temperature measurement */
HTS_TM_CH_CCC_HDL, /*!< \brief Temperature measurement client characteristic configuration */
HTS_IT_CH_HDL, /*!< \brief Intermediate temperature characteristic */
HTS_IT_HDL, /*!< \brief Intermediate temperature */
HTS_IT_CH_CCC_HDL, /*!< \brief Intermediate temperature client characteristic configuration */
HTS_TT_CH_HDL, /*!< \brief Temperature type characteristic */
HTS_TT_HDL, /*!< \brief Temperature type */
HTS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHtsAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHtsRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcHtsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*! \} */ /* HEALTH_THERMOMETER_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_HTS_H */
@@ -0,0 +1,118 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Internet Profile Support Service implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "att_uuid.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_ipss.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef IPSS_SEC_PERMIT_READ
#define IPSS_SEC_PERMIT_READ (ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC)
#endif
/*! Characteristic write permissions */
#ifndef IPSS_SEC_PERMIT_WRITE
#define IPSS_SEC_PERMIT_WRITE (ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC)
#endif
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* IP Support service declaration */
static const uint8_t ipssValSvc[] = {UINT16_TO_BYTES(ATT_UUID_IP_SUPPORT_SERVICE)};
static const uint16_t ipssLenSvc = sizeof(ipssValSvc);
/* Attribute list for IPSS group */
static const attsAttr_t ipssList[] =
{
/* IP Support Service declaration */
{
attPrimSvcUuid,
(uint8_t *) ipssValSvc,
(uint16_t *) &ipssLenSvc,
sizeof(ipssValSvc),
0,
ATTS_PERMIT_READ
},
};
/* IPSS group structure */
static attsGroup_t svcIpssGroup =
{
NULL,
(attsAttr_t *) ipssList,
NULL,
NULL,
IPSS_START_HDL,
IPSS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcIpssAddGroup(void)
{
AttsAddGroup(&svcIpssGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcIpssRemoveGroup(void)
{
AttsRemoveGroup(IPSS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcIpssCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcIpssGroup.readCback = readCback;
svcIpssGroup.writeCback = writeCback;
}
@@ -0,0 +1,100 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Internet Profile Support Service implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_IPSS_H
#define SVC_IPSS_H
#include "att_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup INTERNET_PROFILE_SUPPORT_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name IP Support Service Handles
*
*/
/**@{*/
#define IPSS_START_HDL 0x0600 /*!< \brief Start handle. */
#define IPSS_END_HDL (IPSS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief IP Support Service Handles */
enum
{
IPSS_SVC_HDL = IPSS_START_HDL, /*!< \brief IP Support Server Service declaration */
IPSS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcIpssAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcIpssRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcIpssCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*! \} */ /* INTERNET_PROFILE_SUPPORT_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_IPSS_H */
@@ -0,0 +1,272 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Pulse Oximeter Service Server implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "att_uuid.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_plxs.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef PLXS_SEC_PERMIT_READ
#define PLXS_SEC_PERMIT_READ (ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC)
#endif
/*! Characteristic write permissions */
#ifndef PLXS_SEC_PERMIT_WRITE
#define PLXS_SEC_PERMIT_WRITE (ATTS_PERMIT_WRITE | ATTS_PERMIT_READ_ENC)
#endif
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Pulse Oximeter service declaration */
static const uint8_t plxsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_PULSE_OXIMITER_SERVICE)};
static const uint16_t plxsLenSvc = sizeof(plxsValSvc);
/* Pulse Oximeter Feature characteristic */
static const uint8_t plxsValFeatureCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(PLXS_FEATURES_HDL), UINT16_TO_BYTES(ATT_UUID_PULSE_OX_FEATURES)};
static const uint16_t plxsLenFeatureCh = sizeof(plxsValFeatureCh);
/* Pulse Oximeter Feature */
/* TODO: Set Supported Feature Bits */
static uint8_t plxsValFeature[CH_PLXF_MAX_FEATURES_LEN] = { 0 };
static uint16_t plxsLenFeature = CH_PLXF_MIN_FEATURES_LEN;
/* Pulse Oximeter Spot Check Measurement characteristic */
static const uint8_t plxsValSpotCheckCh[] = {ATT_PROP_INDICATE, UINT16_TO_BYTES(PLXS_SPOT_CHECK_HDL), UINT16_TO_BYTES(ATT_UUID_PULSE_OX_SPOT_CHECK)};
static const uint16_t plxsLenSpotCheckCh = sizeof(plxsValSpotCheckCh);
/* Pulse Oximeter Spot Check Measurement */
/* Note these are dummy values */
static const uint8_t plxsValSpotCheck[] = { 0 };
static const uint16_t plxsLenSpotCheck = 0;
/* Pulse Oximeter Spot Check Measurement client characteristic configuration */
static uint8_t plxsValSpotCheckChCcc[] = { UINT16_TO_BYTES(0x0000) };
static const uint16_t plxsLenSpotCheckChCcc = sizeof(plxsValSpotCheckChCcc);
/* Pulse Oximeter Continuous Measurement characteristic */
static const uint8_t plxsValContinuousCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(PLXS_CONTINUOUS_HDL), UINT16_TO_BYTES(ATT_UUID_PULSE_OX_CONTINUOUS)};
static const uint16_t plxsLenContinuousCh = sizeof(plxsValContinuousCh);
/* Pulse Oximeter Continuous Measurement */
/* Note these are dummy values */
static const uint8_t plxsValContinuous[] = { 0 };
static const uint16_t plxsLenContinuous = 0;
/* Pulse Oximeter Continuous Measurement client characteristic configuration */
static uint8_t plxsValContinuousChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t plxsLenContinuousChCcc = sizeof(plxsValContinuousChCcc);
/* Pulse Oximeter Record Access Control Point characteristic */
static const uint8_t plxsValRecordAccessCh[] = {ATT_PROP_INDICATE | ATT_PROP_WRITE, UINT16_TO_BYTES(PLXS_RECORD_ACCESS_HDL), UINT16_TO_BYTES(ATT_UUID_RACP)};
static const uint16_t plxsLenRecordAccessCh = sizeof(plxsValRecordAccessCh);
/* Pulse Oximeter Record Access Control Point */
/* Note these are dummy values */
static const uint8_t plxsValRecordAccess[] = { 0 };
static const uint16_t plxsLenRecordAccess = 0;
/* Pulse Oximeter Record Access Control Point client characteristic configuration */
static uint8_t plxsValRecordAccessChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t plxsLenRecordAccessChCcc = sizeof(plxsValRecordAccessChCcc);
/* Attribute list for PLXS group */
static const attsAttr_t plxsList[] =
{
/* Pulse Oximeter Service declaration */
{
attPrimSvcUuid,
(uint8_t *) plxsValSvc,
(uint16_t *) &plxsLenSvc,
sizeof(plxsValSvc),
0,
ATTS_PERMIT_READ
},
/* Pulse Oximeter Feature characteristic */
{
attChUuid,
(uint8_t *) plxsValFeatureCh,
(uint16_t *) &plxsLenFeatureCh,
sizeof(plxsValFeatureCh),
0,
ATTS_PERMIT_READ
},
/* Pulse Oximeter Feature value */
{
attPlxfChUuid,
(uint8_t *) plxsValFeature,
(uint16_t *) &plxsLenFeature,
sizeof(plxsValFeature),
ATTS_SET_VARIABLE_LEN,
PLXS_SEC_PERMIT_READ
},
/* Pulse Oximeter Spot Check characteristic */
{
attChUuid,
(uint8_t *) plxsValSpotCheckCh,
(uint16_t *) &plxsLenSpotCheckCh,
sizeof(plxsValSpotCheckCh),
0,
ATTS_PERMIT_READ
},
/* Pulse Oximeter Spot Check value */
{
attPlxscmChUuid,
(uint8_t *) plxsValSpotCheck,
(uint16_t *) &plxsLenSpotCheck,
sizeof(plxsValSpotCheck),
0,
0
},
/* Pulse Oximeter Spot Check Characteristic CCC descriptor */
{
attCliChCfgUuid,
plxsValSpotCheckChCcc,
(uint16_t *) &plxsLenSpotCheckChCcc,
sizeof(plxsValSpotCheckChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | PLXS_SEC_PERMIT_WRITE)
},
/* Pulse Oximeter Continuous Measurement characteristic */
{
attChUuid,
(uint8_t *)plxsValContinuousCh,
(uint16_t *)&plxsLenContinuousCh,
sizeof(plxsValContinuousCh),
0,
ATTS_PERMIT_READ
},
/* Pulse Oximeter Continuous Measurement value */
{
attPlxcmChUuid,
(uint8_t *) plxsValContinuous,
(uint16_t *) &plxsLenContinuous,
sizeof(plxsValContinuous),
0,
0
},
/* Pulse Oximeter Continuous Measurement Characteristic CCC descriptor */
{
attCliChCfgUuid,
plxsValContinuousChCcc,
(uint16_t *) &plxsLenContinuousChCcc,
sizeof(plxsValContinuousChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | PLXS_SEC_PERMIT_WRITE)
},
/* Pulse Oximeter Record Access Control Point characteristic */
{
attChUuid,
(uint8_t *)plxsValRecordAccessCh,
(uint16_t *)&plxsLenRecordAccessCh,
sizeof(plxsValRecordAccessCh),
0,
ATTS_PERMIT_READ
},
/* Pulse Oximeter Record Access Control Point value */
{
attRacpChUuid,
(uint8_t *)plxsValRecordAccess,
(uint16_t *)&plxsLenRecordAccess,
ATT_DEFAULT_PAYLOAD_LEN,
(ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
PLXS_SEC_PERMIT_WRITE
},
/* Pulse Oximeter Record Access Control Point Characteristic CCC descriptor */
{
attCliChCfgUuid,
plxsValRecordAccessChCcc,
(uint16_t *)&plxsLenRecordAccessChCcc,
sizeof(plxsValRecordAccessChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | PLXS_SEC_PERMIT_WRITE)
},
};
/* PLXS group structure */
static attsGroup_t svcPlxsGroup =
{
NULL,
(attsAttr_t *) plxsList,
NULL,
NULL,
PLXS_START_HDL,
PLXS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPlxsAddGroup(void)
{
AttsAddGroup(&svcPlxsGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPlxsRemoveGroup(void)
{
AttsRemoveGroup(PLXS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPlxsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcPlxsGroup.readCback = readCback;
svcPlxsGroup.writeCback = writeCback;
}
@@ -0,0 +1,111 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Pulse Oximiter Service Server implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_PLXS_H
#define SVC_PLXS_H
#include "att_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup PULSE_OXIMITER_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Pulse Oximiter Service Handles
*
*/
/**@{*/
#define PLXS_START_HDL 0x04A0 /*!< \brief Start handle. */
#define PLXS_END_HDL (PLXS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Pulse Oximiter Service Handles */
enum
{
PLXS_SVC_HDL = PLXS_START_HDL, /*!< \brief Pulse Oximiter Server Service declaration */
PLXS_FEATURES_CH_HDL, /*!< \brief Pulse Oximiter Features characteristic */
PLXS_FEATURES_HDL, /*!< \brief Pulse Oximiter Features */
PLXS_SPOT_CHECK_CH_HDL, /*!< \brief Pulse Oximiter Spot Check Measurement characteristic */
PLXS_SPOT_CHECK_HDL, /*!< \brief Pulse Oximiter Spot Check Measurement */
PLXS_SPOT_CHECK_CH_CCC_HDL, /*!< \brief Pulse Oximiter Spot Check Measurement Client Characteristic Configuration Descriptor */
PLXS_CONTINUOUS_CH_HDL, /*!< \brief Pulse Oximiter Continuous Measurement characteristic */
PLXS_CONTINUOUS_HDL, /*!< \brief Pulse Oximiter Continuous Measurement */
PLXS_CONTINUOUS_CH_CCC_HDL, /*!< \brief Pulse Oximiter Continuous Measurement Client Characteristic Configuration Descriptor */
PLXS_RECORD_ACCESS_CH_HDL, /*!< \brief Pulse Oximiter Record Access Control Point characteristic */
PLXS_RECORD_ACCESS_HDL, /*!< \brief Pulse Oximiter Record Access Control Point */
PLXS_RECORD_ACCESS_CH_CCC_HDL, /*!< \brief Pulse Oximiter Record Access Control Point Client Characteristic Configuration Descriptor */
PLXS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPlxsAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPlxsRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPlxsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*! \} */ /* PULSE_OXIMITER_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_PLXS_H */
@@ -0,0 +1,221 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Proximity services implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_px.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef PX_SEC_PERMIT_READ
#define PX_SEC_PERMIT_READ SVC_SEC_PERMIT_READ
#endif
/*! Characteristic write permissions */
#ifndef PX_SEC_PERMIT_WRITE
#define PX_SEC_PERMIT_WRITE SVC_SEC_PERMIT_WRITE
#endif
/**************************************************************************************************
Static Variables
**************************************************************************************************/
/* UUIDs */
static const uint8_t svcAlLvlUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_ALERT_LEVEL)};
static const uint8_t svcTxPwrUuid[ATT_16_UUID_LEN] = {UINT16_TO_BYTES(ATT_UUID_TX_POWER_LEVEL)};
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Link loss service declaration */
static const uint8_t llsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_LINK_LOSS_SERVICE)};
static const uint16_t llsLenSvc = sizeof(llsValSvc);
/* Link loss alert level characteristic */
static const uint8_t llsValAlCh[] = {ATT_PROP_READ | ATT_PROP_WRITE, UINT16_TO_BYTES(LLS_AL_HDL), UINT16_TO_BYTES(ATT_UUID_ALERT_LEVEL)};
static const uint16_t llsLenAlCh = sizeof(llsValAlCh);
/* Link loss alert level */
static uint8_t llsValAl[] = {0};
static const uint16_t llsLenAl = sizeof(llsValAl);
/* Immediate alert service declaration */
static const uint8_t iasValSvc[] = {UINT16_TO_BYTES(ATT_UUID_IMMEDIATE_ALERT_SERVICE)};
static const uint16_t iasLenSvc = sizeof(iasValSvc);
/* Immediate alert alert level characteristic */
static const uint8_t iasValAlCh[] = {ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(IAS_AL_HDL), UINT16_TO_BYTES(ATT_UUID_ALERT_LEVEL)};
static const uint16_t iasLenAlCh = sizeof(iasValAlCh);
/* Immediate alert alert level */
static uint8_t iasValAl[] = {0};
static const uint16_t iasLenAl = sizeof(iasValAl);
/* TX power service declaration */
static const uint8_t txsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_TX_POWER_SERVICE)};
static const uint16_t txsLenSvc = sizeof(txsValSvc);
/* TX power level characteristic */
static const uint8_t txsValTxCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(TXS_TX_HDL), UINT16_TO_BYTES(ATT_UUID_TX_POWER_LEVEL)};
static const uint16_t txsLenTxCh = sizeof(txsValTxCh);
/* TX power level */
static uint8_t txsValTx[] = {0};
static const uint16_t txsLenTx = sizeof(txsValTx);
/* Attribute list */
static const attsAttr_t pxList[] =
{
{
attPrimSvcUuid,
(uint8_t *) llsValSvc,
(uint16_t *) &llsLenSvc,
sizeof(llsValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) llsValAlCh,
(uint16_t *) &llsLenAlCh,
sizeof(llsValAlCh),
0,
ATTS_PERMIT_READ
},
{
svcAlLvlUuid,
llsValAl,
(uint16_t *) &llsLenAl,
sizeof(llsValAl),
0,
PX_SEC_PERMIT_READ | PX_SEC_PERMIT_WRITE
},
{
attPrimSvcUuid,
(uint8_t *) iasValSvc,
(uint16_t *) &iasLenSvc,
sizeof(iasValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) iasValAlCh,
(uint16_t *) &iasLenAlCh,
sizeof(iasValAlCh),
0,
ATTS_PERMIT_READ
},
{
svcAlLvlUuid,
iasValAl,
(uint16_t *) &iasLenAl,
sizeof(iasValAl),
ATTS_SET_WRITE_CBACK,
PX_SEC_PERMIT_WRITE
},
{
attPrimSvcUuid,
(uint8_t *) txsValSvc,
(uint16_t *) &txsLenSvc,
sizeof(txsValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) txsValTxCh,
(uint16_t *) &txsLenTxCh,
sizeof(txsValTxCh),
0,
ATTS_PERMIT_READ
},
{
svcTxPwrUuid,
txsValTx,
(uint16_t *) &txsLenTx,
sizeof(txsValTx),
0,
PX_SEC_PERMIT_READ
}
};
/* Group structure */
static attsGroup_t svcPxGroup =
{
NULL,
(attsAttr_t *) pxList,
NULL,
NULL,
PX_START_HDL,
PX_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPxAddGroup(void)
{
/* add services */
AttsAddGroup(&svcPxGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPxRemoveGroup(void)
{
AttsRemoveGroup(PX_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPxCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcPxGroup.readCback = readCback;
svcPxGroup.writeCback = writeCback;
}
@@ -0,0 +1,109 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Proximity services implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_PX_H
#define SVC_PX_H
#include "att_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup PROXIMITY_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Proximity Service Handles
*
*/
/**@{*/
#define PX_START_HDL 0x50 /*!< \brief Start handle. */
#define PX_END_HDL (PX_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Service Handles */
enum
{
LLS_SVC_HDL = PX_START_HDL, /*!< \brief Link loss service declaration */
LLS_AL_CH_HDL, /*!< \brief Alert level characteristic */
LLS_AL_HDL, /*!< \brief Alert level */
IAS_SVC_HDL, /*!< \brief Immediate alert service declaration */
IAS_AL_CH_HDL, /*!< \brief Alert level characteristic */
IAS_AL_HDL, /*!< \brief Alert level */
TXS_SVC_HDL, /*!< \brief TX power service declaration */
TXS_TX_CH_HDL, /*!< \brief TX power level characteristic */
TXS_TX_HDL, /*!< \brief TX power level */
PX_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPxAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPxRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcPxCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*! \} */ /* PROXIMITY_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_PX_H */
@@ -0,0 +1,215 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Running Speed and Cadence Service Server implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "att_uuid.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_rscs.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef RSCS_SEC_PERMIT_READ
#define RSCS_SEC_PERMIT_READ (ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC)
#endif
/*! Characteristic write permissions */
#ifndef RSCS_SEC_PERMIT_WRITE
#define RSCS_SEC_PERMIT_WRITE (ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC)
#endif
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Running Speed service declaration */
static const uint8_t rscsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_RUNNING_SPEED_SERVICE)};
static const uint16_t rscsLenSvc = sizeof(rscsValSvc);
/* Running Speed Feature characteristic */
static const uint8_t rscsValFeatureCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(RSCS_RSF_HDL), UINT16_TO_BYTES(ATT_UUID_RUNNING_SPEED_FEATURE)};
static const uint16_t rscsLenFeatureCh = sizeof(rscsValFeatureCh);
/* Running Speed Feature */
/* TODO: Set Supported Feature Bits */
static uint16_t rscsValFeature[] = {RSCS_ISLMS_FEATURE_BIT};
static const uint16_t rscsLenFeature = sizeof(rscsValFeature);
/* Running Speed Measurement characteristic */
static const uint8_t rscsValMeasurementCh[] = { ATT_PROP_NOTIFY, UINT16_TO_BYTES(RSCS_RSM_HDL), UINT16_TO_BYTES(ATT_UUID_RUNNING_SPEED_MEASUREMENT)};
static const uint16_t rscsLenMeasurementCh = sizeof(rscsValMeasurementCh);
/* Running Speed Measurement */
/* Note these are dummy values */
static const uint8_t rscsValMeasurement[] = { 0 };
static const uint16_t rscsLenMeasurement = CH_RSCS_MEASUREMENT_LEN;
/* Running Speed Measurement client characteristic configuration */
static uint8_t rscsValMeasurementChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t rscsLenMeasurementChCcc = sizeof(rscsValMeasurementChCcc);
/* Running Speed Sensor Location characteristic */
static const uint8_t rscsValLocationCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(RSCS_SL_HDL), UINT16_TO_BYTES(ATT_UUID_SENSOR_LOCATION)};
static const uint16_t rscsLenLocationCh = sizeof(rscsValLocationCh);
/* Running Speed Sensor Location */
static uint8_t rscsValLocation[] = { 0 };
static const uint16_t rscsLenLocation = sizeof(rscsValLocation);
/* Attribute list for RSCS group */
static const attsAttr_t rscsList[] =
{
/* Running Speed Service declaration */
{
attPrimSvcUuid,
(uint8_t *) rscsValSvc,
(uint16_t *) &rscsLenSvc,
sizeof(rscsValSvc),
0,
ATTS_PERMIT_READ
},
/* Running Speed Feature characteristic */
{
attChUuid,
(uint8_t *)rscsValFeatureCh,
(uint16_t *) &rscsLenFeatureCh,
sizeof(rscsValFeatureCh),
0,
ATTS_PERMIT_READ
},
/* Running Speed Feature value */
{
attRsfChUuid,
(uint8_t *)rscsValFeature,
(uint16_t *) &rscsLenFeature,
sizeof(rscsValFeature),
0,
RSCS_SEC_PERMIT_READ
},
/* Running Speed Measurement characteristic */
{
attChUuid,
(uint8_t *)rscsValMeasurementCh,
(uint16_t *)&rscsLenMeasurementCh,
sizeof(rscsValMeasurementCh),
0,
ATTS_PERMIT_READ
},
/* Running Speed Measurement value */
{
attRsmChUuid,
(uint8_t *)rscsValMeasurement,
(uint16_t *)&rscsLenMeasurement,
sizeof(rscsValMeasurement),
0,
0
},
/* Characteristic CCC descriptor */
{
attCliChCfgUuid,
rscsValMeasurementChCcc,
(uint16_t *)&rscsLenMeasurementChCcc,
sizeof(rscsValMeasurementChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | RSCS_SEC_PERMIT_WRITE)
},
/* Running Speed Sensor Location characteristic */
{
attChUuid,
(uint8_t *)rscsValLocationCh,
(uint16_t *)&rscsLenLocationCh,
sizeof(rscsValLocationCh),
0,
ATTS_PERMIT_READ
},
/* Running Speed Sensor Location value */
{
attSlChUuid,
(uint8_t *)rscsValLocation,
(uint16_t *)&rscsLenLocation,
sizeof(rscsValLocation),
0,
RSCS_SEC_PERMIT_READ
},
};
/* RSCS group structure */
static attsGroup_t svcRscsGroup =
{
NULL,
(attsAttr_t *) rscsList,
NULL,
NULL,
RSCS_START_HDL,
RSCS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcRscsAddGroup(void)
{
AttsAddGroup(&svcRscsGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcRscsRemoveGroup(void)
{
AttsRemoveGroup(RSCS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcRscsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcRscsGroup.readCback = readCback;
svcRscsGroup.writeCback = writeCback;
}
@@ -0,0 +1,125 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Running Speed and Cadence Service Server implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_RSCS_H
#define SVC_RSCS_H
#include "att_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup RUNNING_SPEED_AND_CADENCE_SERVICE
* \{ */
/**************************************************************************************************
Constants
**************************************************************************************************/
/** \name RSC Feature Bits
* Running Speed and Cadence Feature Bits of the Feature Characteristic
*/
/**@{*/
#define RSCS_ISLMS_FEATURE_BIT (1<<0) /*!< \brief Instantaneous Stride Length Measurement Supported Feature Mask Bit */
#define RSCS_TDMS_FEATURE_BIT (1<<1) /*!< \brief Total Distance Measurement Supported Feature Mask Bit */
#define RSCS_WRSS_FEATURE_BIT (1<<2) /*!< \brief Walking or Running Status Supported Feature Mask Bit */
#define RSCS_CPS_FEATURE_BIT (1<<3) /*!< \brief Calibration Procedure Supported Feature Mask Bit */
#define RSCS_MSLS_FEATURE_BIT (1<<4) /*!< \brief Multiple Sensor Locations Supporte Feature Mask Bit */
/*! \brief TODO: Set to all supported features */
#define RSCS_ALL_FEATURES (0x7) /*!< \brief All Supported Feature Mask */
/**@}*/
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Running Speed and Cadence Service Handles
*
*/
/**@{*/
#define RSCS_START_HDL 0x04A0 /*!< \brief Start handle. */
#define RSCS_END_HDL (RSCS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Running Speed Service Handles */
enum
{
RSCS_SVC_HDL = RSCS_START_HDL, /*!< \brief Running Speed Server Service declaration */
RSCS_RSF_CH_HDL, /*!< \brief Running Speed Feature characteristic */
RSCS_RSF_HDL, /*!< \brief Running Speed Feature */
RSCS_RSM_CH_HDL, /*!< \brief Running Speed Measurement characteristic */
RSCS_RSM_HDL, /*!< \brief Running Speed Measurement */
RSCS_RSM_CH_CCC_HDL, /*!< \brief Running Speed Measurement Client Characteristic Configuration Descriptor */
RSCS_SL_CH_HDL, /*!< \brief Running Speed Sensor Location characteristic */
RSCS_SL_HDL, /*!< \brief Running Speed Sensor Location */
RSCS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcRscsAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcRscsRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcRscsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*! \} */ /* RUNNING_SPEED_AND_CADENCE_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_RSCS_H */
@@ -0,0 +1,144 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Scan Parameter Service Server implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_scpss.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef SCPSS_SEC_PERMIT_READ
#define SCPSS_SEC_PERMIT_READ (ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC)
#endif
/*! Characteristic write permissions */
#ifndef SCPSS_SEC_PERMIT_WRITE
#define SCPSS_SEC_PERMIT_WRITE (ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC)
#endif
/**************************************************************************************************
Service variables
**************************************************************************************************/
/*Scan parameter service declaration */
static const uint8_t scpssValSvc[] = {UINT16_TO_BYTES(ATT_UUID_SCAN_PARAM_SERVICE)};
static const uint16_t scpssLenSvc = sizeof(scpssValSvc);
/* Scan interval window characteristic */
static const uint8_t scpssValSiwCh[] = {ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(SCPSS_SIW_HDL), UINT16_TO_BYTES(ATT_UUID_SCAN_INT_WIND)};
static const uint16_t scpssLenSiwCh = sizeof(scpssValSiwCh);
/* Scan interval window measurement */
/* Note these are dummy values */
static const uint8_t scpssValSiw[] = {0};
static const uint16_t scpssLenSiw = CH_SCPP_INTERVAL_WINDOW_LEN;
/* Attribute list for SCPSS group */
static const attsAttr_t scpssList[] =
{
/* Scan Parameter Service declaration */
{
attPrimSvcUuid,
(uint8_t *) scpssValSvc,
(uint16_t *) &scpssLenSvc,
sizeof(scpssValSvc),
0,
ATTS_PERMIT_READ
},
/* Scan interval window characteristic */
{
attChUuid,
(uint8_t *)scpssValSiwCh,
(uint16_t *) &scpssLenSiwCh,
sizeof(scpssValSiwCh),
0,
ATTS_PERMIT_READ
},
/* Scan interval window */
{
attSiwChUuid,
(uint8_t *)scpssValSiw,
(uint16_t *) &scpssLenSiw,
CH_SCPP_INTERVAL_WINDOW_LEN,
ATTS_SET_WRITE_CBACK,
SCPSS_SEC_PERMIT_WRITE
},
};
/* SCPSS group structure */
static attsGroup_t svcScpssGroup =
{
NULL,
(attsAttr_t *) scpssList,
NULL,
NULL,
SCPSS_START_HDL,
SCPSS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcScpssAddGroup(void)
{
AttsAddGroup(&svcScpssGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcScpssRemoveGroup(void)
{
AttsRemoveGroup(SCPSS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcScpssCbackRegister(attsWriteCback_t writeCback)
{
svcScpssGroup.writeCback = writeCback;
}
@@ -0,0 +1,99 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Scan Parameter Service Server implementation.
*
* Copyright (c) 2016-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_SCPSS_H
#define SVC_SCPSS_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup SCAN_PARAMETER_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Scan Parameter Service Handles
*
*/
/**@{*/
#define SCPSS_START_HDL 0x0300 /*!< \brief Start handle. */
#define SCPSS_END_HDL (SCPSS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Scan Parameter Service Handles */
enum
{
SCPSS_SVC_HDL = SCPSS_START_HDL, /*!< \brief Scan Parameter Server Service declaration */
SCPSS_SIW_CH_HDL, /*!< \brief Scan Interval Window characteristic */
SCPSS_SIW_HDL, /*!< \brief Scan Interval Window */
SCPSS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcScpssAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcScpssRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcScpssCbackRegister(attsWriteCback_t writeCback);
/*! \} */ /* SCAN_PARAMETER_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_SCPSS_H */
@@ -0,0 +1,251 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example temperature sensor service implementation.
*
* Copyright (c) 2015-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_cfg.h"
#include "svc_temp.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
#define TEMP_UUID_SVC 0x3010
#define TEMP_UUID_CHR_DATA 0x3011
#define TEMP_UUID_CHR_CONFIG 0x3012
#define TEMP_UUID_CHR_PERIOD 0x3013
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Temperature service declaration. */
static const uint8_t tempValSvc[] = {UINT16_TO_BYTES(TEMP_UUID_SVC)};
static const uint16_t tempLenSvc = sizeof(tempValSvc);
/* Temperature data characteristic. */
static const uint8_t tempValDataChr[] = {ATT_PROP_READ | ATT_PROP_NOTIFY,
UINT16_TO_BYTES(TEMP_HANDLE_DATA),
UINT16_TO_BYTES(TEMP_UUID_CHR_DATA)};
static const uint16_t tempLenDataChr = sizeof(tempValDataChr);
/* Temperature data. */
static const uint8_t tempUuidData[] = {UINT16_TO_BYTES(TEMP_UUID_CHR_DATA)};
static uint8_t tempValData[] = {0x00, 0x00};
static const uint16_t tempLenData = sizeof(tempValData);
/* Temperature data client characteristic configuration. */
static uint8_t tempValDataClientChrConfig[] = {0x00, 0x00};
static const uint16_t tempLenDataClientChrConfig = sizeof(tempValDataClientChrConfig);
/* Temperature data characteristic user description. */
static const uint8_t tempValDataChrUsrDescr[] = "SMD Temp Data";
static const uint16_t tempLenDataChrUsrDescr = sizeof(tempValDataChrUsrDescr) - 1u;
/* Temperature config characteristic. */
static const uint8_t tempValConfigChr[] = {ATT_PROP_READ | ATT_PROP_WRITE,
UINT16_TO_BYTES(TEMP_HANDLE_CONFIG),
UINT16_TO_BYTES(TEMP_UUID_CHR_CONFIG)};
static const uint16_t tempLenConfigChr = sizeof(tempValConfigChr);
/* Temperature config. */
static const uint8_t tempUuidConfig[] = {UINT16_TO_BYTES(TEMP_UUID_CHR_CONFIG)};
static uint8_t tempValConfig[] = {0x00};
static const uint16_t tempLenConfig = sizeof(tempValConfig);
/* Temperature config characteristic user description. */
static const uint8_t tempValConfigChrUsrDescr[] = "SMD Temp Config";
static const uint16_t tempLenConfigChrUsrDescr = sizeof(tempValConfigChrUsrDescr) - 1u;
/* Temperature period characteristic. */
static const uint8_t tempValPeriodChr[] = {ATT_PROP_READ | ATT_PROP_WRITE,
UINT16_TO_BYTES(TEMP_HANDLE_PERIOD),
UINT16_TO_BYTES(TEMP_UUID_CHR_PERIOD)};
static const uint16_t tempLenPeriodChr = sizeof(tempValPeriodChr);
/* Temperature period. */
static const uint8_t tempUuidPeriod[] = {UINT16_TO_BYTES(TEMP_UUID_CHR_PERIOD)};
static uint8_t tempValPeriod[] = {TEMP_ATT_PERIOD_DEFAULT};
static const uint16_t tempLenPeriod = sizeof(tempValPeriod);
/* Temperature period characteristic user description. */
static const uint8_t tempValPeriodChrUsrDescr[] = "SMD Temp Period";
static const uint16_t tempLenPeriodChrUsrDescr = sizeof(tempValPeriodChrUsrDescr) - 1u;
/* Attribute list for temp group. */
static const attsAttr_t tempList[] =
{
/* Service declaration. */
{
attPrimSvcUuid,
(uint8_t *) tempValSvc,
(uint16_t *) &tempLenSvc,
sizeof(tempValSvc),
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration. */
{
attChUuid,
(uint8_t *) tempValDataChr,
(uint16_t *) &tempLenDataChr,
sizeof(tempValDataChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value. */
{
tempUuidData,
(uint8_t *) tempValData,
(uint16_t *) &tempLenData,
sizeof(tempValData),
0,
ATTS_PERMIT_READ
},
/* Client characteristic configuration. */
{
attCliChCfgUuid,
(uint8_t *) tempValDataClientChrConfig,
(uint16_t *) &tempLenDataClientChrConfig,
sizeof(tempValDataClientChrConfig),
ATTS_SET_CCC,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description. */
{
attChUserDescUuid,
(uint8_t *) tempValDataChrUsrDescr,
(uint16_t *) &tempLenDataChrUsrDescr,
sizeof(tempValDataChrUsrDescr) - 1,
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration. */
{
attChUuid,
(uint8_t *) tempValConfigChr,
(uint16_t *) &tempLenConfigChr,
sizeof(tempValConfigChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value. */
{
tempUuidConfig,
(uint8_t *) tempValConfig,
(uint16_t *) &tempLenConfig,
sizeof(tempValConfig),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description. */
{
attChUserDescUuid,
(uint8_t *) tempValConfigChrUsrDescr,
(uint16_t *) &tempLenConfigChrUsrDescr,
sizeof(tempValConfigChrUsrDescr),
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration. */
{
attChUuid,
(uint8_t *) tempValPeriodChr,
(uint16_t *) &tempLenPeriodChr,
sizeof(tempValPeriodChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value. */
{
tempUuidPeriod,
(uint8_t *) tempValPeriod,
(uint16_t *) &tempLenPeriod,
sizeof(tempValPeriod),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description. */
{
attChUserDescUuid,
(uint8_t *) tempValPeriodChrUsrDescr,
(uint16_t *) &tempLenPeriodChrUsrDescr,
sizeof(tempValPeriodChrUsrDescr),
0,
ATTS_PERMIT_READ
}
};
/* Gyro group structure. */
static attsGroup_t tempGroup =
{
NULL,
(attsAttr_t *) tempList,
NULL,
NULL,
TEMP_HANDLE_START,
TEMP_HANDLE_END
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcTempAddGroup(void)
{
AttsAddGroup(&tempGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcTempRemoveGroup(void)
{
AttsRemoveGroup(TEMP_HANDLE_START);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcTempCbackRegister(attsWriteCback_t writeCback)
{
tempGroup.writeCback = writeCback;
}
@@ -0,0 +1,141 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example temperature sensor service implementation.
*
* Copyright (c) 2015-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_TEMP_H
#define SVC_TEMP_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup TEMPERATURE_SENSOR_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Temperature Service Handles
*
*/
/**@{*/
#define TEMP_HANDLE_START 0x60 /*!< \brief Start handle. */
#define TEMP_HANDLE_END (TEMP_HANDLE_END_PLUS_ONE - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Temperature service handles. */
enum
{
TEMP_HANDLE_SVC = TEMP_HANDLE_START, /*!< \brief Service declaration. */
TEMP_HANDLE_DATA_CHR, /*!< \brief Data characteristic declaration. */
TEMP_HANDLE_DATA, /*!< \brief Data characteristic value. */
TEMP_HANDLE_DATA_CLIENT_CHR_CONFIG, /*!< \brief Data characteristic CCCD. */
TEMP_HANDLE_DATA_CHR_USR_DESCR, /*!< \brief Data characteristic user description. */
TEMP_HANDLE_CONFIG_CHR, /*!< \brief Configruation characteristic declaration. */
TEMP_HANDLE_CONFIG, /*!< \brief Configruation characteristic value. */
TEMP_HANDLE_CONFIG_CHR_USR_DESCR, /*!< \brief Configruation characteristic user description. */
TEMP_HANDLE_PERIOD_CHR, /*!< \brief Period characteristc declaration. */
TEMP_HANDLE_PERIOD, /*!< \brief Period characteristc value. */
TEMP_HANDLE_PERIOD_CHR_USR_DESCR, /*!< \brief Period characteristc user description. */
TEMP_HANDLE_END_PLUS_ONE /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Macros
**************************************************************************************************/
/** \name Configuration Attributes
*
*/
/**@{*/
#define TEMP_ATT_CONFIG_DISABLE 0x00u /*!< \brief Disable */
#define TEMP_ATT_CONFIG_ENABLE 0x01u /*!< \brief Enable */
/**@}*/
/** \name Values for Period Attributes
*
*/
/**@{*/
#define TEMP_ATT_PERIOD_MAX 250u /*!< \brief Maximum period */
#define TEMP_ATT_PERIOD_DEFAULT 100u /*!< \brief Default period */
#define TEMP_ATT_PERIOD_MIN 10u /*!< \brief Minimum period */
/**@}*/
/** \name Sizes of Attributes
*
*/
/**@{*/
#define TEMP_SIZE_CONFIG_ATT 1u /*!< \brief Config Attribute size */
#define TEMP_SIZE_PERIOD_ATT 1u /*!< \brief Period Attribute size */
#define TEMP_SIZE_DATA_ATT 6u /*!< \brief Data Attribute size */
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcTempAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcTempRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcTempCbackRegister(attsWriteCback_t writeCback);
/*! \} */ /* TEMPERATURE_SENSOR_SERVICE */
#ifdef __cplusplus
}
#endif
#endif /* SVC_TEMP_H */
@@ -0,0 +1,301 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Time-related services implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_time.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef TIME_SEC_PERMIT_READ
#define TIME_SEC_PERMIT_READ SVC_SEC_PERMIT_READ
#endif
/*! Characteristic write permissions */
#ifndef TIME_SEC_PERMIT_WRITE
#define TIME_SEC_PERMIT_WRITE SVC_SEC_PERMIT_WRITE
#endif
/**************************************************************************************************
Time-Related Services group
**************************************************************************************************/
/*!
* Current time service
*/
/* Current time service declaration */
static const uint8_t timeCtsValSvc[] = {UINT16_TO_BYTES(ATT_UUID_CURRENT_TIME_SERVICE)};
static const uint16_t timeCtsLenSvc = sizeof(timeCtsValSvc);
/* CT time characteristic */
static const uint8_t timeCtsValCtCh[] = {ATT_PROP_READ | ATT_PROP_NOTIFY, UINT16_TO_BYTES(TIME_CTS_CT_HDL), UINT16_TO_BYTES(ATT_UUID_CURRENT_TIME)};
static const uint16_t timeCtsLenCtCh = sizeof(timeCtsValCtCh);
/* CT time */
static const uint8_t timeCtsUuCt[] = {UINT16_TO_BYTES(ATT_UUID_CURRENT_TIME)};
static uint8_t timeCtsValCt[] = {UINT16_TO_BYTES(2011), 3, 17, 14, 55, 57, 0, 0, 0};
static const uint16_t timeCtsLenCt = sizeof(timeCtsValCt);
/* CT time client characteristic configuration */
static uint8_t timeCtsValCtChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t timeCtsLenCtChCcc = sizeof(timeCtsValCtChCcc);
/* Local time information characteristic */
static const uint8_t timeCtsValLocCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(TIME_CTS_LOC_HDL), UINT16_TO_BYTES(ATT_UUID_LOCAL_TIME_INFO)};
static const uint16_t timeCtsLenLocCh = sizeof(timeCtsValLocCh);
/* Local time information */
static const uint8_t timeCtsUuLoc[] = {UINT16_TO_BYTES(ATT_UUID_LOCAL_TIME_INFO)};
static uint8_t timeCtsValLoc[] = {(uint8_t) -32, 0};
static const uint16_t timeCtsLenLoc = sizeof(timeCtsValLoc);
/* Reference time information characteristic */
static const uint8_t timeCtsValRefCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(TIME_CTS_REF_HDL), UINT16_TO_BYTES(ATT_UUID_REFERENCE_TIME_INFO)};
static const uint16_t timeCtsLenRefCh = sizeof(timeCtsValRefCh);
/* Reference time information */
static const uint8_t timeCtsUuRef[] = {UINT16_TO_BYTES(ATT_UUID_REFERENCE_TIME_INFO)};
static uint8_t timeCtsValRef[] = {4, 255, 15, 4};
static const uint16_t timeCtsLenRef = sizeof(timeCtsValRef);
/*!
* DST change service
*/
/* DST change service declaration */
static const uint8_t timeDstValSvc[] = {UINT16_TO_BYTES(ATT_UUID_DST_CHANGE_SERVICE)};
static const uint16_t timeDstLenSvc = sizeof(timeDstValSvc);
/* Time with DST characteristic */
static const uint8_t timeDstValWdstCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(TIME_DST_WDST_HDL), UINT16_TO_BYTES(ATT_UUID_TIME_WITH_DST)};
static const uint16_t timeDstLenWdstCh = sizeof(timeDstValWdstCh);
/* Time with DST */
static const uint8_t timeDstUuWdst[] = {UINT16_TO_BYTES(ATT_UUID_TIME_WITH_DST)};
static uint8_t timeDstValWdst[] = {0, 0, 0, 0, 0, 0, 0, 0};
static const uint16_t timeDstLenWdst = sizeof(timeDstValWdst);
/*!
* Reference time update service
*/
/* Reference time update service declaration */
static const uint8_t timeRtuValSvc[] = {UINT16_TO_BYTES(ATT_UUID_REF_TIME_UPDATE_SERVICE)};
static const uint16_t timeRtuLenSvc = sizeof(timeRtuValSvc);
/* Time update control point characteristic */
static const uint8_t timeRtuValCpCh[] = {ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(TIME_RTU_CP_HDL), UINT16_TO_BYTES(ATT_UUID_TIME_UPDATE_CP)};
static const uint16_t timeRtuLenCpCh = sizeof(timeRtuValCpCh);
/* Time update control point */
static const uint8_t timeRtuUuCp[] = {UINT16_TO_BYTES(ATT_UUID_TIME_UPDATE_CP)};
static uint8_t timeRtuValCp[] = {0};
static const uint16_t timeRtuLenCp = sizeof(timeRtuValCp);
/* Time update state characteristic */
static const uint8_t timeRtuValStateCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(TIME_RTU_STATE_HDL), UINT16_TO_BYTES(ATT_UUID_TIME_UPDATE_STATE)};
static const uint16_t timeRtuLenStateCh = sizeof(timeRtuValStateCh);
/* Time update state */
static const uint8_t timeRtuUuState[] = {UINT16_TO_BYTES(ATT_UUID_TIME_UPDATE_STATE)};
static uint8_t timeRtuValState[] = {0, 0};
static const uint16_t timeRtuLenState = sizeof(timeRtuValState);
/* Attribute list for group */
static const attsAttr_t timeList[] =
{
/* CT time service */
{
attPrimSvcUuid,
(uint8_t *) timeCtsValSvc,
(uint16_t *) &timeCtsLenSvc,
sizeof(timeCtsValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) timeCtsValCtCh,
(uint16_t *) &timeCtsLenCtCh,
sizeof(timeCtsValCtCh),
0,
ATTS_PERMIT_READ
},
{
timeCtsUuCt,
timeCtsValCt,
(uint16_t *) &timeCtsLenCt,
sizeof(timeCtsValCt),
0,
TIME_SEC_PERMIT_READ
},
{
attCliChCfgUuid,
timeCtsValCtChCcc,
(uint16_t *) &timeCtsLenCtChCcc,
sizeof(timeCtsValCtChCcc),
0,
(ATTS_PERMIT_READ | TIME_SEC_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) timeCtsValLocCh,
(uint16_t *) &timeCtsLenLocCh,
sizeof(timeCtsValLocCh),
0,
ATTS_PERMIT_READ
},
{
timeCtsUuLoc,
timeCtsValLoc,
(uint16_t *) &timeCtsLenLoc,
sizeof(timeCtsValLoc),
0,
TIME_SEC_PERMIT_READ
},
{
attChUuid,
(uint8_t *) timeCtsValRefCh,
(uint16_t *) &timeCtsLenRefCh,
sizeof(timeCtsValRefCh),
0,
ATTS_PERMIT_READ
},
{
timeCtsUuRef,
timeCtsValRef,
(uint16_t *) &timeCtsLenRef,
sizeof(timeCtsValRef),
0,
TIME_SEC_PERMIT_READ
},
/* DST change service */
{
attPrimSvcUuid,
(uint8_t *) timeDstValSvc,
(uint16_t *) &timeDstLenSvc,
sizeof(timeDstValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) timeDstValWdstCh,
(uint16_t *) &timeDstLenWdstCh,
sizeof(timeDstValWdstCh),
0,
ATTS_PERMIT_READ
},
{
timeDstUuWdst,
timeDstValWdst,
(uint16_t *) &timeDstLenWdst,
sizeof(timeDstValWdst),
0,
TIME_SEC_PERMIT_READ
},
/* Reference time update service */
{
attPrimSvcUuid,
(uint8_t *) timeRtuValSvc,
(uint16_t *) &timeRtuLenSvc,
sizeof(timeRtuValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) timeRtuValCpCh,
(uint16_t *) &timeRtuLenCpCh,
sizeof(timeRtuValCpCh),
0,
ATTS_PERMIT_READ
},
{
timeRtuUuCp,
timeRtuValCp,
(uint16_t *) &timeRtuLenCp,
sizeof(timeRtuValCp),
0,
TIME_SEC_PERMIT_WRITE
},
{
attChUuid,
(uint8_t *) timeRtuValStateCh,
(uint16_t *) &timeRtuLenStateCh,
sizeof(timeRtuValStateCh),
0,
ATTS_PERMIT_READ
},
{
timeRtuUuState,
timeRtuValState,
(uint16_t *) &timeRtuLenState,
sizeof(timeRtuValState),
0,
TIME_SEC_PERMIT_READ
}
};
/* Time group structure */
static attsGroup_t svcTimeGroup =
{
NULL,
(attsAttr_t *) timeList,
NULL,
NULL,
TIME_START_HDL,
TIME_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcTimeAddGroup(void)
{
AttsAddGroup(&svcTimeGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcTimeRemoveGroup(void)
{
AttsRemoveGroup(TIME_START_HDL);
}
@@ -0,0 +1,112 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Time-related service implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_TIME_H
#define SVC_TIME_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup TIME-RELATED_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Time Service Handles
*
*/
/**@{*/
#define TIME_START_HDL 0xC0 /*!< \brief Start handle. */
#define TIME_END_HDL (TIME_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Time-Related Service Handles */
enum
{
TIME_CTS_SVC_HDL = TIME_START_HDL, /*!< \brief Current time service declaration */
TIME_CTS_CT_CH_HDL, /*!< \brief CT time characteristic */
TIME_CTS_CT_HDL, /*!< \brief CT time */
TIME_CTS_CT_CH_CCC_HDL, /*!< \brief CT time client characteristic configuration */
TIME_CTS_LOC_CH_HDL, /*!< \brief Local time information characteristic */
TIME_CTS_LOC_HDL, /*!< \brief Local time information */
TIME_CTS_REF_CH_HDL, /*!< \brief Reference time information characteristic */
TIME_CTS_REF_HDL, /*!< \brief Reference time information */
TIME_DST_SVC_HDL, /*!< \brief DST change service declaration */
TIME_DST_WDST_CH_HDL, /*!< \brief Time with DST characteristic */
TIME_DST_WDST_HDL, /*!< \brief Time with DST */
TIME_RTU_SVC_HDL, /*!< \brief Reference time update service declaration */
TIME_RTU_CP_CH_HDL, /*!< \brief Time update control point characteristic */
TIME_RTU_CP_HDL, /*!< \brief Time update control point */
TIME_RTU_STATE_CH_HDL, /*!< \brief Time update state characteristic */
TIME_RTU_STATE_HDL, /*!< \brief Time update state */
TIME_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/*! \brief Indexes of CCC descriptor handle table entries */
enum
{
TIME_CTS_CT_CH_CCC_IDX /*!< \brief CT time CCCD index. */
};
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcTimeAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcTimeRemoveGroup(void);
/*! \} */ /* TIME-RELATED_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_TIME_H */
@@ -0,0 +1,487 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief UriCfg configuration service implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_cfg.h"
#include "svc_uricfg.h"
#include "uribeacon/uricfg_defs.h"
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Beacon service declaration */
static const uint8_t uriCfgValSvc[] = {URICFG_UUID_BYTES(URICFG_UUID_SVC)};
static const uint16_t uriCfgLenSvc = sizeof(uriCfgValSvc);
/* Beacon lock state characteristic */
static const uint8_t uriCfgValLockStateChr[] = {ATT_PROP_READ,
UINT16_TO_BYTES(URICFG_HANDLE_LOCKSTATE),
URICFG_UUID_BYTES(URICFG_UUID_CHR_LOCKSTATE)};
static const uint16_t uriCfgLenLockStateChr = sizeof(uriCfgValLockStateChr);
/* Beacon lock state */
static const uint8_t uriCfgUuidLockState[] = {URICFG_UUID_BYTES(URICFG_UUID_CHR_LOCKSTATE)};
static uint8_t uriCfgValLockState[] = {0x00};
static const uint16_t uriCfgLenLockState = sizeof(uriCfgValLockState);
/* Beacon lock state characteristic user description */
static const uint8_t uriCfgValLockStateChrUsrDescr[] = "Lock State";
static const uint16_t uriCfgLenLockStateChrUsrDescr = sizeof(uriCfgValLockStateChrUsrDescr) - 1u;
/* Beacon lock characteristic */
static const uint8_t uriCfgValLockChr[] = {ATT_PROP_WRITE,
UINT16_TO_BYTES(URICFG_HANDLE_LOCK),
URICFG_UUID_BYTES(URICFG_UUID_CHR_LOCK)};
static const uint16_t uriCfgLenLockChr = sizeof(uriCfgValLockChr);
/* Beacon lock */
static const uint8_t uriCfgUuidLock[] = {URICFG_UUID_BYTES(URICFG_UUID_CHR_LOCK)};
static uint8_t uriCfgValLock[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static const uint16_t uriCfgLenLock = sizeof(uriCfgValLock);
/* Beacon lock characteristic user description */
static const uint8_t uriCfgValLockChrUsrDescr[] = "Lock";
static const uint16_t uriCfgLenLockChrUsrDescr = sizeof(uriCfgValLockChrUsrDescr) - 1u;
/* Beacon unlock characteristic */
static const uint8_t uriCfgValUnlockChr[] = {ATT_PROP_WRITE,
UINT16_TO_BYTES(URICFG_HANDLE_UNLOCK),
URICFG_UUID_BYTES(URICFG_UUID_CHR_UNLOCK)};
static const uint16_t uriCfgLenUnlockChr = sizeof(uriCfgValUnlockChr);
/* Beacon unlock */
static const uint8_t uriCfgUuidUnlock[] = {URICFG_UUID_BYTES(URICFG_UUID_CHR_UNLOCK)};
static uint8_t uriCfgValUnlock[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static const uint16_t uriCfgLenUnlock = sizeof(uriCfgValUnlock);
/* Beacon unlock characteristic user description */
static const uint8_t uriCfgValUnlockChrUsrDescr[] = "Unlock";
static const uint16_t uriCfgLenUnlockChrUsrDescr = sizeof(uriCfgValUnlockChrUsrDescr) - 1u;
/* Beacon URI data characteristic */
static const uint8_t uriCfgValUriDataChr[] = {ATT_PROP_READ | ATT_PROP_WRITE,
UINT16_TO_BYTES(URICFG_HANDLE_URIDATA),
URICFG_UUID_BYTES(URICFG_UUID_CHR_URIDATA)};
static const uint16_t uriCfgLenUriDataChr = sizeof(uriCfgValUriDataChr);
/* Beacon URI data */
static const uint8_t uriCfgUuidUriData[] = {URICFG_UUID_BYTES(URICFG_UUID_CHR_URIDATA)};
static uint8_t uriCfgValUriData[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00};
static uint16_t uriCfgLenUriData = 0u;
/* Beacon URI data characteristic user description */
static const uint8_t uriCfgValUriDataChrUsrDescr[] = "URI Data";
static const uint16_t uriCfgLenUriDataChrUsrDescr = sizeof(uriCfgValUriDataChrUsrDescr) - 1u;
/* Beacon URI flags characteristic */
static const uint8_t uriCfgValUriFlagsChr[] = {ATT_PROP_READ | ATT_PROP_WRITE,
UINT16_TO_BYTES(URICFG_HANDLE_URIFLAGS),
URICFG_UUID_BYTES(URICFG_UUID_CHR_URIFLAGS)};
static const uint16_t uriCfgLenUriFlagsChr = sizeof(uriCfgValUriFlagsChr);
/* Beacon URI flags */
static const uint8_t uriCfgUuidUriFlags[] = {URICFG_UUID_BYTES(URICFG_UUID_CHR_URIFLAGS)};
static uint8_t uriCfgValUriFlags[] = {0x00};
static const uint16_t uriCfgLenUriFlags = sizeof(uriCfgValUriFlags);
/* Beacon URI flags characteristic user description */
static const uint8_t uriCfgValUriFlagsChrUsrDescr[] = "URI Flags";
static const uint16_t uriCfgLenUriFlagsChrUsrDescr = sizeof(uriCfgValUriFlagsChrUsrDescr) - 1u;
/* Beacon advertised tx power levels characteristic */
static const uint8_t uriCfgValAdvertisedTxPwrLevelsChr[] = {ATT_PROP_READ | ATT_PROP_WRITE,
UINT16_TO_BYTES(URICFG_HANDLE_TXPWRLEVELS),
URICFG_UUID_BYTES(URICFG_UUID_CHR_TXPWRLEVELS)};
static const uint16_t uriCfgLenAdvertisedTxPwrLevelsChr = sizeof(uriCfgValAdvertisedTxPwrLevelsChr);
/* Beacon advertised tx power levels */
static const uint8_t uriCfgUuidAdvertisedTxPwrLevels[] = {URICFG_UUID_BYTES(URICFG_UUID_CHR_TXPWRLEVELS)};
static uint8_t uriCfgValAdvertisedTxPwrLevels[] = {0x00, 0x00, 0x00, 0x00};
static const uint16_t uriCfgLenAdvertisedTxPwrLevels = sizeof(uriCfgValAdvertisedTxPwrLevels);
/* Beacon advertised tx power levels characteristic user description */
static const uint8_t uriCfgValAdvertisedTxPwrLevelsChrUsrDescr[] = "Advertised Tx Power Levels";
static const uint16_t uriCfgLenAdvertisedTxPwrLevelsChrUsrDescr = sizeof(uriCfgValAdvertisedTxPwrLevelsChrUsrDescr) - 1u;
/* Beacon tx power mode characteristic */
static const uint8_t uriCfgValTxPwrModeChr[] = {ATT_PROP_READ | ATT_PROP_WRITE,
UINT16_TO_BYTES(URICFG_HANDLE_TXPWRMODE),
URICFG_UUID_BYTES(URICFG_UUID_CHR_TXPWRMODE)};
static const uint16_t uriCfgLenTxPwrModeChr = sizeof(uriCfgValTxPwrModeChr);
/* Beacon tx power mode */
static const uint8_t uriCfgUuidTxPwrMode[] = {URICFG_UUID_BYTES(URICFG_UUID_CHR_TXPWRMODE)};
static uint8_t uriCfgValTxPwrMode[] = {0x00};
static const uint16_t uriCfgLenTxPwrMode = sizeof(uriCfgValTxPwrMode);
/* Beacon tx power mode characteristic user description */
static const uint8_t uriCfgValTxPwrModeChrUsrDescr[] = "Tx Power Mode";
static const uint16_t uriCfgLenTxPwrModeChrUsrDescr = sizeof(uriCfgValTxPwrModeChrUsrDescr) - 1u;
/* Beacon period characteristic */
static const uint8_t uriCfgValBeaconPeriodChr[] = {ATT_PROP_READ | ATT_PROP_WRITE,
UINT16_TO_BYTES(URICFG_HANDLE_BEACONPERIOD),
URICFG_UUID_BYTES(URICFG_UUID_CHR_BEACONPERIOD)};
static const uint16_t uriCfgLenBeaconPeriodChr = sizeof(uriCfgValBeaconPeriodChr);
/* Beacon period */
static const uint8_t uriCfgUuidBeaconPeriod[] = {URICFG_UUID_BYTES(URICFG_UUID_CHR_BEACONPERIOD)};
static uint8_t uriCfgValBeaconPeriod[] = {0x00, 0x00};
static const uint16_t uriCfgLenBeaconPeriod = sizeof(uriCfgValBeaconPeriod);
/* Beacon period characteristic user description */
static const uint8_t uriCfgValBeaconPeriodChrUsrDescr[] = "Beacon Period";
static const uint16_t uriCfgLenBeaconPeriodChrUsrDescr = sizeof(uriCfgValBeaconPeriodChrUsrDescr) - 1u;
/* Beacon reset characteristic */
static const uint8_t uriCfgValResetChr[] = {ATT_PROP_WRITE,
UINT16_TO_BYTES(URICFG_HANDLE_RESET),
URICFG_UUID_BYTES(URICFG_UUID_CHR_RESET)};
static const uint16_t uriCfgLenResetChr = sizeof(uriCfgValResetChr);
/* Beacon reset */
static const uint8_t uriCfgUuidReset[] = {URICFG_UUID_BYTES(URICFG_UUID_CHR_RESET)};
static uint8_t uriCfgValReset[] = {0x00};
static const uint16_t uriCfgLenReset = sizeof(uriCfgValReset);
/* Beacon reset characteristic user description */
static const uint8_t uriCfgValResetChrUsrDescr[] = "Reset";
static const uint16_t uriCfgLenResetChrUsrDescr = sizeof(uriCfgValResetChrUsrDescr) - 1u;
/* Attribute list for uriCfg group */
static const attsAttr_t uriCfgList[] =
{
/* Service declaration */
{
attPrimSvcUuid,
(uint8_t *) uriCfgValSvc,
(uint16_t *) &uriCfgLenSvc,
sizeof(uriCfgValSvc),
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration */
{
attChUuid,
(uint8_t *) uriCfgValLockStateChr,
(uint16_t *) &uriCfgLenLockStateChr,
sizeof(uriCfgValLockStateChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
uriCfgUuidLockState,
(uint8_t *) uriCfgValLockState,
(uint16_t *) &uriCfgLenLockState,
sizeof(uriCfgValLockState),
0,
ATTS_PERMIT_READ
},
/* Characteristic user description */
{
attChUserDescUuid,
(uint8_t *) uriCfgValLockStateChrUsrDescr,
(uint16_t *) &uriCfgLenLockStateChrUsrDescr,
sizeof(uriCfgValLockStateChrUsrDescr) - 1,
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration */
{
attChUuid,
(uint8_t *) uriCfgValLockChr,
(uint16_t *) &uriCfgLenLockChr,
sizeof(uriCfgValLockChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
uriCfgUuidLock,
(uint8_t *) uriCfgValLock,
(uint16_t *) &uriCfgLenLock,
sizeof(uriCfgValLock),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_WRITE
},
/* Characteristic user description */
{
attChUserDescUuid,
(uint8_t *) uriCfgValLockChrUsrDescr,
(uint16_t *) &uriCfgLenLockChrUsrDescr,
sizeof(uriCfgValLockChrUsrDescr) - 1,
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration */
{
attChUuid,
(uint8_t *) uriCfgValUnlockChr,
(uint16_t *) &uriCfgLenUnlockChr,
sizeof(uriCfgValUnlockChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
uriCfgUuidUnlock,
(uint8_t *) uriCfgValUnlock,
(uint16_t *) &uriCfgLenUnlock,
sizeof(uriCfgValUnlock),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_WRITE
},
/* Characteristic user description */
{
attChUserDescUuid,
(uint8_t *) uriCfgValUnlockChrUsrDescr,
(uint16_t *) &uriCfgLenUnlockChrUsrDescr,
sizeof(uriCfgValUnlockChrUsrDescr) - 1,
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration */
{
attChUuid,
(uint8_t *) uriCfgValUriDataChr,
(uint16_t *) &uriCfgLenUriDataChr,
sizeof(uriCfgValUriDataChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
uriCfgUuidUriData,
(uint8_t *) uriCfgValUriData,
(uint16_t *) &uriCfgLenUriData,
sizeof(uriCfgValUriData),
ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description */
{
attChUserDescUuid,
(uint8_t *) uriCfgValUriDataChrUsrDescr,
(uint16_t *) &uriCfgLenUriDataChrUsrDescr,
sizeof(uriCfgValUriDataChrUsrDescr) - 1,
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration */
{
attChUuid,
(uint8_t *) uriCfgValUriFlagsChr,
(uint16_t *) &uriCfgLenUriFlagsChr,
sizeof(uriCfgValUriFlagsChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
uriCfgUuidUriFlags,
(uint8_t *) uriCfgValUriFlags,
(uint16_t *) &uriCfgLenUriFlags,
sizeof(uriCfgValUriFlags),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description */
{
attChUserDescUuid,
(uint8_t *) uriCfgValUriFlagsChrUsrDescr,
(uint16_t *) &uriCfgLenUriFlagsChrUsrDescr,
sizeof(uriCfgValUriFlagsChrUsrDescr) - 1,
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration */
{
attChUuid,
(uint8_t *) uriCfgValAdvertisedTxPwrLevelsChr,
(uint16_t *) &uriCfgLenAdvertisedTxPwrLevelsChr,
sizeof(uriCfgValAdvertisedTxPwrLevelsChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
uriCfgUuidAdvertisedTxPwrLevels,
(uint8_t *) uriCfgValAdvertisedTxPwrLevels,
(uint16_t *) &uriCfgLenAdvertisedTxPwrLevels,
sizeof(uriCfgValAdvertisedTxPwrLevels),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description */
{
attChUserDescUuid,
(uint8_t *) uriCfgValAdvertisedTxPwrLevelsChrUsrDescr,
(uint16_t *) &uriCfgLenAdvertisedTxPwrLevelsChrUsrDescr,
sizeof(uriCfgValAdvertisedTxPwrLevelsChrUsrDescr) - 1,
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration */
{
attChUuid,
(uint8_t *) uriCfgValTxPwrModeChr,
(uint16_t *) &uriCfgLenTxPwrModeChr,
sizeof(uriCfgValTxPwrModeChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
uriCfgUuidTxPwrMode,
(uint8_t *) uriCfgValTxPwrMode,
(uint16_t *) &uriCfgLenTxPwrMode,
sizeof(uriCfgValTxPwrMode),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description */
{
attChUserDescUuid,
(uint8_t *) uriCfgValTxPwrModeChrUsrDescr,
(uint16_t *) &uriCfgLenTxPwrModeChrUsrDescr,
sizeof(uriCfgValTxPwrModeChrUsrDescr) - 1,
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration */
{
attChUuid,
(uint8_t *) uriCfgValBeaconPeriodChr,
(uint16_t *) &uriCfgLenBeaconPeriodChr,
sizeof(uriCfgValBeaconPeriodChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
uriCfgUuidBeaconPeriod,
(uint8_t *) uriCfgValBeaconPeriod,
(uint16_t *) &uriCfgLenBeaconPeriod,
sizeof(uriCfgValBeaconPeriod),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE
},
/* Characteristic user description */
{
attChUserDescUuid,
(uint8_t *) uriCfgValBeaconPeriodChrUsrDescr,
(uint16_t *) &uriCfgLenBeaconPeriodChrUsrDescr,
sizeof(uriCfgValBeaconPeriodChrUsrDescr) - 1,
0,
ATTS_PERMIT_READ
},
/* Characteristic declaration */
{
attChUuid,
(uint8_t *) uriCfgValResetChr,
(uint16_t *) &uriCfgLenResetChr,
sizeof(uriCfgValResetChr),
0,
ATTS_PERMIT_READ
},
/* Characteristic value */
{
uriCfgUuidReset,
(uint8_t *) uriCfgValReset,
(uint16_t *) &uriCfgLenReset,
sizeof(uriCfgValReset),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_WRITE
},
/* Characteristic user description */
{
attChUserDescUuid,
(uint8_t *) uriCfgValResetChrUsrDescr,
(uint16_t *) &uriCfgLenResetChrUsrDescr,
sizeof(uriCfgValResetChrUsrDescr) - 1,
0,
ATTS_PERMIT_READ
},
};
/* UriCfg group structure */
static attsGroup_t uriCfgGroup =
{
NULL,
(attsAttr_t *) uriCfgList,
NULL,
NULL,
URICFG_HANDLE_START,
URICFG_HANDLE_END
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcUriCfgAddGroup(void)
{;
AttsAddGroup(&uriCfgGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcUriCfgRemoveGroup(void)
{
AttsRemoveGroup(URICFG_HANDLE_START);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcUriCfgCbackRegister(attsWriteCback_t writeCback)
{
uriCfgGroup.writeCback = writeCback;
}
@@ -0,0 +1,134 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief UriCfg configuration service implementation.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_URICFG_H
#define SVC_URICFG_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup URICFG_CONFIGURATION_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name URI Config Service Handles
*
*/
/**@{*/
#define URICFG_HANDLE_START 0x80 /*!< \brief Start handle. */
#define URICFG_HANDLE_END (URICFG_HANDLE_END_PLUS_ONE - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief UriBeacon configuration service handles */
enum
{
URICFG_HANDLE_SVC = URICFG_HANDLE_START, /*!< \brief Service declaration. */
URICFG_HANDLE_LOCKSTATE_CHR, /*!< \brief Lock state characteristic declaration. */
URICFG_HANDLE_LOCKSTATE, /*!< \brief Lock state characteristic value. */
URICFG_HANDLE_LOCKSTATE_CHR_USR_DESCR, /*!< \brief Lock state characteristic user description. */
URICFG_HANDLE_LOCK_CHR, /*!< \brief Lock characteristic declaration. */
URICFG_HANDLE_LOCK, /*!< \brief Lock characteristic value. */
URICFG_HANDLE_LOCK_CHR_USR_DESCR, /*!< \brief Lock characteristic user declaration. */
URICFG_HANDLE_UNLOCK_CHR, /*!< \brief Unlock characteristic declaration. */
URICFG_HANDLE_UNLOCK, /*!< \brief Unlock characteristic value. */
URICFG_HANDLE_UNLOCK_CHR_USR_DESCR, /*!< \brief Unlock characteristic user description. */
URICFG_HANDLE_URIDATA_CHR, /*!< \brief URI data characteristic declaration. */
URICFG_HANDLE_URIDATA, /*!< \brief URI data characteristic value. */
URICFG_HANDLE_URIDATA_CHR_USR_DESCR, /*!< \brief URI data characteristic user description. */
URICFG_HANDLE_URIFLAGS_CHR, /*!< \brief URI flags characteristic declaration. */
URICFG_HANDLE_URIFLAGS, /*!< \brief URI flags characteristic value. */
URICFG_HANDLE_URIFLAGS_CHR_USR_DESCR, /*!< \brief URI flags characteristic user description. */
URICFG_HANDLE_TXPWRLEVELS_CHR, /*!< \brief Tx power levels characteristic declaration. */
URICFG_HANDLE_TXPWRLEVELS, /*!< \brief Tx power levels characteristic value. */
URICFG_HANDLE_TXPWRLEVELS_CHR_USR_DESCR, /*!< \brief Tx power levels characteristic user description. */
URICFG_HANDLE_TXPWRMODE_CHR, /*!< \brief Tx power mode characteristic declaration. */
URICFG_HANDLE_TXPWRMODE, /*!< \brief Tx power mode characteristic value. */
URICFG_HANDLE_TXPWRMODE_CHR_USR_DESCR, /*!< \brief Tx power mode characteristic user description. */
URICFG_HANDLE_BEACONPERIOD_CHR, /*!< \brief Beacon period characteristic declaration. */
URICFG_HANDLE_BEACONPERIOD, /*!< \brief Beacon period characteristic value. */
URICFG_HANDLE_BEACONPERIOD_CHR_USR_DESCR, /*!< \brief Beacon period characteristic user description. */
URICFG_HANDLE_RESET_CHR, /*!< \brief Reset characteristic declaration. */
URICFG_HANDLE_RESET, /*!< \brief Reset characteristic value. */
URICFG_HANDLE_RESET_CHR_USR_DESCR, /*!< \brief Reset characteristic user description. */
URICFG_HANDLE_END_PLUS_ONE /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcUriCfgAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcUriCfgRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcUriCfgCbackRegister(attsWriteCback_t writeCback);
/*! \} */ /* URICFG_CONFIGURATION_SERVICE */
#ifdef __cplusplus
}
#endif
#endif /* SVC_URICFG_H */
@@ -0,0 +1,284 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Wireless Data Exchange service implementation.
*
* Copyright (c) 2013-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "svc_wdxs.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef WDXS_SEC_PERMIT_READ
#define WDXS_SEC_PERMIT_READ ATTS_PERMIT_READ
#endif
/*! Characteristic write permissions */
#ifndef WDXS_SEC_PERMIT_WRITE
#define WDXS_SEC_PERMIT_WRITE ATTS_PERMIT_WRITE
#endif
/**************************************************************************************************
Global Variables
**************************************************************************************************/
/* UUIDs */
const uint8_t wdxsDcUuid[ATT_128_UUID_LEN] = {WDX_DC_UUID}; /* WDX Device Configuration Characteristic */
const uint8_t wdxsFtcUuid[ATT_128_UUID_LEN] = {WDX_FTC_UUID}; /* WDX File Transfer Control Characteristic */
const uint8_t wdxsFtdUuid[ATT_128_UUID_LEN] = {WDX_FTD_UUID}; /* WDX File Transfer Data Characteristic */
const uint8_t wdxsAuUuid[ATT_128_UUID_LEN] = {WDX_AU_UUID}; /* WDX Authentication Characteristic */
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Proprietary Service Declaration */
static const uint8_t wdxsValSvc[] = {UINT16_TO_BYTES(WDX_SVC_UUID)};
static const uint16_t wdxsLenSvc = sizeof(wdxsValSvc);
/* WDX Device Configuration Characteristic Declaration */
static const uint8_t wdxsValDcCh[] = {ATT_PROP_NOTIFY | ATT_PROP_WRITE, UINT16_TO_BYTES(WDXS_DC_HDL), WDX_DC_UUID};
static const uint16_t wdxsLenDcCh = sizeof(wdxsValDcCh);
/* WDX Device Configuration Characteristic Value */
/* Note these are dummy values */
static const uint8_t wdxsValDc[] = {0};
static const uint16_t wdxsLenDc = sizeof(wdxsValDc);
/* WDX Device Configuration CCCD */
static uint8_t wdxsValDcChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t wdxsLenDcChCcc = sizeof(wdxsValDcChCcc);
/* WDX File Transfer Control Characteristic Declaration */
static const uint8_t wdxsValFtcCh[] = {ATT_PROP_NOTIFY | ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(WDXS_FTC_HDL), WDX_FTC_UUID};
static const uint16_t wdxsLenFtcCh = sizeof(wdxsValFtcCh);
/* WDX File Transfer Control Characteristic Value */
/* Note these are dummy values */
static const uint8_t wdxsValFtc[] = {0};
static const uint16_t wdxsLenFtc = sizeof(wdxsValFtc);
/* WDX File Transfer Control CCCD */
static uint8_t wdxsValFtcChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t wdxsLenFtcChCcc = sizeof(wdxsValFtcChCcc);
/* WDX File Transfer Data Characteristic Declaration */
static const uint8_t wdxsValFtdCh[] = {ATT_PROP_NOTIFY | ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(WDXS_FTD_HDL), WDX_FTD_UUID};
static const uint16_t wdxsLenFtdCh = sizeof(wdxsValFtdCh);
/* WDX File Transfer Data Characteristic Value */
/* Note these are dummy values */
static const uint8_t wdxsValFtd[] = {0};
static const uint16_t wdxsLenFtd = sizeof(wdxsValFtd);
/* WDX File Transfer Data CCCD */
static uint8_t wdxsValFtdChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t wdxsLenFtdChCcc = sizeof(wdxsValFtdChCcc);
/* WDX Authentication Characteristic Declaration */
static const uint8_t wdxsValAuCh[] = {ATT_PROP_NOTIFY | ATT_PROP_WRITE, UINT16_TO_BYTES(WDXS_AU_HDL), WDX_AU_UUID};
static const uint16_t wdxsLenAuCh = sizeof(wdxsValAuCh);
/* WDX Authentication Characteristic Value */
/* Note these are dummy values */
static const uint8_t wdxsValAu[] = {0};
static const uint16_t wdxsLenAu = sizeof(wdxsValAu);
/* WDX Authentication CCCD */
static uint8_t wdxsValAuChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t wdxsLenAuChCcc = sizeof(wdxsValAuChCcc);
/* Attribute list for WDX group */
static const attsAttr_t wdxsList[] =
{
/* Service Delcaration */
{
attPrimSvcUuid,
(uint8_t *) wdxsValSvc,
(uint16_t *) &wdxsLenSvc,
sizeof(wdxsValSvc),
0,
ATTS_PERMIT_READ
},
/* WDX Device Configuration Characteristic Declaration */
{
attChUuid,
(uint8_t *) wdxsValDcCh,
(uint16_t *) &wdxsLenDcCh,
sizeof(wdxsValDcCh),
0,
ATTS_PERMIT_READ
},
/* WDX Device Configuration Characteristic Value */
{
wdxsDcUuid,
(uint8_t *) wdxsValDc,
(uint16_t *) &wdxsLenDc,
ATT_DEFAULT_PAYLOAD_LEN,
(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
WDXS_SEC_PERMIT_WRITE
},
/* WDX Device Configuration CCCD */
{
attCliChCfgUuid,
(uint8_t *) wdxsValDcChCcc,
(uint16_t *) &wdxsLenDcChCcc,
sizeof(wdxsValDcChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | WDXS_SEC_PERMIT_WRITE)
},
/* WDX File Transfer Control Characteristic Declaration */
{
attChUuid,
(uint8_t *) wdxsValFtcCh,
(uint16_t *) &wdxsLenFtcCh,
sizeof(wdxsValFtcCh),
0,
ATTS_PERMIT_READ
},
/* WDX File Transfer Control Characteristic Value */
{
wdxsFtcUuid,
(uint8_t *) wdxsValFtc,
(uint16_t *) &wdxsLenFtc,
ATT_DEFAULT_PAYLOAD_LEN,
(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
WDXS_SEC_PERMIT_WRITE
},
/* WDX File Transfer Control CCCD */
{
attCliChCfgUuid,
(uint8_t *) wdxsValFtcChCcc,
(uint16_t *) &wdxsLenFtcChCcc,
sizeof(wdxsValFtcChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | WDXS_SEC_PERMIT_WRITE)
},
/* WDX File Transfer Data Characteristic Declaration */
{
attChUuid,
(uint8_t *) wdxsValFtdCh,
(uint16_t *) &wdxsLenFtdCh,
sizeof(wdxsValFtdCh),
0,
ATTS_PERMIT_READ
},
/* WDX File Transfer Data Characteristic Value */
{
wdxsFtdUuid,
(uint8_t *) wdxsValFtd,
(uint16_t *) &wdxsLenFtd,
ATT_DEFAULT_PAYLOAD_LEN,
(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
WDXS_SEC_PERMIT_WRITE
},
/* WDX File Transfer Data CCCD */
{
attCliChCfgUuid,
(uint8_t *) wdxsValFtdChCcc,
(uint16_t *) &wdxsLenFtdChCcc,
sizeof(wdxsValFtdChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | WDXS_SEC_PERMIT_WRITE)
},
/* WDX Authentication Characteristic Declaration */
{
attChUuid,
(uint8_t *) wdxsValAuCh,
(uint16_t *) &wdxsLenAuCh,
sizeof(wdxsValAuCh),
0,
ATTS_PERMIT_READ
},
/* WDX Authentication Characteristic Value */
{
wdxsAuUuid,
(uint8_t *) wdxsValAu,
(uint16_t *) &wdxsLenAu,
ATT_DEFAULT_PAYLOAD_LEN,
(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
WDXS_SEC_PERMIT_WRITE
},
/* WDX Authentication CCCD */
{
attCliChCfgUuid,
(uint8_t *) wdxsValAuChCcc,
(uint16_t *) &wdxsLenAuChCcc,
sizeof(wdxsValAuChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | WDXS_SEC_PERMIT_WRITE)
}
};
/* WDX group structure */
static attsGroup_t svcWdxsGroup =
{
NULL,
(attsAttr_t *) wdxsList,
NULL,
NULL,
WDXS_START_HDL,
WDXS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWdxsAddGroup(void)
{
AttsAddGroup(&svcWdxsGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWdxsRemoveGroup(void)
{
AttsRemoveGroup(WDXS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register a write callback functions for the ATT Group.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWdxsRegister(attsWriteCback_t writeCback)
{
svcWdxsGroup.writeCback = writeCback;
}
@@ -0,0 +1,122 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Wireless Data Exchange service implementation.
*
* Copyright (c) 2013-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_WDXS_H
#define SVC_WDXS_H
#include "util/bstream.h"
#include "att_api.h"
#include "wdx_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup WIRELESS_DATA_EXCHANGE_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Arm Ltd. Proprietary Service Handles
*
*/
/**@{*/
#define WDXS_START_HDL 0x240 /*!< \brief Start handle. */
#define WDXS_END_HDL (WDXS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Proprietary Service Handles */
enum
{
WDXS_SVC_HDL = WDXS_START_HDL, /*!< \brief Proprietary Service Declaration */
WDXS_DC_CH_HDL, /*!< \brief WDX Device Configuration Characteristic Declaration */
WDXS_DC_HDL, /*!< \brief WDX Device Configuration Characteristic Value */
WDXS_DC_CH_CCC_HDL, /*!< \brief WDX Device Configuration CCCD */
WDXS_FTC_CH_HDL, /*!< \brief WDX File Transfer Control Characteristic Declaration */
WDXS_FTC_HDL, /*!< \brief WDX File Transfer Control Characteristic Value */
WDXS_FTC_CH_CCC_HDL, /*!< \brief WDX File Transfer Control CCCD */
WDXS_FTD_CH_HDL, /*!< \brief WDX File Transfer Data Characteristic Declaration */
WDXS_FTD_HDL, /*!< \brief WDX File Transfer Data Characteristic Value */
WDXS_FTD_CH_CCC_HDL, /*!< \brief WDX File Transfer Data CCCD */
WDXS_AU_CH_HDL, /*!< \brief WDX Authentication Characteristic Declaration */
WDXS_AU_HDL, /*!< \brief WDX Authentication Characteristic Value */
WDXS_AU_CH_CCC_HDL, /*!< \brief WDX Authentication CCCD */
WDXS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Global Declarations
**************************************************************************************************/
extern const uint8_t wdxsDcUuid[ATT_128_UUID_LEN]; /*!< \brief WDX Device Configuration Characteristic */
extern const uint8_t wdxsFtcUuid[ATT_128_UUID_LEN]; /*!< \brief WDX File Transfer Control Characteristic */
extern const uint8_t wdxsFtdUuid[ATT_128_UUID_LEN]; /*!< \brief WDX File Transfer Data Characteristic */
extern const uint8_t wdxsAuUuid[ATT_128_UUID_LEN]; /*!< \brief WDX Authentication Characteristic */
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWdxsAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWdxsRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register a write callback functions for the ATT Group.
*
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWdxsRegister(attsWriteCback_t writeCback);
/*! \} */ /* WIRELESS_DATA_EXCHANGE_SERVICE */
#ifdef __cplusplus
}
#endif
#endif /* SVC_WDXS_H */
@@ -0,0 +1,161 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief WP service implementation. Arm Ltd. proprietary servicde.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_wp.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef WP_SEC_PERMIT_READ
#define WP_SEC_PERMIT_READ SVC_SEC_PERMIT_READ
#endif
/*! Characteristic write permissions */
#ifndef WP_SEC_PERMIT_WRITE
#define WP_SEC_PERMIT_WRITE SVC_SEC_PERMIT_WRITE
#endif
/**************************************************************************************************
Static Variables
**************************************************************************************************/
/* UUIDs */
static const uint8_t svcDatUuid[] = {ATT_UUID_D1_DATA};
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Proprietary service declaration */
static const uint8_t wpValSvc[] = {ATT_UUID_P1_SERVICE};
static const uint16_t wpLenSvc = sizeof(wpValSvc);
/* Proprietary data characteristic */
static const uint8_t wpValDatCh[] = {ATT_PROP_NOTIFY | ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(WP_DAT_HDL), ATT_UUID_D1_DATA};
static const uint16_t wpLenDatCh = sizeof(wpValDatCh);
/* Proprietary data */
/* Note these are dummy values */
static const uint8_t wpValDat[] = {0};
static const uint16_t wpLenDat = sizeof(wpValDat);
/* Proprietary data client characteristic configuration */
static uint8_t wpValDatChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t wpLenDatChCcc = sizeof(wpValDatChCcc);
/* Attribute list for WP group */
static const attsAttr_t wpList[] =
{
{
attPrimSvcUuid,
(uint8_t *) wpValSvc,
(uint16_t *) &wpLenSvc,
sizeof(wpValSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) wpValDatCh,
(uint16_t *) &wpLenDatCh,
sizeof(wpValDatCh),
0,
ATTS_PERMIT_READ
},
{
svcDatUuid,
(uint8_t *) wpValDat,
(uint16_t *) &wpLenDat,
ATT_VALUE_MAX_LEN,
(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
WP_SEC_PERMIT_WRITE
},
{
attCliChCfgUuid,
(uint8_t *) wpValDatChCcc,
(uint16_t *) &wpLenDatChCcc,
sizeof(wpValDatChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | WP_SEC_PERMIT_WRITE)
}
};
/* WP group structure */
static attsGroup_t svcWpGroup =
{
NULL,
(attsAttr_t *) wpList,
NULL,
NULL,
WP_START_HDL,
WP_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWpAddGroup(void)
{
AttsAddGroup(&svcWpGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWpRemoveGroup(void)
{
AttsRemoveGroup(WP_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWpCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcWpGroup.readCback = readCback;
svcWpGroup.writeCback = writeCback;
}
@@ -0,0 +1,106 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief WP service implementation. Arm Ltd. proprietary servicde.
*
* Copyright (c) 2011-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_WP_H
#define SVC_WP_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup WP_SERVICE
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Arm Ltd. Proprietary Service Handles
*
*/
/**@{*/
/*! \brief Proprietary Service */
#define WP_START_HDL 0x200 /*!< \brief Start handle. */
#define WP_END_HDL (WP_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Proprietary Service Handles */
enum
{
WP_SVC_HDL = WP_START_HDL, /*!< \brief Proprietary service declaration */
WP_DAT_CH_HDL, /*!< \brief Proprietary data characteristic */
WP_DAT_HDL, /*!< \brief Proprietary data */
WP_DAT_CH_CCC_HDL, /*!< \brief Proprietary data client characteristic configuration */
WP_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWpAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWpRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWpCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*! \} */ /* WP_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_WP_H */
@@ -0,0 +1,184 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Weight Scale service implementation.
*
* Copyright (c) 2012-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "util/bstream.h"
#include "svc_ch.h"
#include "svc_wss.h"
#include "svc_cfg.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Characteristic read permissions */
#ifndef WSS_SEC_PERMIT_READ
#define WSS_SEC_PERMIT_READ (ATTS_PERMIT_READ | ATTS_PERMIT_READ_ENC)
#endif
/*! Characteristic write permissions */
#ifndef WSS_SEC_PERMIT_WRITE
#define WSS_SEC_PERMIT_WRITE (ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC)
#endif
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* Weight scale service declaration */
static const uint8_t wssValSvc[] = {UINT16_TO_BYTES(ATT_UUID_WEIGHT_SCALE_SERVICE)};
static const uint16_t wssLenSvc = sizeof(wssValSvc);
/* Weight measurement characteristic */
static const uint8_t wssValWmCh[] = {ATT_PROP_INDICATE, UINT16_TO_BYTES(WSS_WM_HDL), UINT16_TO_BYTES(ATT_UUID_WEIGHT_MEAS)};
static const uint16_t wssLenWmCh = sizeof(wssValWmCh);
/* Weight measurement */
/* Note these are dummy values */
static const uint8_t wssValWm[] = {0};
static const uint16_t wssLenWm = sizeof(wssValWm);
/* Weight measurement client characteristic configuration */
static uint8_t wssValWmChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t wssLenWmChCcc = sizeof(wssValWmChCcc);
/* Weight scale feature characteristic */
static const uint8_t wssValWsfCh[] = {ATT_PROP_READ, UINT16_TO_BYTES(WSS_WSF_HDL), UINT16_TO_BYTES(ATT_UUID_WEIGHT_SCALE_FEATURE)};
static const uint16_t wssLenWsfCh = sizeof(wssValWsfCh);
/* Weight scale feature */
static uint8_t wssValWsf[] = {UINT16_TO_BYTES(CH_WSF_FLAG_TIMESTAMP), 0x00, 0x00};
static const uint16_t wssLenWsf = sizeof(wssValWsf);
/* Attribute list for WSS group */
static const attsAttr_t wssList[] =
{
/* Weight scale service declaration */
{
attPrimSvcUuid,
(uint8_t *) wssValSvc,
(uint16_t *) &wssLenSvc,
sizeof(wssValSvc),
0,
ATTS_PERMIT_READ
},
/* Weight measurement characteristic */
{
attChUuid,
(uint8_t *) wssValWmCh,
(uint16_t *) &wssLenWmCh,
sizeof(wssValWmCh),
0,
ATTS_PERMIT_READ
},
/* Weight measurement */
{
attWmChUuid,
(uint8_t *) wssValWm,
(uint16_t *) &wssLenWm,
sizeof(wssValWm),
0,
0
},
/* Weight measurement client characteristic configuration */
{
attCliChCfgUuid,
(uint8_t *) wssValWmChCcc,
(uint16_t *) &wssLenWmChCcc,
sizeof(wssValWmChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | WSS_SEC_PERMIT_WRITE)
},
/* Weight scale feature characteristic */
{
attChUuid,
(uint8_t *) wssValWsfCh,
(uint16_t *) &wssLenWsfCh,
sizeof(wssValWsfCh),
0,
ATTS_PERMIT_READ
},
/* Weight scale feature */
{
attWsfChUuid,
wssValWsf,
(uint16_t *) &wssLenWsf,
sizeof(wssValWsf),
0,
WSS_SEC_PERMIT_READ
}
};
/* WSS group structure */
static attsGroup_t svcWssGroup =
{
NULL,
(attsAttr_t *) wssList,
NULL,
NULL,
WSS_START_HDL,
WSS_END_HDL
};
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWssAddGroup(void)
{
AttsAddGroup(&svcWssGroup);
}
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWssRemoveGroup(void)
{
AttsRemoveGroup(WSS_START_HDL);
}
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWssCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcWssGroup.readCback = readCback;
svcWssGroup.writeCback = writeCback;
}
@@ -0,0 +1,103 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Example Weight Scale service implementation.
*
* Copyright (c) 2012-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef SVC_WSS_H
#define SVC_WSS_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup WEIGHT_SCALE_SERVICE
* \{ */
/**************************************************************************************************
Handle Ranges
**************************************************************************************************/
/** \name Weight Scale Service Handles
*
*/
/**@{*/
#define WSS_START_HDL 0x0100 /*!< \brief Start handle. */
#define WSS_END_HDL (WSS_MAX_HDL - 1) /*!< \brief End handle. */
/**************************************************************************************************
Handles
**************************************************************************************************/
/*! \brief Weight Scale Service Handles */
enum
{
WSS_SVC_HDL = WSS_START_HDL, /*!< \brief Weight scale service declaration */
WSS_WM_CH_HDL, /*!< \brief Weight measurement characteristic */
WSS_WM_HDL, /*!< \brief Weight measurement */
WSS_WM_CH_CCC_HDL, /*!< \brief Weight measurement client characteristic configuration */
WSS_WSF_CH_HDL, /*!< \brief Weight scale feature characteristic */
WSS_WSF_HDL, /*!< \brief Weight scale feature */
WSS_MAX_HDL /*!< \brief Maximum handle. */
};
/**@}*/
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWssAddGroup(void);
/*************************************************************************************************/
/*!
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWssRemoveGroup(void);
/*************************************************************************************************/
/*!
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcWssCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
/*! \} */ /* WEIGHT_SCALE_SERVICE */
#ifdef __cplusplus
};
#endif
#endif /* SVC_WSS_H */