123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <time.h>
- #include <sys/time.h>
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "esp_sleep.h"
- #include "esp_log.h"
- #include "driver/uart.h"
- #include "driver/rtc_io.h"
- #include "esp_intr_alloc.h"
- #include "esp_attr.h"
- #include "driver/timer.h"
- #include <stddef.h>
- #include "esp_intr_alloc.h"
- #include "receiver.h"
- #include "transceiver.h"
- #include "rxTimer.h"
- #include "Sensors/ClasOSensor.h"
- #include "Sensors/proovesmartSensor.h"
- #include "Sensors/nexa.h"
- #include "led.h"
- #include "udp_client.h"
- #include "wifi.h"
- uint32_t dataArr[1000];
- uint32_t dataArrIdx = 0;
- static int convertToSignedTemp(unsigned int value)
- {
- //int signValue;
- return ( (value >> 11) == 0 )? value : ((-1 ^ 0xFFF) | value);
- }
- void receiverTask(void *pvParameter)
- {
- ESP_LOGI("RX", "Receiver task starting.");
- uint32_t width;
- char dataStr[UDP_QUEUE_OBJ_LENGTH];
- while (1) {
- while( xQueueReceive( rxQueue, &width, portMAX_DELAY ) == pdTRUE ) {
- dataArr[dataArrIdx++] = width;
- if( dataArrIdx == 1000 ) dataArrIdx=0;
- // Receive the Clas Ohlsson Sensors
- int64_t data = nextPulseClasOSensor(width);
- if( data != -1 ) {
- int value = convertToSignedTemp( data & 0xFFF );
- ESP_LOGI("RX", "ClasO: <TR%08llX> %d",data,value);
- sprintf(dataStr,"<TR%08llX>\n",data);
- #ifdef WIFI_ENABLED
- sendUDPMessage(dataStr);
- #endif
- }
- // Receive the Telldus / Proovesmart Sensors
- data = nextPulseProovesmartSensor(width);
- if( data != -1 ) {
- const int value = (data & 0x00FFF0000) >> 16;
- const int id = (data & 0xFF0000000) >> 28;
- ESP_LOGI("RX", "Proove: <Tr%016llX> ID:%d %d",data,id,value);
- sprintf(dataStr,"<Tr%016llX>\n",data);
- #ifdef WIFI_ENABLED
- sendUDPMessage(dataStr);
- #endif
- }
- // Receive the NEXA Sensors
- data = nextPulseNEXA(width);
- if( data != -1 ) {
- ESP_LOGI("RX", "NEXA: <NR%08llX>",data);
- sprintf(dataStr,"<NR%08llX>\n",data);
- #ifdef WIFI_ENABLED
- sendUDPMessage(dataStr);
- #endif
- }
- }
- }
- vTaskDelete(NULL);
- }
- void initReceiver() {
-
- ESP_LOGI("RX", "Receiver has been initialized.");
- xTaskCreatePinnedToCore(&receiverTask, "receiverTask", 8192, NULL, tskIDLE_PRIORITY + 5, NULL, 0);
- }
|