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
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
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
card10
firmware
Commits
1e892a31
Commit
1e892a31
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
feat(ess): add notification support for temperature
parent
224948f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!428
Environmental Sensing Service
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
epicardium/ble/ble_main.c
+2
-0
2 additions, 0 deletions
epicardium/ble/ble_main.c
epicardium/ble/cccd.h
+1
-0
1 addition, 0 deletions
epicardium/ble/cccd.h
epicardium/ble/ess.c
+26
-16
26 additions, 16 deletions
epicardium/ble/ess.c
epicardium/ble/ess.h
+17
-0
17 additions, 0 deletions
epicardium/ble/ess.h
with
46 additions
and
16 deletions
epicardium/ble/ble_main.c
+
2
−
0
View file @
1e892a31
...
...
@@ -40,6 +40,7 @@
#include
"rscp/rscp_api.h"
#include
"profiles/gap_api.h"
#include
"cccd.h"
#include
"ess.h"
#include
"ble_api.h"
#include
"epicardium.h"
...
...
@@ -228,6 +229,7 @@ static const attsCccSet_t bleCccSet[BLE_NUM_CCC_IDX] =
/* cccd handle value range security level */
{
GATT_SC_CH_CCC_HDL
,
ATT_CLIENT_CFG_INDICATE
,
DM_SEC_LEVEL_NONE
},
/* BLE_GATT_SC_CCC_IDX */
{
BATT_LVL_CH_CCC_HDL
,
ATT_CLIENT_CFG_NOTIFY
,
DM_SEC_LEVEL_NONE
},
/* BLE_BATT_LVL_CCC_IDX */
{
ESS_TEMP_CH_CCC_HDL
,
ATT_CLIENT_CFG_NOTIFY
,
DM_SEC_LEVEL_NONE
},
/* BLE_ESS_TEMP_CCC_IDX */
};
/**************************************************************************************************
...
...
This diff is collapsed.
Click to expand it.
epicardium/ble/cccd.h
+
1
−
0
View file @
1e892a31
...
...
@@ -4,6 +4,7 @@ enum
{
BLE_GATT_SC_CCC_IDX
,
/*! GATT service, service changed characteristic */
BLE_BATT_LVL_CCC_IDX
,
/*! Battery service, battery level characteristic */
BLE_ESS_TEMP_CCC_IDX
,
/*! Environmental sensing service, temperature characteristic */
BLE_NUM_CCC_IDX
};
This diff is collapsed.
Click to expand it.
epicardium/ble/ess.c
+
26
−
16
View file @
1e892a31
#include
"ess.h"
#include
"cccd.h"
#include
"wsf_types.h"
#include
"util/bstream.h"
#include
"wsf_assert.h"
#include
"att_api.h"
#include
"app_api.h"
#include
"epicardium.h"
...
...
@@ -11,21 +14,6 @@
#include
<stdbool.h>
#include
<machine/endian.h>
/*!< \brief Service start handle. */
#define ESS_START_HDL 0x1000
/*!< \brief Service end handle. */
#define ESS_END_HDL (ESS_MAX_HDL - 1)
enum
{
/*!< \brief environmental sensing services service declaration */
ESS_SVC_HDL
=
ESS_START_HDL
,
/*!< \brief temperature characteristic */
ESS_TEMPERATURE_CH_HDL
,
ESS_TEMPERATURE_VAL_HDL
,
/*!< \brief Maximum handle. */
ESS_MAX_HDL
};
/* clang-format off */
/* BLE UUID for ESS service*/
...
...
@@ -34,7 +22,7 @@ static const uint16_t UUID_svc_len = sizeof(UUID_svc);
/* BLE UUID for temperature */
static
const
uint8_t
UUID_char_temperature
[]
=
{
ATT_PROP_READ
,
ATT_PROP_READ
|
ATT_PROP_NOTIFY
,
UINT16_TO_BYTES
(
ESS_TEMPERATURE_VAL_HDL
),
UINT16_TO_BYTES
(
ATT_UUID_TEMPERATURE
)
};
...
...
@@ -43,6 +31,12 @@ static const uint16_t UUID_char_len = sizeof(UUID_char_temperature);
static
uint8_t
initTemperatureValue
[]
=
{
UINT16_TO_BYTES
(
0
)
};
static
uint16_t
initTemperatureLen
=
sizeof
(
initTemperatureValue
);
/* Battery level client characteristic configuration */
static
uint8_t
essValTempChCcc
[]
=
{
UINT16_TO_BYTES
(
0x0000
)};
static
const
uint16_t
essLenTempChCcc
=
sizeof
(
essValTempChCcc
);
/* clang-format on */
/*
...
...
@@ -75,6 +69,15 @@ static const attsAttr_t ESSSvcAttrList[] = {
.
permissions
=
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
ATTS_PERMIT_READ_AUTH
,
},
/* Characteristic CCC descriptor */
{
.
pUuid
=
attCliChCfgUuid
,
.
pValue
=
essValTempChCcc
,
.
pLen
=
(
uint16_t
*
)
&
essLenTempChCcc
,
.
maxLen
=
sizeof
(
essValTempChCcc
),
.
settings
=
ATTS_SET_CCC
,
.
permissions
=
(
ATTS_PERMIT_READ
|
ATTS_PERMIT_WRITE
)
// How about security?
},
};
// validating that the service really has all charateristics
...
...
@@ -124,6 +127,13 @@ void bleESS_update(void)
{
uint16_t
i16
=
0
;
AttsSetAttr
(
ESS_TEMPERATURE_VAL_HDL
,
sizeof
(
i16
),
(
uint8_t
*
)
&
i16
);
dmConnId_t
connId
=
AppConnIsOpen
();
if
(
connId
!=
DM_CONN_ID_NONE
)
{
if
(
AttsCccEnabled
(
connId
,
BLE_ESS_TEMP_CCC_IDX
))
{
AttsHandleValueNtf
(
connId
,
ESS_TEMPERATURE_VAL_HDL
,
sizeof
(
i16
),
(
uint8_t
*
)
&
i16
);
}
}
}
/*
...
...
This diff is collapsed.
Click to expand it.
epicardium/ble/ess.h
+
17
−
0
View file @
1e892a31
#pragma once
/*!< \brief Service start handle. */
#define ESS_START_HDL 0x1000
/*!< \brief Service end handle. */
#define ESS_END_HDL (ESS_MAX_HDL - 1)
enum
{
/*!< \brief environmental sensing services service declaration */
ESS_SVC_HDL
=
ESS_START_HDL
,
/*!< \brief temperature characteristic */
ESS_TEMPERATURE_CH_HDL
,
ESS_TEMPERATURE_VAL_HDL
,
ESS_TEMP_CH_CCC_HDL
,
/*!< Temperature CCCD */
/*!< \brief Maximum handle. */
ESS_MAX_HDL
};
void
bleESS_update
();
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