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,253 @@
//*****************************************************************************
//
//! @file svc_amdtp.c
//!
//! @brief AM data transfer protocol service implementation
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "bstream.h"
#include "svc_ch.h"
#include "svc_amdtp.h"
#include "svc_cfg.h"
//*****************************************************************************
//
// Macro definitions
//
//*****************************************************************************
//#define SOME_MACRO 42 //!< This is the answer
//*****************************************************************************
//
// Global Variables
//
//*****************************************************************************
//uint32_t g_ui32Stuff;
/**************************************************************************************************
Static Variables
**************************************************************************************************/
/* UUIDs */
static const uint8_t svcRxUuid[] = {ATT_UUID_AMDTP_RX};
static const uint8_t svcTxUuid[] = {ATT_UUID_AMDTP_TX};
static const uint8_t svcAckUuid[] = {ATT_UUID_AMDTP_ACK};
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* AMDTP service declaration */
static const uint8_t amdtpSvc[] = {ATT_UUID_AMDTP_SERVICE};
static const uint16_t amdtpLenSvc = sizeof(amdtpSvc);
/* AMDTP RX characteristic */
static const uint8_t amdtpRxCh[] = {ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(AMDTPS_RX_HDL), ATT_UUID_AMDTP_RX};
static const uint16_t amdtpLenRxCh = sizeof(amdtpRxCh);
/* AMDTP TX characteristic */
static const uint8_t amdtpTxCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(AMDTPS_TX_HDL), ATT_UUID_AMDTP_TX};
static const uint16_t amdtpLenTxCh = sizeof(amdtpTxCh);
/* AMDTP RX ack characteristic */
static const uint8_t amdtpAckCh[] = {(ATT_PROP_WRITE_NO_RSP | ATT_PROP_NOTIFY), UINT16_TO_BYTES(AMDTPS_ACK_HDL), ATT_UUID_AMDTP_ACK};
static const uint16_t amdtpLenAckCh = sizeof(amdtpAckCh);
/* AMDTP RX data */
/* Note these are dummy values */
static const uint8_t amdtpRx[] = {0};
static const uint16_t amdtpLenRx = sizeof(amdtpRx);
/* AMDTP TX data */
/* Note these are dummy values */
static const uint8_t amdtpTx[] = {0};
static const uint16_t amdtpLenTx = sizeof(amdtpTx);
/* Proprietary data client characteristic configuration */
static uint8_t amdtpTxChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t amdtpLenTxChCcc = sizeof(amdtpTxChCcc);
/* AMDTP RX ack data */
/* Note these are dummy values */
static const uint8_t amdtpAck[] = {0};
static const uint16_t amdtpLenAck = sizeof(amdtpAck);
/* Proprietary data client characteristic configuration */
static uint8_t amdtpAckChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t amdtpLenAckChCcc = sizeof(amdtpAckChCcc);
/* Attribute list for AMDTP group */
static const attsAttr_t amdtpList[] =
{
{
attPrimSvcUuid,
(uint8_t *) amdtpSvc,
(uint16_t *) &amdtpLenSvc,
sizeof(amdtpSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) amdtpRxCh,
(uint16_t *) &amdtpLenRxCh,
sizeof(amdtpRxCh),
0,
ATTS_PERMIT_READ
},
{
svcRxUuid,
(uint8_t *) amdtpRx,
(uint16_t *) &amdtpLenRx,
ATT_VALUE_MAX_LEN,
(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
ATTS_PERMIT_WRITE
},
{
attChUuid,
(uint8_t *) amdtpTxCh,
(uint16_t *) &amdtpLenTxCh,
sizeof(amdtpTxCh),
0,
ATTS_PERMIT_READ
},
{
svcTxUuid,
(uint8_t *) amdtpTx,
(uint16_t *) &amdtpLenTx,
sizeof(amdtpTx), //ATT_VALUE_MAX_LEN,
0, //(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN),
0, //ATTS_PERMIT_READ
},
{
attCliChCfgUuid,
(uint8_t *) amdtpTxChCcc,
(uint16_t *) &amdtpLenTxChCcc,
sizeof(amdtpTxChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | ATTS_PERMIT_WRITE)
},
{
attChUuid,
(uint8_t *) amdtpAckCh,
(uint16_t *) &amdtpLenAckCh,
sizeof(amdtpAckCh),
0,
ATTS_PERMIT_READ
},
{
svcAckUuid,
(uint8_t *) amdtpAck,
(uint16_t *) &amdtpLenAck,
ATT_VALUE_MAX_LEN,
(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
ATTS_PERMIT_WRITE,
},
{
attCliChCfgUuid,
(uint8_t *) amdtpAckChCcc,
(uint16_t *) &amdtpLenAckChCcc,
sizeof(amdtpAckChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | ATTS_PERMIT_WRITE)
}
};
/* AMDTP group structure */
static attsGroup_t svcAmdtpGroup =
{
NULL,
(attsAttr_t *) amdtpList,
NULL,
NULL,
AMDTPS_START_HDL,
AMDTPS_END_HDL
};
/*************************************************************************************************/
/*!
* \fn SvcAmdtpsAddGroup
*
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcAmdtpsAddGroup(void)
{
AttsAddGroup(&svcAmdtpGroup);
}
/*************************************************************************************************/
/*!
* \fn SvcAmdtpRemoveGroup
*
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcAmdtpsRemoveGroup(void)
{
AttsRemoveGroup(AMDTPS_START_HDL);
}
/*************************************************************************************************/
/*!
* \fn SvcAmdtpsCbackRegister
*
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcAmdtpsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcAmdtpGroup.readCback = readCback;
svcAmdtpGroup.writeCback = writeCback;
}
@@ -0,0 +1,131 @@
//*****************************************************************************
//
//! @file svc_amdtps.h
//!
//! @brief AmbiqMicro Data Transfer Protocol service definition
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef SVC_AMDTPS_H
#define SVC_AMDTPS_H
//
// Put additional includes here if necessary.
//
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// Macro definitions
//
//*****************************************************************************
/*! Base UUID: 00002760-08C2-11E1-9073-0E8AC72EXXXX */
#define ATT_UUID_AMBIQ_BASE 0x2E, 0xC7, 0x8A, 0x0E, 0x73, 0x90, \
0xE1, 0x11, 0xC2, 0x08, 0x60, 0x27, 0x00, 0x00
/*! Macro for building Ambiq UUIDs */
#define ATT_UUID_AMBIQ_BUILD(part) UINT16_TO_BYTES(part), ATT_UUID_AMBIQ_BASE
/*! Partial amdtp service UUIDs */
#define ATT_UUID_AMDTP_SERVICE_PART 0x1011
/*! Partial amdtp rx characteristic UUIDs */
#define ATT_UUID_AMDTP_RX_PART 0x0011
/*! Partial amdtp tx characteristic UUIDs */
#define ATT_UUID_AMDTP_TX_PART 0x0012
/*! Partial amdtp ack characteristic UUIDs */
#define ATT_UUID_AMDTP_ACK_PART 0x0013
/* Amdtp services */
#define ATT_UUID_AMDTP_SERVICE ATT_UUID_AMBIQ_BUILD(ATT_UUID_AMDTP_SERVICE_PART)
/* Amdtp characteristics */
#define ATT_UUID_AMDTP_RX ATT_UUID_AMBIQ_BUILD(ATT_UUID_AMDTP_RX_PART)
#define ATT_UUID_AMDTP_TX ATT_UUID_AMBIQ_BUILD(ATT_UUID_AMDTP_TX_PART)
#define ATT_UUID_AMDTP_ACK ATT_UUID_AMBIQ_BUILD(ATT_UUID_AMDTP_ACK_PART)
// AM DTP Service
#define AMDTPS_START_HDL 0x0800//0x300
#define AMDTPS_END_HDL (AMDTPS_MAX_HDL - 1)
/* AMDTP Service Handles */
enum
{
AMDTP_SVC_HDL = AMDTPS_START_HDL, /* AMDTP service declaration */
AMDTPS_RX_CH_HDL, /* AMDTP write command characteristic */
AMDTPS_RX_HDL, /* AMDTP write command data */
AMDTPS_TX_CH_HDL, /* AMDTP notify characteristic */
AMDTPS_TX_HDL, /* AMDTP notify data */
AMDTPS_TX_CH_CCC_HDL, /* AMDTP notify client characteristic configuration */
AMDTPS_ACK_CH_HDL, /* AMDTP rx ack characteristic */
AMDTPS_ACK_HDL, /* AMDTP rx ack data */
AMDTPS_ACK_CH_CCC_HDL, /* AMDTP rx ack client characteristic configuration */
AMDTPS_MAX_HDL
};
//*****************************************************************************
//
// External variable definitions
//
//*****************************************************************************
//extern uint32_t g_ui32Stuff;
//*****************************************************************************
//
// Function definitions.
//
//*****************************************************************************
void SvcAmdtpsAddGroup(void);
void SvcAmdtpsRemoveGroup(void);
void SvcAmdtpsCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
#ifdef __cplusplus
}
#endif
#endif // SVC_AMDTPS_H
@@ -0,0 +1,215 @@
//*****************************************************************************
//
//! @file svc_amotas.c
//!
//! @brief AM OTA service implementation
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "bstream.h"
#include "svc_ch.h"
#include "svc_amotas.h"
#include "svc_cfg.h"
//*****************************************************************************
//
// Macro definitions
//
//*****************************************************************************
//#define SOME_MACRO 42 //!< This is the answer
//*****************************************************************************
//
// Global Variables
//
//*****************************************************************************
//uint32_t g_ui32Stuff;
/**************************************************************************************************
Static Variables
**************************************************************************************************/
/* UUIDs */
static const uint8_t svcRxUuid[] = {ATT_UUID_AMOTA_RX};
static const uint8_t svcTxUuid[] = {ATT_UUID_AMOTA_TX};
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* AMOTA service declaration */
static const uint8_t amotaSvc[] = {ATT_UUID_AMOTA_SERVICE};
static const uint16_t amotaLenSvc = sizeof(amotaSvc);
/* AMOTA RX characteristic */
static const uint8_t amotaRxCh[] = {ATT_PROP_WRITE_NO_RSP, UINT16_TO_BYTES(AMOTAS_RX_HDL), ATT_UUID_AMOTA_RX};
static const uint16_t amotaLenRxCh = sizeof(amotaRxCh);
/* AMOTA TX characteristic */
static const uint8_t amotaTxCh[] = {ATT_PROP_NOTIFY, UINT16_TO_BYTES(AMOTAS_TX_HDL), ATT_UUID_AMOTA_TX};
static const uint16_t amotaLenTxCh = sizeof(amotaTxCh);
/* AMOTA RX data */
/* Note these are dummy values */
static const uint8_t amotaRx[] = {0};
static const uint16_t amotaLenRx = sizeof(amotaRx);
/* AMOTA TX data */
/* Note these are dummy values */
static const uint8_t amotaTx[] = {0};
static const uint16_t amotaLenTx = sizeof(amotaTx);
/* Proprietary data client characteristic configuration */
static uint8_t amotaTxChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t amotaLenTxChCcc = sizeof(amotaTxChCcc);
/* Attribute list for AMOTA group */
static const attsAttr_t amotaList[] =
{
{
attPrimSvcUuid,
(uint8_t *) amotaSvc,
(uint16_t *) &amotaLenSvc,
sizeof(amotaSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) amotaRxCh,
(uint16_t *) &amotaLenRxCh,
sizeof(amotaRxCh),
0,
ATTS_PERMIT_READ
},
{
svcRxUuid,
(uint8_t *) amotaRx,
(uint16_t *) &amotaLenRx,
ATT_VALUE_MAX_LEN,
(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
ATTS_PERMIT_WRITE
},
{
attChUuid,
(uint8_t *) amotaTxCh,
(uint16_t *) &amotaLenTxCh,
sizeof(amotaTxCh),
0,
ATTS_PERMIT_READ
},
{
svcTxUuid,
(uint8_t *) amotaTx,
(uint16_t *) &amotaLenTx,
ATT_VALUE_MAX_LEN,
(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN),
ATTS_PERMIT_READ
},
{
attCliChCfgUuid,
(uint8_t *) amotaTxChCcc,
(uint16_t *) &amotaLenTxChCcc,
sizeof(amotaTxChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | ATTS_PERMIT_WRITE)
}
};
/* AMOTA group structure */
static attsGroup_t svcAmotaGroup =
{
NULL,
(attsAttr_t *) amotaList,
NULL,
NULL,
AMOTAS_START_HDL,
AMOTAS_END_HDL
};
/*************************************************************************************************/
/*!
* \fn SvcAmotasAddGroup
*
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcAmotasAddGroup(void)
{
AttsAddGroup(&svcAmotaGroup);
}
/*************************************************************************************************/
/*!
* \fn SvcAmotaRemoveGroup
*
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcAmotasRemoveGroup(void)
{
AttsRemoveGroup(AMOTAS_START_HDL);
}
/*************************************************************************************************/
/*!
* \fn SvcAmotasCbackRegister
*
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcAmotasCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcAmotaGroup.readCback = readCback;
svcAmotaGroup.writeCback = writeCback;
}
@@ -0,0 +1,124 @@
//*****************************************************************************
//
//! @file svc_amotas.h
//!
//! @brief AmbiqMicro OTA service definition
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2020, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 2.4.2 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef SVC_AMOTAS_H
#define SVC_AMOTAS_H
//
// Put additional includes here if necessary.
//
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// Macro definitions
//
//*****************************************************************************
/*! Base UUID: 00002760-08C2-11E1-9073-0E8AC72EXXXX */
#define ATT_UUID_AMBIQ_BASE 0x2E, 0xC7, 0x8A, 0x0E, 0x73, 0x90, \
0xE1, 0x11, 0xC2, 0x08, 0x60, 0x27, 0x00, 0x00
/*! Macro for building Ambiq UUIDs */
#define ATT_UUID_AMBIQ_BUILD(part) UINT16_TO_BYTES(part), ATT_UUID_AMBIQ_BASE
/*! Partial amota service UUIDs */
#define ATT_UUID_AMOTA_SERVICE_PART 0x1001
/*! Partial amota rx characteristic UUIDs */
#define ATT_UUID_AMOTA_RX_PART 0x0001
/*! Partial amota tx characteristic UUIDs */
#define ATT_UUID_AMOTA_TX_PART 0x0002
/* Amota services */
#define ATT_UUID_AMOTA_SERVICE ATT_UUID_AMBIQ_BUILD(ATT_UUID_AMOTA_SERVICE_PART)
/* Amota characteristics */
#define ATT_UUID_AMOTA_RX ATT_UUID_AMBIQ_BUILD(ATT_UUID_AMOTA_RX_PART)
#define ATT_UUID_AMOTA_TX ATT_UUID_AMBIQ_BUILD(ATT_UUID_AMOTA_TX_PART)
// AM OTA Service
#define AMOTAS_START_HDL 0x300
#define AMOTAS_END_HDL (AMOTAS_MAX_HDL - 1)
/* AMOTA Service Handles */
enum
{
AMOTA_SVC_HDL = AMOTAS_START_HDL, /* AMOTA service declaration */
AMOTAS_RX_CH_HDL, /* AMOTA write command characteristic */
AMOTAS_RX_HDL, /* AMOTA write command data */
AMOTAS_TX_CH_HDL, /* AMOTA notify characteristic */
AMOTAS_TX_HDL, /* AMOTA notify data */
AMOTAS_TX_CH_CCC_HDL, /* AMOTA notify client characteristic configuration */
AMOTAS_MAX_HDL
};
//*****************************************************************************
//
// External variable definitions
//
//*****************************************************************************
//extern uint32_t g_ui32Stuff;
//*****************************************************************************
//
// Function definitions.
//
//*****************************************************************************
void SvcAmotasAddGroup(void);
void SvcAmotasRemoveGroup(void);
void SvcAmotasCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
#ifdef __cplusplus
}
#endif
#endif // SVC_AMOTAS_H
@@ -0,0 +1,224 @@
//*****************************************************************************
//
//! @file svc_amvole.c
//!
//! @brief AM Voice Over LE service implementation
//!
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2018, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 1.2.12 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#include "wsf_types.h"
#include "att_api.h"
#include "wsf_trace.h"
#include "bstream.h"
#include "svc_ch.h"
#include "svc_amvole.h"
#include "svc_cfg.h"
//*****************************************************************************
//
// Macro definitions
//
//*****************************************************************************
//#define SOME_MACRO 42 //!< This is the answer
//*****************************************************************************
//
// Global Variables
//
//*****************************************************************************
/**************************************************************************************************
Static Variables
**************************************************************************************************/
/* UUIDs */
static const uint8_t svcRxUuid[] = {ATT_UUID_VOLES_RX};
static const uint8_t svcTxUuid[] = {ATT_UUID_VOLES_TX};
/**************************************************************************************************
Service variables
**************************************************************************************************/
/* VOLES service declaration */
static const uint8_t amvoleSvc[] = {ATT_UUID_VOLES_SERVICE};
static const uint16_t amvoleLenSvc = sizeof(amvoleSvc);
/* VOLES RX characteristic */
static const uint8_t amvoleRxCh[] = {ATT_PROP_WRITE, UINT16_TO_BYTES(VOLES_RX_HDL), ATT_UUID_VOLES_RX};
static const uint16_t amvoleLenRxCh = sizeof(amvoleRxCh);
/* VOLES TX characteristic */
static const uint8_t amvoleTxCh[] = {ATT_PROP_NOTIFY | ATT_PROP_READ, UINT16_TO_BYTES(VOLES_TX_HDL), ATT_UUID_VOLES_TX};
static const uint16_t amvoleLenTxCh = sizeof(amvoleTxCh);
/* VOLES RX data */
/* Note these are dummy values */
static const uint8_t amvoleRx[] = {0};
static const uint16_t amvoleLenRx = sizeof(amvoleRx);
/* VOLES TX data */
/* Note these are dummy values */
static const uint8_t amvoleTx[] = {0};
static const uint16_t amvoleLenTx = sizeof(amvoleTx);
/* Proprietary data client characteristic configuration */
static uint8_t amvoleTxChCcc[] = {UINT16_TO_BYTES(0x0000)};
static const uint16_t amvoleLenTxChCcc = sizeof(amvoleTxChCcc);
/* Attribute list for VOLES group */
static const attsAttr_t amvoleList[] =
{
{
attPrimSvcUuid,
(uint8_t *) amvoleSvc,
(uint16_t *) &amvoleLenSvc,
sizeof(amvoleSvc),
0,
ATTS_PERMIT_READ
},
{
attChUuid,
(uint8_t *) amvoleRxCh,
(uint16_t *) &amvoleLenRxCh,
sizeof(amvoleRxCh),
0,
ATTS_PERMIT_READ
},
{
svcRxUuid,
(uint8_t *) amvoleRx,
(uint16_t *) &amvoleLenRx,
ATT_VALUE_MAX_LEN,
(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK),
ATTS_PERMIT_WRITE
//ATTS_PERMIT_WRITE_ENC
},
{
attChUuid,
(uint8_t *) amvoleTxCh,
(uint16_t *) &amvoleLenTxCh,
sizeof(amvoleTxCh),
0,
ATTS_PERMIT_READ
},
{
svcTxUuid,
(uint8_t *) amvoleTx,
(uint16_t *) &amvoleLenTx,
sizeof(amvoleTx), //ATT_VALUE_MAX_LEN,
#if 0
#if USE_OUTPUT_VOLES_AMA
(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN),
ATTS_PERMIT_READ
#else
0, //(ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN),
0 //ATTS_PERMIT_READ
#endif
#endif
(ATTS_SET_UUID_128),
ATTS_PERMIT_READ
},
{
attCliChCfgUuid,
(uint8_t *) amvoleTxChCcc,
(uint16_t *) &amvoleLenTxChCcc,
sizeof(amvoleTxChCcc),
ATTS_SET_CCC,
(ATTS_PERMIT_READ | ATTS_PERMIT_WRITE)
}
};
/* VOLES group structure */
static attsGroup_t svcVolesGroup =
{
NULL,
(attsAttr_t *) amvoleList,
NULL,
NULL,
VOLES_START_HDL,
VOLES_END_HDL
};
/*************************************************************************************************/
/*!
* \fn SvcVolesAddGroup
*
* \brief Add the services to the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcVolesAddGroup(void)
{
AttsAddGroup(&svcVolesGroup);
}
/*************************************************************************************************/
/*!
* \fn SvcVolesRemoveGroup
*
* \brief Remove the services from the attribute server.
*
* \return None.
*/
/*************************************************************************************************/
void SvcVolesRemoveGroup(void)
{
AttsRemoveGroup(VOLES_START_HDL);
}
/*************************************************************************************************/
/*!
* \fn SvcVolesCbackRegister
*
* \brief Register callbacks for the service.
*
* \param readCback Read callback function.
* \param writeCback Write callback function.
*
* \return None.
*/
/*************************************************************************************************/
void SvcVolesCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback)
{
svcVolesGroup.readCback = readCback;
svcVolesGroup.writeCback = writeCback;
}
@@ -0,0 +1,107 @@
//*****************************************************************************
//
//! @file svc_amvole.h
//!
//! @brief AmbiqMicro Voice Over LE service definition
//
//*****************************************************************************
//*****************************************************************************
//
// Copyright (c) 2018, Ambiq Micro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// Third party software included in this distribution is subject to the
// additional license terms as defined in the /docs/licenses directory.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// This is part of revision 1.2.12 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef SVC_VOLES_H
#define SVC_VOLES_H
//
// Put additional includes here if necessary.
//
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// Macro definitions
//
//*****************************************************************************
/* AMA services */
#define ATT_UUID_VOLES_SERVICE 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x03, 0xFE, 0x00, 0x00
/* VOLE characteristics */
#define ATT_UUID_VOLES_RX 0x76, 0x30, 0xF8, 0xDD, 0x90, 0xA3, 0x61, 0xAC, 0xA7, 0x43, 0x05, 0x30, 0x77, 0xB1, 0x4E, 0xF0
#define ATT_UUID_VOLES_TX 0x0B, 0x42, 0x82, 0x1F, 0x64, 0x72, 0x2F, 0x8A, 0xB4, 0x4B, 0x79, 0x18, 0x5B, 0xA0, 0xEE, 0x2B
#define VOLES_START_HDL 0x0800//0x300
#define VOLES_END_HDL (VOLES_MAX_HDL - 1)
/* VOLE Service Handles */
enum
{
VOLES_SVC_HDL = VOLES_START_HDL, /* VOLE service declaration */
VOLES_RX_CH_HDL, /* VOLE write command characteristic */
VOLES_RX_HDL, /* VOLE write command data */
VOLES_TX_CH_HDL, /* VOLE notify characteristic */
VOLES_TX_HDL, /* VOLE notify data */
VOLES_TX_CH_CCC_HDL, /* VOLE notify client characteristic configuration */
VOLES_MAX_HDL
};
//*****************************************************************************
//
// External variable definitions
//
//*****************************************************************************
//*****************************************************************************
//
// Function definitions.
//
//*****************************************************************************
void SvcVolesAddGroup(void);
void SvcVolesRemoveGroup(void);
void SvcVolesCbackRegister(attsReadCback_t readCback, attsWriteCback_t writeCback);
#ifdef __cplusplus
}
#endif
#endif // SVC_VOLES_H