2018-11-20 15:02:37 +01:00
|
|
|
// Basic Config
|
|
|
|
#include "globals.h"
|
2020-03-29 18:08:52 +02:00
|
|
|
#include "sensor.h"
|
2018-11-20 15:02:37 +01:00
|
|
|
|
2020-09-02 11:21:56 +02:00
|
|
|
#if (COUNT_ENS)
|
2020-09-01 12:02:21 +02:00
|
|
|
#include "payload.h"
|
|
|
|
#include "corona.h"
|
|
|
|
extern PayloadConvert payload;
|
|
|
|
#endif
|
|
|
|
|
2018-11-20 15:02:37 +01:00
|
|
|
// Local logging tag
|
2019-02-27 00:49:32 +01:00
|
|
|
static const char TAG[] = __FILE__;
|
2018-11-20 15:02:37 +01:00
|
|
|
|
2018-11-25 20:56:14 +01:00
|
|
|
#define SENSORBUFFER \
|
|
|
|
10 // max. size of user sensor data buffer in bytes [default=20]
|
2018-11-21 11:12:39 +01:00
|
|
|
|
2018-11-20 16:48:35 +01:00
|
|
|
void sensor_init(void) {
|
|
|
|
|
2018-11-25 20:56:14 +01:00
|
|
|
// this function is called during device startup
|
|
|
|
// put your user sensor initialization routines here
|
2018-11-20 16:48:35 +01:00
|
|
|
}
|
|
|
|
|
2018-11-20 15:44:33 +01:00
|
|
|
uint8_t sensor_mask(uint8_t sensor_no) {
|
|
|
|
switch (sensor_no) {
|
2018-11-25 20:56:14 +01:00
|
|
|
case 0:
|
|
|
|
return (uint8_t)COUNT_DATA;
|
2018-11-20 15:44:33 +01:00
|
|
|
case 1:
|
|
|
|
return (uint8_t)SENSOR1_DATA;
|
|
|
|
case 2:
|
|
|
|
return (uint8_t)SENSOR2_DATA;
|
|
|
|
case 3:
|
|
|
|
return (uint8_t)SENSOR3_DATA;
|
|
|
|
case 4:
|
2018-11-27 11:21:20 +01:00
|
|
|
return (uint8_t)BATT_DATA;
|
2018-11-25 20:56:14 +01:00
|
|
|
case 5:
|
|
|
|
return (uint8_t)GPS_DATA;
|
|
|
|
case 6:
|
|
|
|
return (uint8_t)MEMS_DATA;
|
|
|
|
case 7:
|
|
|
|
return (uint8_t)ALARM_DATA;
|
2018-12-09 13:48:03 +01:00
|
|
|
default:
|
|
|
|
return 0;
|
2018-11-20 15:44:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t *sensor_read(uint8_t sensor) {
|
2018-11-20 15:02:37 +01:00
|
|
|
|
|
|
|
static uint8_t buf[SENSORBUFFER] = {0};
|
|
|
|
uint8_t length = 3;
|
|
|
|
|
|
|
|
switch (sensor) {
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
2020-09-27 18:00:28 +02:00
|
|
|
// insert user specific sensor data frames here
|
|
|
|
// note: Sensor1 fields are used for ENS count, if ENS detection enabled
|
2020-10-05 13:56:41 +02:00
|
|
|
#if (COUNT_ENS)
|
|
|
|
if (cfg.enscount)
|
2020-11-07 22:32:36 +01:00
|
|
|
payload.addCount(cwa_report(), MAC_SNIFF_BLE_ENS);
|
2020-09-01 12:02:21 +02:00
|
|
|
#else
|
2018-11-20 15:02:37 +01:00
|
|
|
buf[0] = length;
|
2019-03-16 11:41:04 +01:00
|
|
|
buf[1] = 0x01;
|
|
|
|
buf[2] = 0x02;
|
|
|
|
buf[3] = 0x03;
|
2020-09-01 12:02:21 +02:00
|
|
|
#endif
|
2018-11-20 15:02:37 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
buf[0] = length;
|
2019-03-16 11:41:04 +01:00
|
|
|
buf[1] = 0x01;
|
|
|
|
buf[2] = 0x02;
|
|
|
|
buf[3] = 0x03;
|
2018-11-20 15:02:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
buf[0] = length;
|
2019-03-16 11:41:04 +01:00
|
|
|
buf[1] = 0x01;
|
|
|
|
buf[2] = 0x02;
|
2018-11-20 15:02:37 +01:00
|
|
|
buf[3] = 0x03;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
2020-09-01 12:02:21 +02:00
|
|
|
}
|