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
swym
firmware
Commits
6fc005ec
Verified
Commit
6fc005ec
authored
5 years ago
by
genofire
Browse files
Options
Downloads
Patches
Plain Diff
ble: card10 svc - personal state
parent
dd3a665c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
epicardium/ble/card10.c
+79
-1
79 additions, 1 deletion
epicardium/ble/card10.c
epicardium/epicardium.h
+2
-0
2 additions, 0 deletions
epicardium/epicardium.h
with
81 additions
and
1 deletion
epicardium/ble/card10.c
+
79
−
1
View file @
6fc005ec
...
...
@@ -59,6 +59,9 @@ enum {
/*!< \brief flashlight characteristic */
CARD10_FLASHLIGHT_CH_HDL
,
CARD10_FLASHLIGHT_VAL_HDL
,
/*!< \brief flashlight characteristic */
CARD10_PERSONAL_STATE_CH_HDL
,
CARD10_PERSONAL_STATE_VAL_HDL
,
/*!< \brief leds above characteristic */
CARD10_LEDS_ABOVE_CH_HDL
,
CARD10_LEDS_ABOVE_VAL_HDL
,
...
...
@@ -204,6 +207,20 @@ static const uint8_t UUID_attChar_flashlight[] = {
CARD10_UUID_SUFFIX
,
0x18
,
CARD10_UUID_PREFIX
};
/* BLE UUID for card10 personal state */
static
const
uint8_t
UUID_char_personal_state
[]
=
{
ATT_PROP_READ
|
ATT_PROP_WRITE
,
UINT16_TO_BYTES
(
CARD10_PERSONAL_STATE_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x19
,
CARD10_UUID_PREFIX
};
static
const
uint8_t
UUID_attChar_personal_state
[]
=
{
CARD10_UUID_SUFFIX
,
0x19
,
CARD10_UUID_PREFIX
};
static
uint8_t
personalStateValue
=
0
;
static
uint16_t
personalStateLen
=
sizeof
(
personalStateValue
);
/* BLE UUID for card10 above leds */
static
const
uint8_t
UUID_char_leds_above
[]
=
{
ATT_PROP_WRITE_NO_RSP
,
...
...
@@ -443,6 +460,27 @@ static const attsAttr_t card10SvcAttrList[] =
ATTS_PERMIT_WRITE_AUTH
)
},
// personal state
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_personal_state
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_personal_state
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_personal_state
,
.
pValue
=
&
personalStateValue
,
.
pLen
=
&
personalStateLen
,
.
maxLen
=
sizeof
(
uint16_t
),
.
settings
=
(
ATTS_SET_WRITE_CBACK
|
ATTS_SET_READ_CBACK
),
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
|
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
ATTS_PERMIT_READ_AUTH
)
},
// ABOVE LEDS
{
...
...
@@ -461,7 +499,7 @@ static const attsAttr_t card10SvcAttrList[] =
ATTS_PERMIT_WRITE_AUTH
)
},
//
ABOVE LEDS
//
Light sensor
{
.
pUuid
=
attChUuid
,
...
...
@@ -654,6 +692,41 @@ static uint8_t writeCard10CB(
epic_set_flashlight
(
pValue
[
0
]);
APP_TRACE_INFO1
(
"set flashlight to: %d
\n
"
,
pValue
[
0
]);
return
ATT_SUCCESS
;
// personal state
case
CARD10_PERSONAL_STATE_VAL_HDL
:
BYTES_TO_UINT16
(
ui16
,
pValue
);
if
(
ui16
<=
STATE_MAX
)
{
if
(
operation
==
ATT_PDU_WRITE_CMD
||
operation
==
ATT_PDU_SIGNED_WRITE_CMD
||
operation
==
ATT_PDU_WRITE_REQ
||
operation
==
ATT_PDU_EXEC_WRITE_REQ
)
{
epic_personal_state_set
(
ui16
,
true
);
APP_TRACE_INFO1
(
"ble-card10: set personal state to: %d
\n
"
,
ui16
);
return
ATT_SUCCESS
;
}
else
if
(
operation
==
ATT_PDU_PREP_WRITE_REQ
)
{
APP_TRACE_INFO1
(
"ble_card10: personal state would be okay: %d
\n
"
,
ui16
);
return
ATT_SUCCESS
;
}
else
{
APP_TRACE_INFO1
(
"ble-card10: personal state with unknown operation: %d
\n
"
,
operation
);
return
ATT_ERR_INVALID_PDU
;
}
}
else
{
APP_TRACE_INFO2
(
"ble-card: personal state invalid value (0-%d): %d
\n
"
,
STATE_MAX
-
1
,
ui16
);
return
ATT_ERR_RANGE
;
}
// leds above
case
CARD10_LEDS_ABOVE_VAL_HDL
:
for
(
ui16
=
0
;
ui16
<
11
;
ui16
++
)
{
...
...
@@ -693,6 +766,11 @@ static uint8_t readCard10CB(
uint16_t
ui16
=
0
;
switch
(
handle
)
{
case
CARD10_PERSONAL_STATE_VAL_HDL
:
ui16
=
epic_personal_state_get
();
*
pAttr
->
pValue
=
ui16
;
APP_TRACE_INFO1
(
"ble-card10: read personal state: %d
\n
"
,
ui16
);
return
ATT_SUCCESS
;
case
CARD10_LIGHT_SENSOR_VAL_HDL
:
epic_light_sensor_get
(
&
ui16
);
*
pAttr
->
pValue
=
ui16
;
...
...
This diff is collapsed.
Click to expand it.
epicardium/epicardium.h
+
2
−
0
View file @
6fc005ec
...
...
@@ -820,6 +820,8 @@ enum personal_state {
STATE_COMMUNICATION
=
3
,
/** ``4``, "camp" - I am focussed on self-, camp-, or community maintenance - yellow led, fade on and off. */
STATE_CAMP
=
4
,
/** STATE_MAX gives latest value and count of possible STATEs**/
STATE_MAX
=
5
,
};
/**
...
...
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