espNowTest/main/main.c
simon 44cd594d96 Refactored in multiple files.
- isMaster variable should not be set like this but now it is working
- TODO: Rework it in a modular way!
- shared.h is not very pretty but works that way
- There should be a universal logger with the tag
2024-10-04 16:11:16 +02:00

40 lines
911 B
C

#include "driver/gpio.h"
#include "esp_crc.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_mac.h"
#include "esp_netif.h"
#include "esp_now.h"
#include "esp_random.h"
#include "esp_wifi.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "hal/gpio_types.h"
#include "nvs_flash.h"
#include "portmacro.h"
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "main.h"
#include "espnow_handler.h"
void app_main(void) {
// Master Slave Detection, default pin is pull up so ground it and check state
gpio_reset_pin(Master_SlavePin);
gpio_set_direction(Master_SlavePin, GPIO_MODE_INPUT);
int checkMaster = gpio_get_level(Master_SlavePin);
if (checkMaster == 0) {
isMaster = true;
setIsMaster(true);
}
ESP_LOGI(tag, "ESP MASTER State %d\n", isMaster);
vTaskDelay(500 / portTICK_PERIOD_MS);
wifi_init();
espnow_init();
}