-static int lacrossetx_callback(uint8_t bb[BITBUF_ROWS][BITBUF_COLS],
- int16_t bits_per_row[BITBUF_ROWS]) {
-
- int i, m, valid = 0;
- uint8_t *buf;
- uint8_t msg_nybbles[11];
- uint8_t sensor_id, msg_type, msg_len, msg_parity, msg_checksum;
- int msg_value_int;
- float msg_value = 0, temp_c = 0, temp_f = 0;
- time_t time_now;
- char time_str[25];
-
- static float last_msg_value = 0.0;
- static uint8_t last_sensor_id = 0;
- static uint8_t last_msg_type = 0;
- static time_t last_msg_time = 0;
-
- for (m = 0; m < BITBUF_ROWS; m++) {
- valid = 0;
- if (lacrossetx_detect(bb[m], msg_nybbles)) {
-
- msg_len = msg_nybbles[1];
- msg_type = msg_nybbles[2];
- sensor_id = (msg_nybbles[3] << 3) + (msg_nybbles[4] >> 1);
- msg_parity = msg_nybbles[4] & 0x01;
- msg_value = msg_nybbles[5] * 10 + msg_nybbles[6]
- + msg_nybbles[7] / 10.0;
- msg_value_int = msg_nybbles[8] * 10 + msg_nybbles[9];
- msg_checksum = msg_nybbles[10];
-
- time(&time_now);
-
- // suppress duplicates
- if (sensor_id == last_sensor_id && msg_type == last_msg_type
- && last_msg_value == msg_value
- && time_now - last_msg_time < 50) {
- continue;
- }
-
- local_time_str(time_now, time_str);
-
- switch (msg_type) {
- case 0x00:
- temp_c = msg_value - 50.0;
- temp_f = temp_c * 1.8 + 32;
- printf("SENSOR:TYPE=LACROSSE_TX,TIME=%s,ID=%02x,TEMPERATURE=%3.1f\n",
- time_str, sensor_id, temp_c);
- break;
-
- case 0x0E:
- printf("SENSOR:TYPE=LACROSSE_TX,TIME=%s,ID=%02x,HUMIDITY=%3.1f\n",
- time_str, sensor_id, msg_value);
- break;
-
- default:
- fprintf(stderr,
- "%s LaCrosse Sensor %02x: Unknown Reading % 3.1f (%d)\n",
- time_str, sensor_id, msg_value, msg_value_int);
- }
-
- time(&last_msg_time);
- last_msg_value = msg_value;
- last_msg_type = msg_type;
- last_sensor_id = sensor_id;
-
- } else {
- return 0;
+static int lacrossetx_callback(bitbuffer_t *bitbuffer) {
+ bitrow_t *bb = bitbuffer->bb;
+
+ int i, m, valid = 0;
+ int events = 0;
+ uint8_t *buf;
+ uint8_t msg_nybbles[LACROSSE_NYBBLE_CNT];
+ uint8_t sensor_id, msg_type, msg_len, msg_parity, msg_checksum;
+ int msg_value_int;
+ float msg_value = 0, temp_c = 0;
+ time_t time_now;
+ char time_str[LOCAL_TIME_BUFLEN];
+ data_t *data;
+
+ for (m = 0; m < BITBUF_ROWS; m++) {
+ valid = 0;
+ // break out the message nybbles into separate bytes
+ if (lacrossetx_detect(bb[m], msg_nybbles, bitbuffer->bits_per_row[m])) {
+
+ msg_len = msg_nybbles[1];
+ msg_type = msg_nybbles[2];
+ sensor_id = (msg_nybbles[3] << 3) + (msg_nybbles[4] >> 1);
+ msg_parity = msg_nybbles[4] & 0x01;
+ msg_value = msg_nybbles[5] * 10 + msg_nybbles[6]
+ + msg_nybbles[7] / 10.0;
+ msg_value_int = msg_nybbles[8] * 10 + msg_nybbles[9];
+ msg_checksum = msg_nybbles[10];
+
+ time(&time_now);
+ local_time_str(0, time_str);
+
+ // Check Repeated data values as another way of verifying
+ // message integrity.
+ if (msg_nybbles[5] != msg_nybbles[8] ||
+ msg_nybbles[6] != msg_nybbles[9]) {
+ if (debug_output) {
+ fprintf(stderr,
+ "LaCrosse TX Sensor %02x, type: %d: message value mismatch int(%3.1f) != %d?\n",
+ sensor_id, msg_type, msg_value, msg_value_int);