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
fleur
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
Branches
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
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:
- Time update characteristic:
UUID: ``42230201-2342-2342-2342-234223422342``
write
write
no response
- Vibra characteristic:
UUID: ``4223020f-2342-2342-2342-234223422342``
write
write
no response
- Rockets characteristic:
UUID: ``42230210-2342-2342-2342-234223422342``
write
write
no response
- Background LED Bottom Left characteristic:
UUID: ``42230211-2342-2342-2342-234223422342``
write
write
no response
- Background LED Bottom Right characteristic:
UUID: ``42230212-2342-2342-2342-234223422342``
write
write
no response
- Background LED Top Right characteristic:
UUID: ``42230213-2342-2342-2342-234223422342``
write
write
no response
- Background LED Top Left characteristic:
UUID: ``42230214-2342-2342-2342-234223422342``
write
write
no reponse
- LEDS dim bottom characteristic:
UUID: ``42230215-2342-2342-2342-234223422342``
write
write
with response
- LEDs dim top characteristic:
UUID: ``42230216-2342-2342-2342-234223422342``
write
write
with response
- LEDs powersafe characteristic:
UUID: ``42230217-2342-2342-2342-234223422342``
write
write
no response
- Flashlight characteristic:
UUID: ``42230218-2342-2342-2342-234223422342``
write
write
no response
- LEDs above characteristic:
UUID: ``42230220-2342-2342-2342-234223422342``
write
write
no reponse
- Light sensor characteristic:
UUID: ``422302f0-2342-2342-2342-234223422342``
read
read
no response
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_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
"wsf_assert.h"
#include
"att_api.h"
#include
"FreeRTOS.h"
#include
"crc32.h"
#include
"epicardium.h"
#include
<stdio.h>
...
...
@@ -85,16 +73,19 @@ enum {
/* BLE UUID for card10 service*/
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
/* BLE UUID for card10 time update */
static
const
uint8_t
UUID_char_time
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_TIME_UPDATE_VAL_HDL
),
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
[]
=
{
CARD10_UUID_SUFFIX
,
0x01
,
CARD10_UUID_PREFIX
...
...
@@ -102,7 +93,7 @@ static const uint8_t UUID_attChar_time[] = {
/* BLE UUID for card10 char vibra */
static
const
uint8_t
UUID_char_vibra
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_VIBRA_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x0f
,
CARD10_UUID_PREFIX
};
...
...
@@ -116,7 +107,7 @@ static const uint8_t UUID_attChar_vibra[] = {
/* BLE UUID for card10 char rockets */
static
const
uint8_t
UUID_char_rockets
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_ROCKETS_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x10
,
CARD10_UUID_PREFIX
};
...
...
@@ -127,7 +118,7 @@ static const uint8_t UUID_attChar_rockets[] = {
/* BLE UUID for card10 led background 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
),
CARD10_UUID_SUFFIX
,
0x11
,
CARD10_UUID_PREFIX
};
...
...
@@ -138,7 +129,7 @@ static const uint8_t UUID_attChar_led_bg_bottom_left[] = {
/* BLE UUID for card10 led background 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
),
CARD10_UUID_SUFFIX
,
0x12
,
CARD10_UUID_PREFIX
};
...
...
@@ -149,7 +140,7 @@ static const uint8_t UUID_attChar_led_bg_bottom_right[] = {
/* BLE UUID for card10 led background 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
),
CARD10_UUID_SUFFIX
,
0x13
,
CARD10_UUID_PREFIX
};
...
...
@@ -160,7 +151,7 @@ static const uint8_t UUID_attChar_led_bg_top_right[] = {
/* BLE UUID for card10 led background 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
),
CARD10_UUID_SUFFIX
,
0x14
,
CARD10_UUID_PREFIX
};
...
...
@@ -193,7 +184,7 @@ static const uint8_t UUID_attChar_leds_top_dim[] = {
/* BLE UUID for card10 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
),
CARD10_UUID_SUFFIX
,
0x17
,
CARD10_UUID_PREFIX
};
...
...
@@ -204,7 +195,7 @@ static const uint8_t UUID_attChar_led_powersafe[] = {
/* BLE UUID for card10 flashlight */
static
const
uint8_t
UUID_char_flashlight
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_FLASHLIGHT_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x18
,
CARD10_UUID_PREFIX
};
...
...
@@ -215,7 +206,7 @@ static const uint8_t UUID_attChar_flashlight[] = {
/* BLE UUID for card10 above leds */
static
const
uint8_t
UUID_char_leds_above
[]
=
{
ATT_PROP_WRITE
,
ATT_PROP_WRITE
_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LEDS_ABOVE_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x20
,
CARD10_UUID_PREFIX
};
...
...
@@ -234,308 +225,267 @@ static const uint8_t UUID_char_light_sensor[] = {
static
const
uint8_t
UUID_attChar_light_sensor
[]
=
{
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.
*/
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
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_time
,
sizeof
(
UUID_char_time
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_time
,
NULL
,
0
,
sizeof
(
uint64_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// VIBRA
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_vibra
,
sizeof
(
UUID_char_vibra
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_vibra
,
NULL
,
0
,
sizeof
(
uint16_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// ROCKETS
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_rockets
,
sizeof
(
UUID_char_rockets
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_rockets
,
NULL
,
0
,
3
*
sizeof
(
uint8_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// BG LED Bottom left
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_led_bg_bottom_left
,
sizeof
(
UUID_char_led_bg_bottom_left
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_led_bg_bottom_left
,
NULL
,
0
,
3
*
sizeof
(
uint8_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// BG LED Bottom right
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_led_bg_bottom_right
,
sizeof
(
UUID_char_led_bg_bottom_right
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_led_bg_bottom_right
,
NULL
,
0
,
3
*
sizeof
(
uint8_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// BG LED top right
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_led_bg_top_right
,
sizeof
(
UUID_char_led_bg_top_right
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_led_bg_top_right
,
NULL
,
0
,
3
*
sizeof
(
uint8_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// BG LED top left
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_led_bg_top_left
,
sizeof
(
UUID_char_led_bg_top_left
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_led_bg_top_left
,
NULL
,
0
,
3
*
sizeof
(
uint8_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// Dim bottom module
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_leds_bottom_dim
,
sizeof
(
UUID_char_leds_bottom_dim
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_leds_bottom_dim
,
NULL
,
0
,
sizeof
(
uint8_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// Dim top module
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_leds_top_dim
,
sizeof
(
UUID_char_leds_top_dim
),
0
,
ATTS_PERMIT_READ
);
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_leds_top_dim
,
NULL
,
0
,
sizeof
(
uint8_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// led powersafe
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_led_powersafe
,
sizeof
(
UUID_char_led_powersafe
),
0
,
ATTS_PERMIT_READ
);
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
},
// TIME
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_time
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_time
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
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
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_vibra
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_vibra
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_vibra
,
.
pValue
=
NULL
,
.
maxLen
=
sizeof
(
uint16_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
// ROCKETS
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_rockets
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_rockets
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_rockets
,
.
pValue
=
NULL
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
// BG LED Bottom left
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_led_bg_bottom_left
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_led_bg_bottom_left
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_led_bg_bottom_left
,
.
pValue
=
NULL
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
// BG LED Bottom right
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_led_bg_bottom_right
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_led_bg_bottom_right
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_led_bg_bottom_right
,
.
pValue
=
NULL
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
// BG LED top right
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_led_bg_top_right
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_led_bg_top_right
),
.
settings
=
0
,
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_led_bg_top_right
,
.
pValue
=
NULL
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
// BG LED top left
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_led_bg_top_left
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_led_bg_top_left
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_led_bg_top_left
,
.
pValue
=
NULL
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
// Dim bottom module
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_leds_bottom_dim
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_leds_bottom_dim
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_leds_bottom_dim
,
.
pValue
=
NULL
,
.
pLen
=
0
,
.
maxLen
=
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
// Dim top module
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_leds_top_dim
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_leds_top_dim
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_leds_top_dim
,
.
pValue
=
NULL
,
.
maxLen
=
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_led_powersafe
,
NULL
,
0
,
sizeof
(
uint8_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// flashlight
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_flashlight
,
sizeof
(
UUID_char_flashlight
),
0
,
ATTS_PERMIT_READ
);
// led powersafe
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_flashlight
,
NULL
,
0
,
sizeof
(
uint8_t
),
ATTS_SET_WRITE_CBACK
,
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
);
// ABOVE LEDS
AttsDynAddAttrConst
(
pSHdl
,
attChUuid
,
UUID_char_leds_above
,
sizeof
(
UUID_char_leds_above
),
0
,
ATTS_PERMIT_READ
);
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_led_powersafe
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_led_powersafe
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_led_powersafe
,
.
pValue
=
NULL
,
.
maxLen
=
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
AttsDynAddAttr
(
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
);
// flashlight
AttsDynAddAttr
(
pSHdl
,
UUID_attChar_light_sensor
,
initLightSensorValue
,
sizeof
(
uint8_t
),
sizeof
(
uint8_t
),
ATTS_SET_READ_CBACK
,
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
ATTS_PERMIT_READ_AUTH
);
APP_TRACE_INFO0
(
"ble-card10: services bound
\n
"
);
}
return
pSHdl
;
}
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_flashlight
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_flashlight
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_flashlight
,
.
pValue
=
NULL
,
.
maxLen
=
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
permissions
=
(
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
)
},
// ABOVE LEDS
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_leds_above
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_leds_above
),
.
permissions
=
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
)
},
// ABOVE LEDS
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_light_sensor
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_len
,
.
maxLen
=
sizeof
(
UUID_char_light_sensor
),
.
permissions
=
ATTS_PERMIT_READ
},
{
.
pUuid
=
UUID_attChar_light_sensor
,
.
pValue
=
initLightSensorValue
,
.
pLen
=
&
initLightSensorLen
,
.
maxLen
=
sizeof
(
uint8_t
),
.
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.
*/
...
...
@@ -548,7 +498,7 @@ static uint8_t setTime(uint8_t *pValue)
time
=
__bswap64
(
timeNet
);
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
;
}
...
...
@@ -631,21 +581,69 @@ static uint8_t writeCard10CB(
case
CARD10_LEDS_BOTTOM_DIM_VAL_HDL
:
ui8
=
pValue
[
0
];
if
(
ui8
>=
1
&&
ui8
<=
8
)
{
epic_leds_dim_bottom
(
pValue
[
0
]);
APP_TRACE_INFO1
(
"dim bottom to: %d
\n
"
,
pValue
[
0
]);
return
ATT_SUCCESS
;
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
]);
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
;
}
else
{
APP_TRACE_INFO1
(
"ble-card10: dim bottom with unknown operation: %d
\n
"
,
operation
);
return
ATT_ERR_INVALID_PDU
;
}
}
else
{
APP_TRACE_INFO1
(
"ble-card: prep dim bottom invalid value (1-8): %d
\n
"
,
ui8
);
return
ATT_ERR_RANGE
;
}
APP_TRACE_INFO1
(
"dim bottom invalid value (1-8): %d
\n
"
,
ui8
);
return
ATT_ERR_RANGE
;
case
CARD10_LEDS_TOP_DIM_VAL_HDL
:
ui8
=
pValue
[
0
];
if
(
ui8
>=
1
&&
ui8
<=
8
)
{
epic_leds_dim_top
(
ui8
);
APP_TRACE_INFO1
(
"dim top to: %d
\n
"
,
ui8
);
return
ATT_SUCCESS
;
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_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
;
}
else
{
APP_TRACE_INFO1
(
"ble-card10: dim top with unknown operation: %d
\n
"
,
operation
);
return
ATT_ERR_INVALID_PDU
;
}
}
else
{
APP_TRACE_INFO1
(
"ble-card: prep dim top invalid value (1-8): %d
\n
"
,
ui8
);
return
ATT_ERR_RANGE
;
}
APP_TRACE_INFO1
(
"dim top invalid value (1-8): %d
\n
"
,
ui8
);
return
ATT_ERR_RANGE
;
// led powersafe
case
CARD10_LED_POWERSAFE_VAL_HDL
:
epic_leds_set_powersave
(
pValue
[
0
]);
...
...
@@ -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.
*/
void
bleCard10_init
(
void
)
{
void
*
pSHdl
=
addCard10GroupDyn
();
AttsDynRegister
(
pSHdl
,
readCard10CB
,
writeCard10CB
);
AttsAddGroup
(
&
svcCard10Group
);
}
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