123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #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 "rxTimer.h"
- #include "toshiba_ir.h"
- #include "wifi.h"
- uint32_t dataArr[1000];
- uint32_t dataArrIdx = 0;
- void receiverTask(void *pvParameter)
- {
- ESP_LOGI("RX", "Receiver task starting.");
- uint32_t width;
- while (1) {
- while( xQueueReceive( rxQueue, &width, portMAX_DELAY ) == pdTRUE ) {
- //ESP_LOGI("D", "%u", width);
- //dataArr[dataArrIdx++] = width;
- //if( dataArrIdx == 1000 ) dataArrIdx=0;
- // Receive the Toshiba IR
- union ToshibaProtocolU* data = (union ToshibaProtocolU*)nextPulseToshiba_ir(width);
- if( data != NULL ) {
- ESP_LOGI("TOSHIBA", "Data: %02X %02X %02X %02X %02X %02X %02X %02X %02X",data->raw[8],data->raw[7],data->raw[6],data->raw[5],data->raw[4],data->raw[3],data->raw[2],data->raw[1],data->raw[0]);
- const uint8_t fan = (data->data.Fan > 0) ? data->data.Fan-1 : data->data.Fan;
- const uint8_t power = (data->data.Mode == 3) ? 1 : 0;
- ESP_LOGI("TOSHIBA","Mode:%u Temp:%u Fan:%u",power,data->data.Temp+17u,fan);
- #ifdef WIFI_ENABLED
- sendUDPMessage(dataStr, true);
- #endif
- }
-
- }
- }
- vTaskDelete(NULL);
- }
- void initReceiver() {
- gpio_pad_select_gpio(GPIO_RX_DATA);
- gpio_set_direction(GPIO_RX_DATA, GPIO_MODE_INPUT);
- //ClasO_ResetDecoder();
-
- ESP_LOGI("RX", "Receiver has been initialized.");
- xTaskCreatePinnedToCore(&receiverTask, "receiverTask", 8192, NULL, tskIDLE_PRIORITY + 5, NULL, 0);
- }
|