main.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #endif
  34. initTransceiver(); // Init the 433-transceiver-HW
  35. initLed(); // Init LED-Blink
  36. initReceiver(); // Init receiver-task
  37. initNexaTransmit(); // Init NEXA Transmit task
  38. disableRx = false;
  39. while (true)
  40. {
  41. vTaskDelay(100 / portTICK_PERIOD_MS);
  42. int c;
  43. c=getchar();
  44. if( c == 't') {
  45. ESP_LOGI("MAIN", "Time: %10d mS",millis());
  46. }
  47. if( c == '?' ) {
  48. char buff[40*15];
  49. vTaskList(buff);
  50. printf(buff);
  51. }
  52. if( c == 'p' ) {
  53. int idx=dataArrIdx;
  54. for(int i=0;i<500;i++) {
  55. if( dataArr[idx] > 200 && dataArr[idx] < 5000 )
  56. printf("%u\n",dataArr[idx]);
  57. else
  58. printf("-\n");
  59. idx--;
  60. if( idx == -1 ) idx = 999;
  61. }
  62. }
  63. if( c == 'w' ) {
  64. char buff[40*10];
  65. vTaskGetRunTimeStats(buff);
  66. printf(buff);
  67. }
  68. if( c == '0' ) {
  69. sendNexaCode(0x4C90AD81);
  70. }
  71. if( c == '1' ) {
  72. sendNexaCode(0x4C90AD91);
  73. }
  74. }
  75. }