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
f573649f
Commit
f573649f
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
feat(ess): Add card10 IAQ and CO2 measurements
parent
8ab96b6d
No related branches found
No related tags found
No related merge requests found
Pipeline
#4966
passed
4 years ago
Stage: build
Stage: test
Changes
4
Pipelines
1
Show 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
+64
-1
64 additions, 1 deletion
epicardium/ble/ess.c
epicardium/ble/ess.h
+4
-0
4 additions, 0 deletions
epicardium/ble/ess.h
with
71 additions
and
1 deletion
epicardium/ble/ble_main.c
+
2
−
0
View file @
f573649f
...
...
@@ -232,6 +232,7 @@ static const attsCccSet_t bleCccSet[BLE_NUM_CCC_IDX] =
{
ESS_TEMP_CH_CCC_HDL
,
ATT_CLIENT_CFG_NOTIFY
,
DM_SEC_LEVEL_NONE
},
/* BLE_ESS_TEMP_CCC_IDX */
{
ESS_HUMI_CH_CCC_HDL
,
ATT_CLIENT_CFG_NOTIFY
,
DM_SEC_LEVEL_NONE
},
/* BLE_ESS_HUMI_CCC_IDX */
{
ESS_PRES_CH_CCC_HDL
,
ATT_CLIENT_CFG_NOTIFY
,
DM_SEC_LEVEL_NONE
},
/* BLE_ESS_PRES_CCC_IDX */
{
ESS_IAQ_CH_CCC_HDL
,
ATT_CLIENT_CFG_NOTIFY
,
DM_SEC_LEVEL_NONE
},
/* BLE_ESS_IAQ_CCC_IDX */
};
/**************************************************************************************************
...
...
@@ -454,6 +455,7 @@ static void bleProcCccState(bleMsg_t *pMsg)
case
BLE_ESS_TEMP_CCC_IDX
:
case
BLE_ESS_HUMI_CCC_IDX
:
case
BLE_ESS_PRES_CCC_IDX
:
case
BLE_ESS_IAQ_CCC_IDX
:
bleESS_ccc_update
();
break
;
};
...
...
This diff is collapsed.
Click to expand it.
epicardium/ble/cccd.h
+
1
−
0
View file @
f573649f
...
...
@@ -7,6 +7,7 @@ enum
BLE_ESS_TEMP_CCC_IDX
,
/*! Environmental sensing service, temperature characteristic */
BLE_ESS_HUMI_CCC_IDX
,
/*! Environmental sensing service, humidity characteristic */
BLE_ESS_PRES_CCC_IDX
,
/*! Environmental sensing service, pressure characteristic */
BLE_ESS_IAQ_CCC_IDX
,
/*! Environmental sensing service, IAQ characteristic */
BLE_NUM_CCC_IDX
};
This diff is collapsed.
Click to expand it.
epicardium/ble/ess.c
+
64
−
1
View file @
f573649f
...
...
@@ -11,6 +11,8 @@
#include
"modules/log.h"
#include
"modules/modules.h"
#include
"ble/ble_api.h"
#include
"FreeRTOS.h"
#include
"timers.h"
...
...
@@ -46,7 +48,19 @@ static const uint8_t UUID_char_pressure[] = {
UINT16_TO_BYTES
(
ATT_UUID_PRESSURE
)
};
/* BLE UUID for IAQ */
static
const
uint8_t
UUID_char_IAQ
[]
=
{
ATT_PROP_READ
|
ATT_PROP_NOTIFY
,
UINT16_TO_BYTES
(
ESS_IAQ_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0xf1
,
CARD10_UUID_PREFIX
};
static
const
uint8_t
UUID_attChar_IAQ
[]
=
{
CARD10_UUID_SUFFIX
,
0xf1
,
CARD10_UUID_PREFIX
};
static
const
uint16_t
UUID_char_len
=
sizeof
(
UUID_char_temperature
);
static
const
uint16_t
UUID_char_IAQ_len
=
sizeof
(
UUID_char_IAQ
);
static
uint8_t
initTemperatureValue
[]
=
{
UINT16_TO_BYTES
(
0
)
};
static
uint16_t
initTemperatureLen
=
sizeof
(
initTemperatureValue
);
...
...
@@ -57,6 +71,9 @@ static uint16_t initHumidityLen = sizeof(initHumidityValue);
static
uint8_t
initPressureValue
[]
=
{
UINT32_TO_BYTES
(
0
)
};
static
uint16_t
initPressureLen
=
sizeof
(
initPressureValue
);
static
uint8_t
initIAQValue
[]
=
{
0x00
,
UINT16_TO_BYTES
(
0
),
UINT16_TO_BYTES
(
0
)};
static
uint16_t
initIAQLen
=
sizeof
(
initIAQValue
);
/* Temperature client characteristic configuration */
static
uint8_t
essValTempChCcc
[]
=
{
UINT16_TO_BYTES
(
0x0000
)};
static
const
uint16_t
essLenTempChCcc
=
sizeof
(
essValTempChCcc
);
...
...
@@ -69,6 +86,10 @@ static const uint16_t essLenHumidityChCcc = sizeof(essValHumidityChCcc);
static
uint8_t
essValPressureChCcc
[]
=
{
UINT16_TO_BYTES
(
0x0000
)};
static
const
uint16_t
essLenPressureChCcc
=
sizeof
(
essValPressureChCcc
);
/* IAQ client characteristic configuration */
static
uint8_t
essValIAQChCcc
[]
=
{
UINT16_TO_BYTES
(
0x0000
)};
static
const
uint16_t
essLenIAQChCcc
=
sizeof
(
essValIAQChCcc
);
/* clang-format on */
/*
...
...
@@ -171,6 +192,35 @@ static const attsAttr_t ESSSvcAttrList[] = {
ATTS_PERMIT_WRITE
)
// How about security?
},
// IAQ
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_IAQ
,
.
pLen
=
(
uint16_t
*
)
&
UUID_char_IAQ_len
,
.
maxLen
=
sizeof
(
UUID_char_IAQ
),
.
permissions
=
ATTS_PERMIT_READ
,
},
{
.
pUuid
=
UUID_attChar_IAQ
,
.
pValue
=
initIAQValue
,
.
pLen
=
&
initIAQLen
,
.
maxLen
=
sizeof
(
initIAQValue
),
.
settings
=
ATTS_SET_READ_CBACK
,
.
permissions
=
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
ATTS_PERMIT_READ_AUTH
,
},
/* Characteristic CCC descriptor */
{
.
pUuid
=
attCliChCfgUuid
,
.
pValue
=
essValIAQChCcc
,
.
pLen
=
(
uint16_t
*
)
&
essLenIAQChCcc
,
.
maxLen
=
sizeof
(
essValIAQChCcc
),
.
settings
=
ATTS_SET_CCC
,
.
permissions
=
(
ATTS_PERMIT_READ
|
ATTS_PERMIT_WRITE
)
// How about security?
},
};
// validating that the service really has all charateristics
...
...
@@ -257,6 +307,15 @@ static void setAttrFromBME680(struct bme680_sensor_data *data)
static
void
setAttrFromBSEC
(
struct
bsec_sensor_data
*
data
)
{
setAttrFromBME680
((
struct
bme680_sensor_data
*
)
data
);
uint16_t
iaq
=
data
->
indoor_air_quality
;
uint8_t
accuracy
=
data
->
accuracy
;
uint16_t
co2_equivalent
=
data
->
co2_equivalent
;
uint8_t
IAQValue
[]
=
{
accuracy
,
UINT16_TO_BYTES
(
iaq
),
UINT16_TO_BYTES
(
co2_equivalent
)
};
AttsSetAttr
(
ESS_IAQ_VAL_HDL
,
sizeof
(
IAQValue
),
IAQValue
);
}
/*
...
...
@@ -306,6 +365,8 @@ static uint8_t readESSCB(
);
APP_TRACE_INFO1
(
"ble-ess: read pressure: %u
\n
"
,
pressure
);
return
ATT_SUCCESS
;
case
ESS_IAQ_VAL_HDL
:
return
ATT_SUCCESS
;
default:
APP_TRACE_INFO0
(
"ble-card10: read no handler found
\n
"
);
return
ATT_ERR_HANDLE
;
...
...
@@ -341,6 +402,7 @@ void bleESS_update_from_bsec_data(struct bsec_sensor_data *data)
sendNotification
(
connId
,
ESS_TEMPERATURE_VAL_HDL
,
BLE_ESS_TEMP_CCC_IDX
);
sendNotification
(
connId
,
ESS_HUMIDITY_VAL_HDL
,
BLE_ESS_HUMI_CCC_IDX
);
sendNotification
(
connId
,
ESS_PRESSURE_VAL_HDL
,
BLE_ESS_PRES_CCC_IDX
);
sendNotification
(
connId
,
ESS_IAQ_VAL_HDL
,
BLE_ESS_IAQ_CCC_IDX
);
}
/*
...
...
@@ -365,7 +427,8 @@ void bleESS_ccc_update(void)
if
(
connId
!=
DM_CONN_ID_NONE
&&
(
AttsCccEnabled
(
connId
,
BLE_ESS_TEMP_CCC_IDX
)
||
AttsCccEnabled
(
connId
,
BLE_ESS_HUMI_CCC_IDX
)
||
AttsCccEnabled
(
connId
,
BLE_ESS_PRES_CCC_IDX
)))
{
AttsCccEnabled
(
connId
,
BLE_ESS_PRES_CCC_IDX
)
||
AttsCccEnabled
(
connId
,
BLE_ESS_IAQ_CCC_IDX
)))
{
LOG_INFO
(
"ess"
,
"enable periodic measurement"
);
periodic
(
3000
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
epicardium/ble/ess.h
+
4
−
0
View file @
f573649f
...
...
@@ -22,6 +22,10 @@ enum {
ESS_PRESSURE_CH_HDL
,
ESS_PRESSURE_VAL_HDL
,
ESS_PRES_CH_CCC_HDL
,
/*!< Pressure CCCD */
/*!< \brief IAQ/CO2 characteristic */
ESS_IAQ_CH_HDL
,
ESS_IAQ_VAL_HDL
,
ESS_IAQ_CH_CCC_HDL
,
/*!< IAQ CCCD */
/*!< \brief Maximum handle. */
...
...
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