<commit_before>/**
 * Ai-Thinker RGBW Light Firmware - WiFi Module
 *
 * The WiFi module holds all the code to manage all functions for setting up the
 * WiFi connection.
 *
 * This file is part of the Ai-Thinker RGBW Light Firmware.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.

 * Created by <NAME> <stelgenhof at gmail dot com>
 * (https://www.sachatelgenhof.nl)
 * Copyright (c) 2016 - 2017 <NAME>
 */

// ---------------------------
// Core functions
// ---------------------------

/**
 * @brief Bootstrap function for the WiFi connection
 */
void setupWiFi() {

  // Set WiFi hostname
  if (strlen(cfg.hostname) == 0) {
    strcpy(cfg.hostname, getDeviceID());
    EEPROM_write(cfg);
  }
  WiFi.hostname(cfg.hostname);

  // Set WiFi module to STA mode and set Power Output
  if (WiFi.getMode() != WIFI_STA) {
    WiFi.mode(WIFI_STA);
    WiFi.setOutputPower(WIFI_OUTPUT_POWER);
  }

  // Connecting
  WiFi.disconnect();
  DEBUGLOG("[WIFI] Connecting to %s\n", cfg.wifi_ssid);
  WiFi.begin(cfg.wifi_ssid, cfg.wifi_psk);
  MDNS.begin(cfg.hostname);
  MDNS.addService("http", "tcp", 80);

  // Check connection and switch to AP mode if no connection
  if (WiFi.waitForConnectResult() != WL_CONNECTED) {
    DEBUGLOG("[WIFI] Connection not established! Changing into AP mode...\n");
<commit_msg>In AP mode have the DNS service listen to 'AiLight.local' in order to make initial access more easier.<commit_after>/**
 * Ai-Thinker RGBW Light Firmware - WiFi Module
 *
 * The WiFi module holds all the code to manage all functions for setting up the
 * WiFi connection.
 *
 * This file is part of the Ai-Thinker RGBW Light Firmware.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.

 * Created by <NAME> <<EMAIL> at gmail dot com>
 * (https://www.sachatelgenhof.nl)
 * Copyright (c) 2016 - 2017 <NAME>
 */

// ---------------------------
// Core functions
// ---------------------------

/**
 * @brief Bootstrap function for the WiFi connection
 */
void setupWiFi() {

  // Set WiFi hostname
  if (strlen(cfg.hostname) == 0) {
    strcpy(cfg.hostname, getDeviceID());
    EEPROM_write(cfg);
  }
  WiFi.hostname(cfg.hostname);

  // Set WiFi module to STA mode and set Power Output
  if (WiFi.getMode() != WIFI_STA) {
    WiFi.mode(WIFI_STA);
    WiFi.setOutputPower(WIFI_OUTPUT_POWER);
  }

  // Connecting
  WiFi.disconnect();
  DEBUGLOG("[WIFI] Connecting to %s\n", cfg.wifi_ssid);
  WiFi.begin(cfg.wifi_ssid, cfg.wifi_psk);
  if (MDNS.begin(WiFi.getMode() == WIFI_AP ? HOSTNAME : cfg.hostname)) {
    MDNS.addService("http", "tcp", 80);
  }

  // Check connection and switch to AP mode if no connection
  if (WiFi.waitForConnectResult() != WL_CONNECTED) {
    DEBUGLOG("[WIFI] Connection not established! Changing into AP mode...\n");

{'fraction_non_alphanumeric': 0.1559158330458779, 'fraction_numerical': 0.0075888237323214905, 'mean_word_length': 2.9835164835164836, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2429738', 'n_tokens_mistral': 987, 'n_tokens_neox': 960, 'n_words': 295}