Skip to content
Snippets Groups Projects
Commit 9c1b4e55 authored by genofire's avatar genofire
Browse files

Merge branch 'ble-fileTrans-const-init' into 'master'

Ble file trans const init

See merge request card10/firmware!181
parents 76acf664 21a99831
No related branches found
No related tags found
No related merge requests found
...@@ -81,6 +81,7 @@ enum { ...@@ -81,6 +81,7 @@ enum {
static const uint8_t fileTransSvc[] = { FILE_TRANS_UUID_SUFFIX, static const uint8_t fileTransSvc[] = { FILE_TRANS_UUID_SUFFIX,
0x00, 0x00,
FILE_TRANS_UUID_PREFIX }; FILE_TRANS_UUID_PREFIX };
static const uint16_t fileTransSvc_len = sizeof(fileTransSvc);
/* BLE File transfer Central TX configuration */ /* BLE File transfer Central TX configuration */
static const uint8_t txChConfig[] = { ATT_PROP_WRITE_NO_RSP, static const uint8_t txChConfig[] = { ATT_PROP_WRITE_NO_RSP,
...@@ -89,6 +90,8 @@ static const uint8_t txChConfig[] = { ATT_PROP_WRITE_NO_RSP, ...@@ -89,6 +90,8 @@ static const uint8_t txChConfig[] = { ATT_PROP_WRITE_NO_RSP,
FILE_TRANS_UUID_SUFFIX, FILE_TRANS_UUID_SUFFIX,
0x01, 0x01,
FILE_TRANS_UUID_PREFIX }; FILE_TRANS_UUID_PREFIX };
static const uint16_t txChConfig_len = sizeof(txChConfig);
/* BLE File transfer Central TX UUID */ /* BLE File transfer Central TX UUID */
static const uint8_t attTxChConfigUuid[] = { FILE_TRANS_UUID_SUFFIX, static const uint8_t attTxChConfigUuid[] = { FILE_TRANS_UUID_SUFFIX,
0x01, 0x01,
...@@ -101,92 +104,75 @@ static const uint8_t rxChConfig[] = { ATT_PROP_READ | ATT_PROP_NOTIFY, ...@@ -101,92 +104,75 @@ static const uint8_t rxChConfig[] = { ATT_PROP_READ | ATT_PROP_NOTIFY,
FILE_TRANS_UUID_SUFFIX, FILE_TRANS_UUID_SUFFIX,
0x02, 0x02,
FILE_TRANS_UUID_PREFIX }; FILE_TRANS_UUID_PREFIX };
static const uint16_t rxChConfig_len = sizeof(rxChConfig);
/* BLE File transfer Central RX UUID */ /* BLE File transfer Central RX UUID */
static const uint8_t attRxChConfigUuid[] = { FILE_TRANS_UUID_SUFFIX, static const uint8_t attRxChConfigUuid[] = { FILE_TRANS_UUID_SUFFIX,
0x02, 0x02,
FILE_TRANS_UUID_PREFIX }; FILE_TRANS_UUID_PREFIX };
static uint8_t attRxChConfigValue[64];
static uint16_t attRxChConfigValue_len = 0;
/* File descriptor of the currently transferred file */ /* File descriptor of the currently transferred file */
static int file_fd = -1; static int file_fd = -1;
/* /* Attribute list for uriCfg group */
* Create the BLE service description. static const attsAttr_t fileTransCfgList[] = {
*/ /* Service declaration */
static void *fileTransAddGroupDyn(void)
{ {
void *pSHdl; .pUuid = attPrimSvcUuid,
uint8_t initCcc[] = { UINT16_TO_BYTES(0x0000) }; .pValue = (uint8_t *)fileTransSvc,
.pLen = (uint16_t *)&fileTransSvc_len,
/* Create the service */ .maxLen = sizeof(fileTransSvc),
pSHdl = AttsDynCreateGroup(FILE_TRANS_START_HDL, FILE_TRANS_END_HDL); .settings = 0,
.permissions = ATTS_PERMIT_READ,
if (pSHdl != NULL) { },
/* Primary service */
AttsDynAddAttrConst(
pSHdl,
attPrimSvcUuid,
fileTransSvc,
sizeof(fileTransSvc),
0,
ATTS_PERMIT_READ
);
/* File transfer Central TX characteristic */ /* File transfer Central TX characteristic */
AttsDynAddAttrConst( {
pSHdl, .pUuid = attChUuid,
attChUuid, .pValue = (uint8_t *)txChConfig,
txChConfig, .pLen = (uint16_t *)&txChConfig_len,
sizeof(txChConfig), .maxLen = sizeof(txChConfig),
0, .settings = 0,
ATTS_PERMIT_READ .permissions = ATTS_PERMIT_READ,
); },
/* File transfer Central TX, this contains information about the real data */ /* File transfer Central TX, this contains information about the real data */
AttsDynAddAttr( {
pSHdl, .pUuid = attTxChConfigUuid,
attTxChConfigUuid, .pValue = NULL,
NULL, .pLen = NULL,
0, .maxLen = 128,
128, .settings = ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN,
ATTS_SET_WRITE_CBACK | ATTS_SET_VARIABLE_LEN, .permissions = ATTS_PERMIT_WRITE,
ATTS_PERMIT_WRITE },
);
/* File transfer Central RX characteristic */ /* File transfer Central RX characteristic */
AttsDynAddAttrConst( {
pSHdl, .pUuid = attChUuid,
attChUuid, .pValue = (uint8_t *)rxChConfig,
rxChConfig, .pLen = (uint16_t *)&rxChConfig_len,
sizeof(rxChConfig), .maxLen = sizeof(rxChConfig),
0, .settings = 0,
ATTS_PERMIT_READ .permissions = ATTS_PERMIT_READ,
); },
/* File transfer Central RX, this contains information about the real data */ /* File transfer Central RX, this contains information about the real data */
AttsDynAddAttr( {
pSHdl, .pUuid = attRxChConfigUuid,
attRxChConfigUuid, .pValue = attRxChConfigValue,
NULL, .pLen = &attRxChConfigValue_len,
0, .maxLen = sizeof(attRxChConfigValue),
64, .settings = ATTS_SET_VARIABLE_LEN,
ATTS_SET_READ_CBACK, .permissions = ATTS_PERMIT_READ,
ATTS_PERMIT_READ },
);
/* File transfer Central RX notification channel */ /* File transfer Central RX notification channel */
AttsDynAddAttr( {
pSHdl, .pUuid = attCliChCfgUuid,
attCliChCfgUuid, .pValue = attRxChConfigValue,
initCcc, .pLen = &attRxChConfigValue_len,
sizeof(uint16_t), .maxLen = sizeof(attRxChConfigValue),
sizeof(uint16_t), .settings = ATTS_SET_CCC,
ATTS_SET_CCC, .permissions = ATTS_PERMIT_READ | ATTS_PERMIT_WRITE,
ATTS_PERMIT_READ | ATTS_PERMIT_WRITE },
); };
}
return pSHdl;
}
/** /**
* Send a repose with an optional CRC. * Send a repose with an optional CRC.
...@@ -413,22 +399,17 @@ static uint8_t writeCallback( ...@@ -413,22 +399,17 @@ static uint8_t writeCallback(
} }
} }
static uint8_t readCallback( static attsGroup_t fileTransCfgGroup = {
dmConnId_t connId, .pAttr = (attsAttr_t *)fileTransCfgList,
uint16_t handle, .writeCback = writeCallback,
uint8_t operation, .startHandle = FILE_TRANS_START_HDL,
uint16_t offset, .endHandle = FILE_TRANS_END_HDL,
attsAttr_t *pAttr };
) {
LOG_ERR("filetrans", "read callback\n");
return ATT_SUCCESS;
}
/* /*
* This registers and starts the BLE file transfer service. * This registers and starts the BLE file transfer service.
*/ */
void bleFileTransfer_init(void) void bleFileTransfer_init(void)
{ {
void *pSHdl = fileTransAddGroupDyn(); AttsAddGroup(&fileTransCfgGroup);
AttsDynRegister(pSHdl, readCallback, writeCallback);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment