ESP8266 WIFI hacks | DIMI’s place

DIMI's place

My thoughts on different things

13 August 2021

ESP8266 WIFI hacks

Inspired by Wifi - IOS hacks I wanted to check what I can do using ESP8266 & my Android phone.

Here are some capabilities that ESP8266 provides in terms of Wifi:

Set Wifi Country

It is possible to define your custom country with a custom name, and stuff like this:

#include <user_interface.h>

const wifi_country_t WM_COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO};

wifi_country_t temp_country = {
    cc:     "DZ",
    schan:  1,
    nchan:  14,
    policy: WIFI_COUNTRY_POLICY_MANUAL
};

wifi_set_country(&temp_country)

This option for some reason is ignored by Android device, but it is still nice that you can set it:

Wifi Station name & password

How to type special characters: Hold Ctrl+⇧ Shift and type U followed by up to eight hex digits (on main keyboard or numpad). Then release Ctrl+⇧ Shift.

You can set Wifi AP name or password with smilies and un-printable characters (if you can type them using unicode typing), something like this: 🌭🌯 or 🤑🤑

That’ll confuse anyone trying to connect - especially since they cannot type password with smilies, only copy-paste from other app.

#include "Arduino.h"
#include <ESP8266WiFi.h>

WiFi.mode(WIFI_AP);
const char *ssid = "🌭🌯";
const char *pass = "🤑🤑🤑🤑";

Note: You cannot set AP name larger then 32 characters - even with code modifications - it would be trimmed due to header size according to specification.

Also here’s some code to print special characters in java (I’ll do a fancy lambda, at some point instead):

class Scratch {
    public static void main(String[] args) {
        for (int z=0; z < 100; z++){
            String st="" + z;
            while (st.length() < 4) st = "0" + st;
            char c[] = Character.toChars(Integer.parseInt(st, 16));
            System.out.println(String.format("%s %d '%c'", st, c.length, c[0]));
        }
    }
}

Specify Wifi standard

#include <user_interface.h>

wifi_set_phy_mode(PHY_MODE_11B)
wifi_set_phy_mode(PHY_MODE_11N)

Manually Send packet

Haven’t tried it yet, but it is surelly possible to do:

#include <user_interface.h>

bool sent = wifi_send_pkt_freedom(packet, packetSize, 0) == 0;

Wifi Debugging:

If you need to debug why there are issues with WIFI - you can do that as below:

#include "Arduino.h"

Serial.begin(115200);
Serial.println("");
Serial.setDebugOutput(true);
tags: esp8266 - esp32 - wifi