mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2026-04-09 03:11:29 +00:00
chore(format): initial formatting
This commit is contained in:
parent
fa08fcfe65
commit
008c79852b
21 changed files with 1021 additions and 1082 deletions
|
|
@ -11,32 +11,28 @@
|
|||
static const char *TAG = "WIFI";
|
||||
static bool s_wifi_started = false;
|
||||
|
||||
esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel, uint8_t max_connections)
|
||||
{
|
||||
if (s_wifi_started)
|
||||
{
|
||||
esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
||||
uint8_t max_connections) {
|
||||
if (s_wifi_started) {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (!ssid || strlen(ssid) == 0 || strlen(ssid) > 32)
|
||||
{
|
||||
if (!ssid || strlen(ssid) == 0 || strlen(ssid) > 32) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
const bool has_password = password && strlen(password) > 0;
|
||||
if (has_password && strlen(password) < 8)
|
||||
{
|
||||
if (has_password && strlen(password) < 8) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
esp_err_t err = nvs_flash_init();
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND)
|
||||
{
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES ||
|
||||
err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
err = nvs_flash_init();
|
||||
}
|
||||
if (err != ESP_OK)
|
||||
{
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
@ -48,22 +44,24 @@ esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
|||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
|
||||
wifi_config_t wifi_config = {
|
||||
.ap = {
|
||||
.channel = channel,
|
||||
.max_connection = max_connections,
|
||||
.authmode = has_password ? WIFI_AUTH_WPA2_PSK : WIFI_AUTH_OPEN,
|
||||
.pmf_cfg = {
|
||||
.required = false,
|
||||
.ap =
|
||||
{
|
||||
.channel = channel,
|
||||
.max_connection = max_connections,
|
||||
.authmode = has_password ? WIFI_AUTH_WPA2_PSK : WIFI_AUTH_OPEN,
|
||||
.pmf_cfg =
|
||||
{
|
||||
.required = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
strlcpy((char *)wifi_config.ap.ssid, ssid, sizeof(wifi_config.ap.ssid));
|
||||
wifi_config.ap.ssid_len = strlen(ssid);
|
||||
|
||||
if (has_password)
|
||||
{
|
||||
strlcpy((char *)wifi_config.ap.password, password, sizeof(wifi_config.ap.password));
|
||||
if (has_password) {
|
||||
strlcpy((char *)wifi_config.ap.password, password,
|
||||
sizeof(wifi_config.ap.password));
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
|
||||
|
|
@ -75,10 +73,8 @@ esp_err_t wifi_start_ap(const char *ssid, const char *password, uint8_t channel,
|
|||
return ESP_OK;
|
||||
}
|
||||
|
||||
void wifi_stop_ap(void)
|
||||
{
|
||||
if (!s_wifi_started)
|
||||
{
|
||||
void wifi_stop_ap(void) {
|
||||
if (!s_wifi_started) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue