Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hauke Mehrtens
firmware
Commits
5f39ee6b
Commit
5f39ee6b
authored
5 years ago
by
Hauke Mehrtens
Browse files
Options
Downloads
Patches
Plain Diff
BLE: file transfer: add delete caracteristik
parent
95657e11
No related branches found
No related tags found
No related merge requests found
Pipeline
#1565
passed
5 years ago
Stage: build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
epicardium/ble/ble_filetransfer.c
+56
-27
56 additions, 27 deletions
epicardium/ble/ble_filetransfer.c
with
56 additions
and
27 deletions
epicardium/ble/ble_filetransfer.c
+
56
−
27
View file @
5f39ee6b
...
...
@@ -53,17 +53,23 @@
enum
{
FILE_TRANS_SVC_HDL
=
FILE_TRANS_START_HDL
,
/*!< \brief File transfer service declaration */
FILE_TRANS_DATA_CH_HDL
,
/*!< \brief File transfer rx characteristic */
FILE_TRANS_DATA_HDL
,
/*!< \brief File transfer rx value */
FILE_TRANS_DATA_CH_HDL
,
/*!< \brief File transfer data characteristic */
FILE_TRANS_DATA_HDL
,
/*!< \brief File transfer data value */
FILE_TRANS_DELETE_CH_HDL
,
/*!< \brief File transfer delete characteristic */
FILE_TRANS_DELETE_HDL
,
/*!< \brief File transfer delete value */
FILE_TRANS_MAX_HDL
/*!< \brief Maximum handle. */
};
/* BLE File tra
s
nfer Service UUID */
/* BLE File tran
s
fer Service UUID */
static
const
uint8_t
fileTransSvc
[]
=
{
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x0
};
/* BLE File trasnfer characteristic configuration */
static
const
uint8_t
fileTransRxCh
[]
=
{
ATT_PROP_WRITE
,
UINT16_TO_BYTES
(
FILE_TRANS_DATA_HDL
),
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x1
};
/* BLE File trasnfer characteristic UUID */
static
const
uint8_t
attFileTransRxChUuid
[]
=
{
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x1
};
/* BLE File transfer data characteristic configuration */
static
const
uint8_t
fileTransDataCh
[]
=
{
ATT_PROP_WRITE
,
UINT16_TO_BYTES
(
FILE_TRANS_DATA_HDL
),
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x1
};
/* BLE File transfer data characteristic UUID */
static
const
uint8_t
attFileTransDataChUuid
[]
=
{
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x1
};
/* BLE File transfer delete characteristic configuration */
static
const
uint8_t
fileTransDeleteCh
[]
=
{
ATT_PROP_WRITE
,
UINT16_TO_BYTES
(
FILE_TRANS_DELETE_HDL
),
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x2
};
/* BLE File transfer delete characteristic UUID */
static
const
uint8_t
attFileTransDeleteChUuid
[]
=
{
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x23
,
0x42
,
0x2
};
/*
* Create the BLE service description.
...
...
@@ -80,11 +86,16 @@ static void *SvcFileTransAddGroupDyn(void)
/* Primary service */
AttsDynAddAttrConst
(
pSHdl
,
attPrimSvcUuid
,
fileTransSvc
,
sizeof
(
fileTransSvc
),
0
,
ATTS_PERMIT_READ
);
/* File transfer data characteristic */
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
fileTrans
Rx
Ch
,
sizeof
(
fileTrans
Rx
Ch
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
fileTrans
Data
Ch
,
sizeof
(
fileTrans
Data
Ch
),
0
,
ATTS_PERMIT_READ
);
/* File transfer data attribute, this contains information about the real data */
AttsDynAddAttr
(
pSHdl
,
attFileTransRxChUuid
,
NULL
,
0
,
128
,
AttsDynAddAttr
(
pSHdl
,
attFileTransDataChUuid
,
NULL
,
0
,
128
,
ATTS_SET_WRITE_CBACK
|
ATTS_SET_VARIABLE_LEN
,
ATTS_PERMIT_WRITE
);
/* File transfer delete characteristic */
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
fileTransDeleteCh
,
sizeof
(
fileTransDeleteCh
),
0
,
ATTS_PERMIT_READ
);
/* File transfer delete attribute, this contains information about the real data */
AttsDynAddAttr
(
pSHdl
,
attFileTransDeleteChUuid
,
NULL
,
0
,
64
,
ATTS_SET_WRITE_CBACK
|
ATTS_SET_VARIABLE_LEN
,
ATTS_PERMIT_WRITE
);
}
...
...
@@ -134,11 +145,12 @@ static uint8_t fileTransWrite(dmConnId_t connId, uint16_t handle, uint8_t operat
attsAttr_t
*
pAttr
)
{
uint32_t
fileOffset
;
FRESULT
res
;
char
filename
[
65
];
switch
(
handle
)
{
case
FILE_TRANS_DATA_HDL
:
{
/* The first 4 bytes are our mandatory offset. */
if
(
len
<
4
)
{
return
ATT_ERR_LENGTH
;
...
...
@@ -153,10 +165,27 @@ static uint8_t fileTransWrite(dmConnId_t connId, uint16_t handle, uint8_t operat
//printf("write execute request: %.*s, offset: %li\n", len - 4, pValue + 4, fileOffset);
fileTransWriteDataOffset
(
"mytest.py"
,
fileOffset
,
pValue
+
4
,
len
-
4
);
return
ATT_SUCCESS
;
}
return
ATT_ERR_NOT_SUP
;
case
FILE_TRANS_DELETE_HDL
:
snprintf
(
filename
,
sizeof
(
filename
),
"%.*s"
,
len
,
pValue
);
if
(
operation
==
ATT_PDU_PREP_WRITE_REQ
)
{
res
=
f_stat
(
filename
,
NULL
);
if
(
res
==
FR_OK
)
{
return
ATT_SUCCESS
;
}
else
{
return
ATT_ERR_VALUE_NOT_ALLOWED
;
}
}
else
if
(
operation
==
ATT_PDU_EXEC_WRITE_REQ
)
{
printf
(
"delete: %s
\n
"
,
filename
);
f_unlink
(
filename
);
return
ATT_SUCCESS
;
}
return
ATT_ERR_NOT_SUP
;
}
return
ATT_ERR_NOT_SUP
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment