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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dos
firmware
Commits
7d7b6816
Commit
7d7b6816
authored
5 years ago
by
Hauke Mehrtens
Browse files
Options
Downloads
Plain Diff
Merge branch 'genofire/ble-rewrite' into 'master'
ble: card10 svc - rewrite Closes
#84
See merge request
!151
parents
9c1b4e55
f725fd98
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Documentation/bluetooth/card10.rst
+13
-13
13 additions, 13 deletions
Documentation/bluetooth/card10.rst
epicardium/ble/card10.c
+335
-329
335 additions, 329 deletions
epicardium/ble/card10.c
with
348 additions
and
342 deletions
Documentation/bluetooth/card10.rst
+
13
−
13
View file @
7d7b6816
...
@@ -18,67 +18,67 @@ The current draft uses following service specification:
...
@@ -18,67 +18,67 @@ The current draft uses following service specification:
- Time update characteristic:
- Time update characteristic:
UUID: ``42230201-2342-2342-2342-234223422342``
UUID: ``42230201-2342-2342-2342-234223422342``
write
write
no response
- Vibra characteristic:
- Vibra characteristic:
UUID: ``4223020f-2342-2342-2342-234223422342``
UUID: ``4223020f-2342-2342-2342-234223422342``
write
write
no response
- Rockets characteristic:
- Rockets characteristic:
UUID: ``42230210-2342-2342-2342-234223422342``
UUID: ``42230210-2342-2342-2342-234223422342``
write
write
no response
- Background LED Bottom Left characteristic:
- Background LED Bottom Left characteristic:
UUID: ``42230211-2342-2342-2342-234223422342``
UUID: ``42230211-2342-2342-2342-234223422342``
write
write
no response
- Background LED Bottom Right characteristic:
- Background LED Bottom Right characteristic:
UUID: ``42230212-2342-2342-2342-234223422342``
UUID: ``42230212-2342-2342-2342-234223422342``
write
write
no response
- Background LED Top Right characteristic:
- Background LED Top Right characteristic:
UUID: ``42230213-2342-2342-2342-234223422342``
UUID: ``42230213-2342-2342-2342-234223422342``
write
write
no response
- Background LED Top Left characteristic:
- Background LED Top Left characteristic:
UUID: ``42230214-2342-2342-2342-234223422342``
UUID: ``42230214-2342-2342-2342-234223422342``
write
write
no reponse
- LEDS dim bottom characteristic:
- LEDS dim bottom characteristic:
UUID: ``42230215-2342-2342-2342-234223422342``
UUID: ``42230215-2342-2342-2342-234223422342``
write
write
with response
- LEDs dim top characteristic:
- LEDs dim top characteristic:
UUID: ``42230216-2342-2342-2342-234223422342``
UUID: ``42230216-2342-2342-2342-234223422342``
write
write
with response
- LEDs powersafe characteristic:
- LEDs powersafe characteristic:
UUID: ``42230217-2342-2342-2342-234223422342``
UUID: ``42230217-2342-2342-2342-234223422342``
write
write
no response
- Flashlight characteristic:
- Flashlight characteristic:
UUID: ``42230218-2342-2342-2342-234223422342``
UUID: ``42230218-2342-2342-2342-234223422342``
write
write
no response
- LEDs above characteristic:
- LEDs above characteristic:
UUID: ``42230220-2342-2342-2342-234223422342``
UUID: ``42230220-2342-2342-2342-234223422342``
write
write
no reponse
- Light sensor characteristic:
- Light sensor characteristic:
UUID: ``422302f0-2342-2342-2342-234223422342``
UUID: ``422302f0-2342-2342-2342-234223422342``
read
read
no response
Time update characteristic
Time update characteristic
---------------------------------
---------------------------------
...
...
This diff is collapsed.
Click to expand it.
epicardium/ble/card10.c
+
335
−
329
View file @
7d7b6816
#include
"wsf_types.h"
#include
"wsf_types.h"
#include
"wsf_os.h"
#include
"wsf_buf.h"
#include
"wsf_timer.h"
#include
"wsf_trace.h"
#include
"app_ui.h"
#include
"fit/fit_api.h"
#include
"hci_vs.h"
#include
"ff.h"
#include
"util/bstream.h"
#include
"util/bstream.h"
#include
"wsf_assert.h"
#include
"att_api.h"
#include
"att_api.h"
#include
"FreeRTOS.h"
#include
"crc32.h"
#include
"epicardium.h"
#include
"epicardium.h"
#include
<stdio.h>
#include
<stdio.h>
...
@@ -85,16 +73,19 @@ enum {
...
@@ -85,16 +73,19 @@ enum {
/* BLE UUID for card10 service*/
/* BLE UUID for card10 service*/
static
const
uint8_t
UUID_svc
[]
=
{
CARD10_UUID_SUFFIX
,
0x0
,
CARD10_UUID_PREFIX
};
static
const
uint8_t
UUID_svc
[]
=
{
CARD10_UUID_SUFFIX
,
0x0
,
CARD10_UUID_PREFIX
};
// works vor everyone?
static
const
uint16_t
UUID_len
=
sizeof
(
UUID_svc
);
// starting at 0x01 with write (non visual) charateristics
// starting at 0x01 with write (non visual) charateristics
/* BLE UUID for card10 time update */
/* BLE UUID for card10 time update */
static
const
uint8_t
UUID_char_time
[]
=
{
static
const
uint8_t
UUID_char_time
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_TIME_UPDATE_VAL_HDL
),
UINT16_TO_BYTES
(
CARD10_TIME_UPDATE_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x01
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0x01
,
CARD10_UUID_PREFIX
};
};
// works vor everyone?
static
const
uint16_t
UUID_char_len
=
sizeof
(
UUID_char_time
);
static
const
uint8_t
UUID_attChar_time
[]
=
{
static
const
uint8_t
UUID_attChar_time
[]
=
{
CARD10_UUID_SUFFIX
,
0x01
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0x01
,
CARD10_UUID_PREFIX
...
@@ -102,7 +93,7 @@ static const uint8_t UUID_attChar_time[] = {
...
@@ -102,7 +93,7 @@ static const uint8_t UUID_attChar_time[] = {
/* BLE UUID for card10 char vibra */
/* BLE UUID for card10 char vibra */
static
const
uint8_t
UUID_char_vibra
[]
=
{
static
const
uint8_t
UUID_char_vibra
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_VIBRA_VAL_HDL
),
UINT16_TO_BYTES
(
CARD10_VIBRA_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x0f
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0x0f
,
CARD10_UUID_PREFIX
};
};
...
@@ -116,7 +107,7 @@ static const uint8_t UUID_attChar_vibra[] = {
...
@@ -116,7 +107,7 @@ static const uint8_t UUID_attChar_vibra[] = {
/* BLE UUID for card10 char rockets */
/* BLE UUID for card10 char rockets */
static
const
uint8_t
UUID_char_rockets
[]
=
{
static
const
uint8_t
UUID_char_rockets
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_ROCKETS_VAL_HDL
),
UINT16_TO_BYTES
(
CARD10_ROCKETS_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x10
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0x10
,
CARD10_UUID_PREFIX
};
};
...
@@ -127,7 +118,7 @@ static const uint8_t UUID_attChar_rockets[] = {
...
@@ -127,7 +118,7 @@ static const uint8_t UUID_attChar_rockets[] = {
/* BLE UUID for card10 led background bottom left */
/* BLE UUID for card10 led background bottom left */
static
const
uint8_t
UUID_char_led_bg_bottom_left
[]
=
{
static
const
uint8_t
UUID_char_led_bg_bottom_left
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LED_BG_BOTTOM_LEFT_VAL_HDL
),
UINT16_TO_BYTES
(
CARD10_LED_BG_BOTTOM_LEFT_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x11
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0x11
,
CARD10_UUID_PREFIX
};
};
...
@@ -138,7 +129,7 @@ static const uint8_t UUID_attChar_led_bg_bottom_left[] = {
...
@@ -138,7 +129,7 @@ static const uint8_t UUID_attChar_led_bg_bottom_left[] = {
/* BLE UUID for card10 led background bottom right */
/* BLE UUID for card10 led background bottom right */
static
const
uint8_t
UUID_char_led_bg_bottom_right
[]
=
{
static
const
uint8_t
UUID_char_led_bg_bottom_right
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LED_BG_BOTTOM_RIGHT_VAL_HDL
),
UINT16_TO_BYTES
(
CARD10_LED_BG_BOTTOM_RIGHT_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x12
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0x12
,
CARD10_UUID_PREFIX
};
};
...
@@ -149,7 +140,7 @@ static const uint8_t UUID_attChar_led_bg_bottom_right[] = {
...
@@ -149,7 +140,7 @@ static const uint8_t UUID_attChar_led_bg_bottom_right[] = {
/* BLE UUID for card10 led background top right */
/* BLE UUID for card10 led background top right */
static
const
uint8_t
UUID_char_led_bg_top_right
[]
=
{
static
const
uint8_t
UUID_char_led_bg_top_right
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LED_BG_TOP_RIGHT_VAL_HDL
),
UINT16_TO_BYTES
(
CARD10_LED_BG_TOP_RIGHT_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x13
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0x13
,
CARD10_UUID_PREFIX
};
};
...
@@ -160,7 +151,7 @@ static const uint8_t UUID_attChar_led_bg_top_right[] = {
...
@@ -160,7 +151,7 @@ static const uint8_t UUID_attChar_led_bg_top_right[] = {
/* BLE UUID for card10 led background top left */
/* BLE UUID for card10 led background top left */
static
const
uint8_t
UUID_char_led_bg_top_left
[]
=
{
static
const
uint8_t
UUID_char_led_bg_top_left
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LED_BG_TOP_LEFT_VAL_HDL
),
UINT16_TO_BYTES
(
CARD10_LED_BG_TOP_LEFT_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x14
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0x14
,
CARD10_UUID_PREFIX
};
};
...
@@ -193,7 +184,7 @@ static const uint8_t UUID_attChar_leds_top_dim[] = {
...
@@ -193,7 +184,7 @@ static const uint8_t UUID_attChar_leds_top_dim[] = {
/* BLE UUID for card10 powersafe */
/* BLE UUID for card10 powersafe */
static
const
uint8_t
UUID_char_led_powersafe
[]
=
{
static
const
uint8_t
UUID_char_led_powersafe
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LED_POWERSAFE_VAL_HDL
),
UINT16_TO_BYTES
(
CARD10_LED_POWERSAFE_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x17
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0x17
,
CARD10_UUID_PREFIX
};
};
...
@@ -204,7 +195,7 @@ static const uint8_t UUID_attChar_led_powersafe[] = {
...
@@ -204,7 +195,7 @@ static const uint8_t UUID_attChar_led_powersafe[] = {
/* BLE UUID for card10 flashlight */
/* BLE UUID for card10 flashlight */
static
const
uint8_t
UUID_char_flashlight
[]
=
{
static
const
uint8_t
UUID_char_flashlight
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_FLASHLIGHT_VAL_HDL
),
UINT16_TO_BYTES
(
CARD10_FLASHLIGHT_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x18
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0x18
,
CARD10_UUID_PREFIX
};
};
...
@@ -215,7 +206,7 @@ static const uint8_t UUID_attChar_flashlight[] = {
...
@@ -215,7 +206,7 @@ static const uint8_t UUID_attChar_flashlight[] = {
/* BLE UUID for card10 above leds */
/* BLE UUID for card10 above leds */
static
const
uint8_t
UUID_char_leds_above
[]
=
{
static
const
uint8_t
UUID_char_leds_above
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LEDS_ABOVE_VAL_HDL
),
UINT16_TO_BYTES
(
CARD10_LEDS_ABOVE_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x20
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0x20
,
CARD10_UUID_PREFIX
};
};
...
@@ -234,308 +225,267 @@ static const uint8_t UUID_char_light_sensor[] = {
...
@@ -234,308 +225,267 @@ static const uint8_t UUID_char_light_sensor[] = {
static
const
uint8_t
UUID_attChar_light_sensor
[]
=
{
static
const
uint8_t
UUID_attChar_light_sensor
[]
=
{
CARD10_UUID_SUFFIX
,
0xf0
,
CARD10_UUID_PREFIX
CARD10_UUID_SUFFIX
,
0xf0
,
CARD10_UUID_PREFIX
};
};
/* clang-format on */
static
uint8_t
initLightSensorValue
[]
=
{
UINT16_TO_BYTES
(
0
)
};
static
uint16_t
initLightSensorLen
=
sizeof
(
initLightSensorValue
);
/*
/*
* Create the BLE service description.
* Create the BLE service description.
*/
*/
static
void
*
addCard10GroupDyn
(
void
)
{
void
*
pSHdl
;
uint8_t
initLightSensorValue
[]
=
{
UINT16_TO_BYTES
(
0
)
};
/* Create the service */
pSHdl
=
AttsDynCreateGroup
(
CARD10_START_HDL
,
CARD10_END_HDL
);
if
(
pSHdl
!=
NULL
)
{
/* Primary service */
AttsDynAddAttrConst
(
pSHdl
,
attPrimSvcUuid
,
UUID_svc
,
sizeof
(
UUID_svc
),
0
,
ATTS_PERMIT_READ
);
// TIME UPDTAE
static
const
attsAttr_t
card10SvcAttrList
[]
=
{
{
.
pUuid
=
attPrimSvcUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_svc
,
.
pLen
=
(
uint16_t
*
)
&
UUID_len
,
.
maxLen
=
sizeof
(
UUID_svc
),
.
permissions
=
ATTS_PERMIT_READ
},
AttsDynAddAttrConst
(
// TIME
pSHdl
,
attChUuid
,
UUID_char_time
,
sizeof
(
UUID_char_time
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttr
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
UUID_attChar_time
,
.
pValue
=
(
uint8_t
*
)
UUID_char_time
,
NULL
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
0
,
.
maxLen
=
sizeof
(
UUID_char_time
),
sizeof
(
uint64_t
),
.
permissions
=
ATTS_PERMIT_READ
ATTS_SET_WRITE_CBACK
,
},
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
{
ATTS_PERMIT_WRITE_AUTH
);
.
pUuid
=
UUID_attChar_time
,
.
pValue
=
NULL
,
.
maxLen
=
sizeof
(
uint64_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
// VIBRA
// VIBRA
AttsDynAddAttrConst
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_vibra
,
UUID_char_vibra
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
UUID_char_vibra
),
.
maxLen
=
sizeof
(
UUID_char_vibra
),
0
,
.
permissions
=
ATTS_PERMIT_READ
ATTS_PERMIT_READ
},
);
{
.
pUuid
=
UUID_attChar_vibra
,
AttsDynAddAttr
(
.
pValue
=
NULL
,
pSHdl
,
.
maxLen
=
sizeof
(
uint16_t
),
UUID_attChar_vibra
,
.
settings
=
ATTS_SET_WRITE_CBACK
,
NULL
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
0
,
ATTS_PERMIT_WRITE_AUTH
)
sizeof
(
uint16_t
),
},
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// ROCKETS
// ROCKETS
AttsDynAddAttrConst
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_rockets
,
UUID_char_rockets
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
UUID_char_rockets
),
.
maxLen
=
sizeof
(
UUID_char_rockets
),
0
,
.
permissions
=
ATTS_PERMIT_READ
ATTS_PERMIT_READ
},
);
{
.
pUuid
=
UUID_attChar_rockets
,
AttsDynAddAttr
(
.
pValue
=
NULL
,
pSHdl
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
UUID_attChar_rockets
,
.
settings
=
ATTS_SET_WRITE_CBACK
,
NULL
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
0
,
ATTS_PERMIT_WRITE_AUTH
)
3
*
sizeof
(
uint8_t
),
},
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// BG LED Bottom left
// BG LED Bottom left
AttsDynAddAttrConst
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_led_bg_bottom_left
,
UUID_char_led_bg_bottom_left
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
UUID_char_led_bg_bottom_left
),
.
maxLen
=
sizeof
(
UUID_char_led_bg_bottom_left
),
0
,
.
permissions
=
ATTS_PERMIT_READ
ATTS_PERMIT_READ
},
);
{
.
pUuid
=
UUID_attChar_led_bg_bottom_left
,
AttsDynAddAttr
(
.
pValue
=
NULL
,
pSHdl
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
UUID_attChar_led_bg_bottom_left
,
.
settings
=
ATTS_SET_WRITE_CBACK
,
NULL
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
0
,
ATTS_PERMIT_WRITE_AUTH
)
3
*
sizeof
(
uint8_t
),
},
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// BG LED Bottom right
// BG LED Bottom right
AttsDynAddAttrConst
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_led_bg_bottom_right
,
UUID_char_led_bg_bottom_right
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
UUID_char_led_bg_bottom_right
),
.
maxLen
=
sizeof
(
UUID_char_led_bg_bottom_right
),
0
,
.
permissions
=
ATTS_PERMIT_READ
ATTS_PERMIT_READ
},
);
{
.
pUuid
=
UUID_attChar_led_bg_bottom_right
,
AttsDynAddAttr
(
.
pValue
=
NULL
,
pSHdl
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
UUID_attChar_led_bg_bottom_right
,
.
settings
=
ATTS_SET_WRITE_CBACK
,
NULL
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
0
,
ATTS_PERMIT_WRITE_AUTH
)
3
*
sizeof
(
uint8_t
),
},
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// BG LED top right
// BG LED top right
AttsDynAddAttrConst
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_led_bg_top_right
,
UUID_char_led_bg_top_right
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
UUID_char_led_bg_top_right
),
.
maxLen
=
sizeof
(
UUID_char_led_bg_top_right
),
0
,
.
settings
=
0
,
ATTS_PERMIT_READ
.
permissions
=
ATTS_PERMIT_READ
);
},
{
AttsDynAddAttr
(
.
pUuid
=
UUID_attChar_led_bg_top_right
,
pSHdl
,
.
pValue
=
NULL
,
UUID_attChar_led_bg_top_right
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
NULL
,
.
settings
=
ATTS_SET_WRITE_CBACK
,
0
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
3
*
sizeof
(
uint8_t
),
ATTS_PERMIT_WRITE_AUTH
)
ATTS_SET_WRITE_CBACK
,
},
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// BG LED top left
// BG LED top left
AttsDynAddAttrConst
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_led_bg_top_left
,
UUID_char_led_bg_top_left
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
UUID_char_led_bg_top_left
),
.
maxLen
=
sizeof
(
UUID_char_led_bg_top_left
),
0
,
.
permissions
=
ATTS_PERMIT_READ
ATTS_PERMIT_READ
},
);
{
.
pUuid
=
UUID_attChar_led_bg_top_left
,
AttsDynAddAttr
(
.
pValue
=
NULL
,
pSHdl
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
UUID_attChar_led_bg_top_left
,
.
settings
=
ATTS_SET_WRITE_CBACK
,
NULL
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
0
,
ATTS_PERMIT_WRITE_AUTH
)
3
*
sizeof
(
uint8_t
),
},
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// Dim bottom module
// Dim bottom module
AttsDynAddAttrConst
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_leds_bottom_dim
,
UUID_char_leds_bottom_dim
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
UUID_char_leds_bottom_dim
),
.
maxLen
=
sizeof
(
UUID_char_leds_bottom_dim
),
0
,
.
permissions
=
ATTS_PERMIT_READ
ATTS_PERMIT_READ
},
);
{
.
pUuid
=
UUID_attChar_leds_bottom_dim
,
AttsDynAddAttr
(
.
pValue
=
NULL
,
pSHdl
,
.
pLen
=
0
,
UUID_attChar_leds_bottom_dim
,
.
maxLen
=
sizeof
(
uint8_t
),
NULL
,
.
settings
=
ATTS_SET_WRITE_CBACK
,
0
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
sizeof
(
uint8_t
),
ATTS_PERMIT_WRITE_AUTH
)
ATTS_SET_WRITE_CBACK
,
},
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// Dim top module
// Dim top module
AttsDynAddAttrConst
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_leds_top_dim
,
UUID_char_leds_top_dim
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
UUID_char_leds_top_dim
),
.
maxLen
=
sizeof
(
UUID_char_leds_top_dim
),
0
,
.
permissions
=
ATTS_PERMIT_READ
ATTS_PERMIT_READ
},
);
{
.
pUuid
=
UUID_attChar_leds_top_dim
,
AttsDynAddAttr
(
.
pValue
=
NULL
,
pSHdl
,
.
maxLen
=
sizeof
(
uint8_t
),
UUID_attChar_leds_top_dim
,
.
settings
=
ATTS_SET_WRITE_CBACK
,
NULL
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
0
,
ATTS_PERMIT_WRITE_AUTH
)
sizeof
(
uint8_t
),
},
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// led powersafe
// led powersafe
AttsDynAddAttrConst
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_led_powersafe
,
UUID_char_led_powersafe
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
UUID_char_led_powersafe
),
.
maxLen
=
sizeof
(
UUID_char_led_powersafe
),
0
,
.
permissions
=
ATTS_PERMIT_READ
ATTS_PERMIT_READ
},
);
{
.
pUuid
=
UUID_attChar_led_powersafe
,
AttsDynAddAttr
(
.
pValue
=
NULL
,
pSHdl
,
.
maxLen
=
sizeof
(
uint8_t
),
UUID_attChar_led_powersafe
,
.
settings
=
ATTS_SET_WRITE_CBACK
,
NULL
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
0
,
ATTS_PERMIT_WRITE_AUTH
)
sizeof
(
uint8_t
),
},
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// flashlight
// flashlight
AttsDynAddAttrConst
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_flashlight
,
UUID_char_flashlight
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
UUID_char_flashlight
),
.
maxLen
=
sizeof
(
UUID_char_flashlight
),
0
,
.
permissions
=
ATTS_PERMIT_READ
ATTS_PERMIT_READ
},
);
{
.
pUuid
=
UUID_attChar_flashlight
,
AttsDynAddAttr
(
.
pValue
=
NULL
,
pSHdl
,
.
maxLen
=
sizeof
(
uint8_t
),
UUID_attChar_flashlight
,
.
settings
=
ATTS_SET_WRITE_CBACK
,
NULL
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
0
,
ATTS_PERMIT_WRITE_AUTH
)
sizeof
(
uint8_t
),
},
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// ABOVE LEDS
// ABOVE LEDS
AttsDynAddAttrConst
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_leds_above
,
UUID_char_leds_above
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
UUID_char_leds_above
),
.
maxLen
=
sizeof
(
UUID_char_leds_above
),
0
,
.
permissions
=
ATTS_PERMIT_READ
ATTS_PERMIT_READ
},
);
{
.
pUuid
=
UUID_attChar_leds_above
,
.
pValue
=
NULL
,
.
maxLen
=
11
*
3
*
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
AttsDynAddAttr
(
// ABOVE LEDS
pSHdl
,
UUID_attChar_leds_above
,
NULL
,
0
,
11
*
3
*
sizeof
(
uint8_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// LIGHT_SENSOR
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_light_sensor
,
sizeof
(
UUID_char_light_sensor
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttr
(
{
pSHdl
,
.
pUuid
=
attChUuid
,
UUID_attChar_light_sensor
,
.
pValue
=
(
uint8_t
*
)
UUID_char_light_sensor
,
initLightSensorValue
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
sizeof
(
uint8_t
),
.
maxLen
=
sizeof
(
UUID_char_light_sensor
),
sizeof
(
uint8_t
),
.
permissions
=
ATTS_PERMIT_READ
ATTS_SET_READ_CBACK
,
},
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
{
ATTS_PERMIT_READ_AUTH
);
.
pUuid
=
UUID_attChar_light_sensor
,
.
pValue
=
initLightSensorValue
,
APP_TRACE_INFO0
(
"ble-card10: services bound
\n
"
);
.
pLen
=
&
initLightSensorLen
,
}
.
maxLen
=
sizeof
(
uint8_t
),
return
pSHdl
;
.
settings
=
ATTS_SET_READ_CBACK
,
}
.
permissions
=
(
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
ATTS_PERMIT_READ_AUTH
)
},
};
/* clang-format on */
// validating, that the service really get all charateristics
WSF_CT_ASSERT
(
((
sizeof
(
card10SvcAttrList
)
/
sizeof
(
card10SvcAttrList
[
0
]))
==
CARD10_END_HDL
-
CARD10_START_HDL
+
1
));
/*
/*
* Set the time given in milliseconds since 1.1.1970 as 64 bit integer.
* Set the time given in milliseconds since 1.1.1970 as 64 bit integer.
*/
*/
...
@@ -548,7 +498,7 @@ static uint8_t setTime(uint8_t *pValue)
...
@@ -548,7 +498,7 @@ static uint8_t setTime(uint8_t *pValue)
time
=
__bswap64
(
timeNet
);
time
=
__bswap64
(
timeNet
);
epic_rtc_set_milliseconds
(
time
);
epic_rtc_set_milliseconds
(
time
);
APP_TRACE_INFO1
(
"set time to: %d
\n
"
,
time
);
APP_TRACE_INFO1
(
"
ble-card10:
set time to: %d
\n
"
,
time
);
return
ATT_SUCCESS
;
return
ATT_SUCCESS
;
}
}
...
@@ -631,21 +581,69 @@ static uint8_t writeCard10CB(
...
@@ -631,21 +581,69 @@ static uint8_t writeCard10CB(
case
CARD10_LEDS_BOTTOM_DIM_VAL_HDL
:
case
CARD10_LEDS_BOTTOM_DIM_VAL_HDL
:
ui8
=
pValue
[
0
];
ui8
=
pValue
[
0
];
if
(
ui8
>=
1
&&
ui8
<=
8
)
{
if
(
ui8
>=
1
&&
ui8
<=
8
)
{
if
(
operation
==
ATT_PDU_WRITE_CMD
||
operation
==
ATT_PDU_SIGNED_WRITE_CMD
||
operation
==
ATT_PDU_WRITE_REQ
||
operation
==
ATT_PDU_EXEC_WRITE_REQ
)
{
epic_leds_dim_bottom
(
pValue
[
0
]);
epic_leds_dim_bottom
(
pValue
[
0
]);
APP_TRACE_INFO1
(
"dim bottom to: %d
\n
"
,
pValue
[
0
]);
APP_TRACE_INFO1
(
"ble-card10: dim bottom to: %d
\n
"
,
pValue
[
0
]
);
return
ATT_SUCCESS
;
}
else
if
(
operation
==
ATT_PDU_PREP_WRITE_REQ
)
{
APP_TRACE_INFO1
(
"ble_card10: value for dim bottom would be okay: %d
\n
"
,
pValue
[
0
]
);
return
ATT_SUCCESS
;
return
ATT_SUCCESS
;
}
else
{
APP_TRACE_INFO1
(
"ble-card10: dim bottom with unknown operation: %d
\n
"
,
operation
);
return
ATT_ERR_INVALID_PDU
;
}
}
APP_TRACE_INFO1
(
"dim bottom invalid value (1-8): %d
\n
"
,
ui8
);
}
else
{
APP_TRACE_INFO1
(
"ble-card: prep dim bottom invalid value (1-8): %d
\n
"
,
ui8
);
return
ATT_ERR_RANGE
;
return
ATT_ERR_RANGE
;
}
case
CARD10_LEDS_TOP_DIM_VAL_HDL
:
case
CARD10_LEDS_TOP_DIM_VAL_HDL
:
ui8
=
pValue
[
0
];
ui8
=
pValue
[
0
];
if
(
ui8
>=
1
&&
ui8
<=
8
)
{
if
(
ui8
>=
1
&&
ui8
<=
8
)
{
epic_leds_dim_top
(
ui8
);
if
(
operation
==
ATT_PDU_WRITE_CMD
||
APP_TRACE_INFO1
(
"dim top to: %d
\n
"
,
ui8
);
operation
==
ATT_PDU_SIGNED_WRITE_CMD
||
operation
==
ATT_PDU_WRITE_REQ
||
operation
==
ATT_PDU_EXEC_WRITE_REQ
)
{
epic_leds_dim_top
(
pValue
[
0
]);
APP_TRACE_INFO1
(
"ble-card10: dim top to: %d
\n
"
,
pValue
[
0
]
);
return
ATT_SUCCESS
;
}
else
if
(
operation
==
ATT_PDU_PREP_WRITE_REQ
)
{
APP_TRACE_INFO1
(
"ble_card10: value for dim top would be okay: %d
\n
"
,
pValue
[
0
]
);
return
ATT_SUCCESS
;
return
ATT_SUCCESS
;
}
else
{
APP_TRACE_INFO1
(
"ble-card10: dim top with unknown operation: %d
\n
"
,
operation
);
return
ATT_ERR_INVALID_PDU
;
}
}
APP_TRACE_INFO1
(
"dim top invalid value (1-8): %d
\n
"
,
ui8
);
}
else
{
APP_TRACE_INFO1
(
"ble-card: prep dim top invalid value (1-8): %d
\n
"
,
ui8
);
return
ATT_ERR_RANGE
;
return
ATT_ERR_RANGE
;
}
// led powersafe
// led powersafe
case
CARD10_LED_POWERSAFE_VAL_HDL
:
case
CARD10_LED_POWERSAFE_VAL_HDL
:
epic_leds_set_powersave
(
pValue
[
0
]);
epic_leds_set_powersave
(
pValue
[
0
]);
...
@@ -706,12 +704,20 @@ static uint8_t readCard10CB(
...
@@ -706,12 +704,20 @@ static uint8_t readCard10CB(
}
}
}
}
static
attsGroup_t
svcCard10Group
=
{
.
pNext
=
NULL
,
.
pAttr
=
(
attsAttr_t
*
)
card10SvcAttrList
,
.
readCback
=
readCard10CB
,
.
writeCback
=
writeCard10CB
,
.
startHandle
=
CARD10_START_HDL
,
.
endHandle
=
CARD10_END_HDL
,
};
/*
/*
* This registers and starts the BLE card10 service.
* This registers and starts the BLE card10 service.
*/
*/
void
bleCard10_init
(
void
)
void
bleCard10_init
(
void
)
{
{
void
*
pSHdl
=
addCard10GroupDyn
();
AttsAddGroup
(
&
svcCard10Group
);
AttsDynRegister
(
pSHdl
,
readCard10CB
,
writeCard10CB
);
}
}
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