Skip to content

Commit

Permalink
Use msCO2 cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
nurikk committed Oct 6, 2020
1 parent 0b77082 commit bc156fc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
4 changes: 2 additions & 2 deletions CC2530DB/GenericApp.ewp
Original file line number Diff line number Diff line change
Expand Up @@ -3702,7 +3702,7 @@
</option>
<option>
<name>OGChipConfigPath</name>
<state>$TOOLKIT_DIR$\config\devices\Texas Instruments\CC25xx\3x\CC2530F256.i51</state>
<state>C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.1\8051\bin\..\config\devices\Texas Instruments\CC25xx\3x\CC2530F256.i51</state>
</option>
</data>
</settings>
Expand Down Expand Up @@ -3730,7 +3730,7 @@
<name>CCDefines</name>
<state>HAL_BOARD_TARGET</state>
<state>HAL_PA_LNA_CC2592</state>
<state>APP_TX_POWER=TX_PWR_PLUS_19</state>
<state>APP_TX_POWER=19</state>
</option>
<option>
<name>CCPreprocFile</name>
Expand Down
6 changes: 1 addition & 5 deletions Source/preinclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@
#define CO2_UART_PORT 0x00
#define HAL_UART_DMA 1
#define HAL_UART_ISR 0
#if defined(RTR_NWK)
#define INT_HEAP_LEN 2300
#else
#define INT_HEAP_LEN 2750
#endif
#define INT_HEAP_LEN 2300
#elif defined(HAL_BOARD_CHDTECH_DEV)
#define HAL_UART_DMA 1
#define HAL_UART_ISR 2
Expand Down
8 changes: 5 additions & 3 deletions Source/zcl_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,12 @@ static void zclApp_ReadSensors(void) {
case 1:
switch (sensorType) {
case SENSEAIR:
zclApp_Sensors.CO2_PPM = SenseAir_Read() / 1000000.0;
zclApp_Sensors.CO2_PPM = SenseAir_Read();
zclApp_Sensors.CO2 = (float) ((double) zclApp_Sensors.CO2_PPM / 1000000.0);
break;
case MHZ19:
zclApp_Sensors.CO2_PPM = MHZ19_Read() / 1000000.0;
zclApp_Sensors.CO2_PPM = MHZ19_Read();
zclApp_Sensors.CO2 = (float) ((double) zclApp_Sensors.CO2_PPM / 1000000.0);
break;

default:
Expand Down Expand Up @@ -342,7 +344,7 @@ static void zclApp_ReadSensors(void) {
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, TEMP, ATTRID_MS_TEMPERATURE_MEASURED_VALUE);
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, PRESSURE, ATTRID_MS_PRESSURE_MEASUREMENT_MEASURED_VALUE);
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, HUMIDITY, ATTRID_MS_RELATIVE_HUMIDITY_MEASURED_VALUE);
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, CO2, ATTRID_CO2_MEASURED_VALUE);
bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_CO2, ATTRID_CO2_MEASURED_VALUE);
currentSensorsReadingPhase = 0;
zclApp_LedFeedback();
break;
Expand Down
6 changes: 3 additions & 3 deletions Source/zcl_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern "C" {
#define PRESSURE ZCL_CLUSTER_ID_MS_PRESSURE_MEASUREMENT

//Carbon Dioxide (CO2)
#define CO2 0x040d
#define ZCL_CO2 0x040d


// Carbon Dioxide (CO2)
Expand Down Expand Up @@ -69,7 +69,6 @@ extern "C" {
*/

typedef struct {
float SensorTolerance;
uint8 LedFeedback;
uint8 EnableABC;
uint16 Threshold1_PPM;
Expand All @@ -81,7 +80,8 @@ typedef struct {
} application_config_t;

typedef struct {
float CO2_PPM;
float CO2;
int16 CO2_PPM;
int16 Temperature;
int16 BME280_Temperature_Sensor_MeasuredValue;
int16 BME280_PressureSensor_MeasuredValue;
Expand Down
17 changes: 7 additions & 10 deletions Source/zcl_app_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const uint8 zclApp_ManufacturerName[] = {9, 'm', 'o', 'd', 'k', 'a', 'm', '.', '
const uint8 zclApp_ModelId[] = {15, 'D', 'I', 'Y', 'R', 'u', 'Z', '_', 'A', 'i', 'r', 'S', 'e', 'n', 's', 'e'};
const uint8 zclApp_PowerSource = POWER_SOURCE_MAINS_1_PHASE;

#define DEFAULT_SensorTolerance 0
#define DEFAULT_LedFeedback TRUE
#define DEFAULT_EnableABC TRUE
// FYI: https://www.kane.co.uk/knowledge-centre/what-are-safe-levels-of-co-and-co2-in-rooms
Expand All @@ -65,7 +64,6 @@ const uint8 zclApp_PowerSource = POWER_SOURCE_MAINS_1_PHASE;


application_config_t zclApp_Config = {
.SensorTolerance = DEFAULT_SensorTolerance,
.LedFeedback = DEFAULT_LedFeedback,
.EnableABC = DEFAULT_EnableABC,
.Threshold1_PPM = DEFAULT_Threshold1_PPM,
Expand All @@ -76,6 +74,7 @@ application_config_t zclApp_Config = {
};

sensors_state_t zclApp_Sensors = {
.CO2 = 0.0,
.CO2_PPM = 0,
.Temperature = 0,
.BME280_Temperature_Sensor_MeasuredValue = 0,
Expand Down Expand Up @@ -112,12 +111,11 @@ CONST zclAttrRec_t zclApp_AttrsFirstEP[] = {
{HUMIDITY, {ATTRID_MS_RELATIVE_HUMIDITY_MEASURED_VALUE, ZCL_UINT16, RR, (void *)&zclApp_Sensors.BME280_HumiditySensor_MeasuredValue}},
{HUMIDITY, {ATTRID_HumidityOffset, ZCL_INT16, RW, (void *)&zclApp_Config.HumidityOffset}},

{CO2, {ATTRID_CO2_MEASURED_VALUE, ZCL_SINGLE, RR, (void *)&zclApp_Sensors.CO2_PPM}},
{CO2, {ATTRID_CO2_TOLERANCE, ZCL_SINGLE, RW, (void *)&zclApp_Config.SensorTolerance}},
{CO2, {ATTRID_ENABLE_ABC, ZCL_DATATYPE_BOOLEAN, RW, (void *)&zclApp_Config.EnableABC}},
{CO2, {ATTRID_LED_FEEDBACK, ZCL_DATATYPE_BOOLEAN, RW, (void *)&zclApp_Config.LedFeedback}},
{CO2, {ATTRID_THRESHOLD1_PPM, ZCL_UINT16, RW, (void *)&zclApp_Config.Threshold1_PPM}},
{CO2, {ATTRID_THRESHOLD2_PPM, ZCL_UINT16, RW, (void *)&zclApp_Config.Threshold2_PPM}}
{ZCL_CO2, {ATTRID_CO2_MEASURED_VALUE, ZCL_SINGLE, RR, (void *)&zclApp_Sensors.CO2}},
{ZCL_CO2, {ATTRID_ENABLE_ABC, ZCL_DATATYPE_BOOLEAN, RW, (void *)&zclApp_Config.EnableABC}},
{ZCL_CO2, {ATTRID_LED_FEEDBACK, ZCL_DATATYPE_BOOLEAN, RW, (void *)&zclApp_Config.LedFeedback}},
{ZCL_CO2, {ATTRID_THRESHOLD1_PPM, ZCL_UINT16, RW, (void *)&zclApp_Config.Threshold1_PPM}},
{ZCL_CO2, {ATTRID_THRESHOLD2_PPM, ZCL_UINT16, RW, (void *)&zclApp_Config.Threshold2_PPM}}
};


Expand All @@ -127,7 +125,7 @@ const cId_t zclApp_InClusterList[] = {ZCL_CLUSTER_ID_GEN_BASIC};

#define APP_MAX_INCLUSTERS (sizeof(zclApp_InClusterList) / sizeof(zclApp_InClusterList[0]))

const cId_t zclApp_OutClusterList[] = {TEMP, HUMIDITY, PRESSURE, CO2};
const cId_t zclApp_OutClusterList[] = {TEMP, HUMIDITY, PRESSURE, ZCL_CO2};


#define APP_MAX_OUT_CLUSTERS (sizeof(zclApp_OutClusterList) / sizeof(zclApp_OutClusterList[0]))
Expand All @@ -147,7 +145,6 @@ SimpleDescriptionFormat_t zclApp_FirstEP = {


void zclApp_ResetAttributesToDefaultValues(void) {
zclApp_Config.SensorTolerance = DEFAULT_SensorTolerance;
zclApp_Config.LedFeedback = DEFAULT_LedFeedback;
zclApp_Config.EnableABC = DEFAULT_EnableABC;
zclApp_Config.Threshold1_PPM = DEFAULT_Threshold1_PPM;
Expand Down
2 changes: 1 addition & 1 deletion zstack-lib
Submodule zstack-lib updated 1 files
+7 −0 utils.h

0 comments on commit bc156fc

Please sign in to comment.