Project configuration items.
This commit is contained in:
parent
63273a63b8
commit
cc36fc6676
23
main/Kconfig.projbuild
Normal file
23
main/Kconfig.projbuild
Normal file
@ -0,0 +1,23 @@
|
||||
menu "EspTunnel Configuration"
|
||||
|
||||
config ESPTNL_PMK
|
||||
string "ESPNOW primary master key"
|
||||
default "pmk1234567890123"
|
||||
help
|
||||
ESPNOW primary master key. Must be 16 bytes.
|
||||
|
||||
config ESPTNL_LMK
|
||||
string "ESPNOW local master key"
|
||||
default "lmk1234567890123"
|
||||
help
|
||||
ESPNOW local master key. Must be 16 bytes.
|
||||
|
||||
|
||||
config ESPTNL_CHANNEL
|
||||
int "Channel"
|
||||
default 1
|
||||
range 0 14
|
||||
help
|
||||
The channel for sending and receiving ESPNOW data.
|
||||
|
||||
endmenu
|
||||
@ -21,6 +21,15 @@ static const char* TAG = "Networking";
|
||||
static_assert(std::is_standard_layout_v<EspNowEvent> && std::is_trivial_v<EspNowEvent>,
|
||||
"EspNowEvent is not compatible with a FreeRTOS queue.");
|
||||
|
||||
template<std::size_t N>
|
||||
constexpr auto STR_LEN(const char (&s)[N])
|
||||
{
|
||||
return N;
|
||||
}
|
||||
|
||||
static_assert(STR_LEN(CONFIG_ESPTNL_PMK) == 16 + 1, "CONFIG_ESPTNL_PMK must be of length 16 bytes + 1 null terminator.");
|
||||
static_assert(STR_LEN(CONFIG_ESPTNL_LMK) == 16 + 1, "CONFIG_ESPTNL_LMK must be of length 16 bytes + 1 null terminator.");
|
||||
|
||||
QueueHandle_t s_esp_now_queue = nullptr;
|
||||
std::array<std::uint8_t, 128> s_rx_buffer;
|
||||
std::variant<MacAddress, std::monostate> s_peer;
|
||||
@ -72,7 +81,7 @@ void setupWifi()
|
||||
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
ESP_ERROR_CHECK(esp_wifi_set_channel(1, WIFI_SECOND_CHAN_NONE));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_channel(CONFIG_ESPTNL_CHANNEL, WIFI_SECOND_CHAN_NONE));
|
||||
}
|
||||
|
||||
QueueHandle_t setupEspNow()
|
||||
@ -81,7 +90,7 @@ QueueHandle_t setupEspNow()
|
||||
ESP_ERROR_CHECK(s_esp_now_queue == nullptr);
|
||||
|
||||
ESP_ERROR_CHECK(esp_now_init());
|
||||
// ESP_ERROR_CHECK(esp_now_set_pmk(nullptr));
|
||||
ESP_ERROR_CHECK(esp_now_set_pmk((const std::uint8_t*)CONFIG_ESPTNL_PMK));
|
||||
|
||||
ESP_ERROR_CHECK(esp_now_register_send_cb(s_cbEspNowSendComplete));
|
||||
ESP_ERROR_CHECK(esp_now_register_recv_cb(s_cbEspNowReceiveComplete));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user