main.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5. #include <sys/time.h>
  6. #include "freertos/FreeRTOS.h"
  7. #include "freertos/task.h"
  8. #include "esp_sleep.h"
  9. #include "esp_log.h"
  10. #include "driver/uart.h"
  11. #include "driver/rtc_io.h"
  12. #include "esp_intr_alloc.h"
  13. #include "esp_attr.h"
  14. #include "driver/timer.h"
  15. #include <stddef.h>
  16. #include "esp_intr_alloc.h"
  17. #include "led.h"
  18. #include "rxTimer.h"
  19. #include "transceiver.h"
  20. #include "receiver.h"
  21. #include "nexaTransmit.h"
  22. #include "wifi.h"
  23. #include "udp_client.h"
  24. void app_main(void)
  25. {
  26. //volatile uint32_t counter = 0;
  27. // Init stuff
  28. disableRx = true;
  29. rxTimerInit(); // First we start the Timer (which samples Rx and handles uS-delays)
  30. #ifdef WIFI_ENABLED
  31. initWifi(); // Init WIFI
  32. udpClientInit();
  33. //while(1) vTaskDelay(2000 / portTICK_RATE_MS);
  34. #endif
  35. initTransceiver(); // Init the 433-transceiver-HW
  36. initLed(); // Init LED-Blink
  37. initReceiver(); // Init receiver-task
  38. initNexaTransmit(); // Init NEXA Transmit task
  39. disableRx = false;
  40. while (true)
  41. {
  42. vTaskDelay(100 / portTICK_PERIOD_MS);
  43. int c;
  44. c=getchar();
  45. if( c == 't') {
  46. ESP_LOGI("MAIN", "Time: %10d mS",millis());
  47. }
  48. if( c == '?' ) {
  49. char buff[40*15];
  50. vTaskList(buff);
  51. printf(buff);
  52. }
  53. if( c == 'p' ) {
  54. int idx=dataArrIdx;
  55. for(int i=0;i<500;i++) {
  56. if( dataArr[idx] > 40 && dataArr[idx] < 25000 )
  57. printf("%u\n",dataArr[idx]);
  58. else
  59. printf("-\n");
  60. idx--;
  61. if( idx == -1 ) idx = 999;
  62. }
  63. }
  64. if( c == 'w' ) {
  65. char buff[40*10];
  66. vTaskGetRunTimeStats(buff);
  67. printf(buff);
  68. }
  69. if( c == '0' ) {
  70. //sendNexaCode(0x1B5C1DA0);
  71. sendNexaCode(0x2A37C840);
  72. }
  73. if( c == '1' ) {
  74. //sendNexaCode(0x1B5C1DB0);
  75. sendNexaCode(0x2A37C850); // Volvo: ON
  76. }
  77. }
  78. }