<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.tinkernet.ca/index.php?action=history&amp;feed=atom&amp;title=IoT_-_Modular_-_WiFi.cpp</id>
	<title>IoT - Modular - WiFi.cpp - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.tinkernet.ca/index.php?action=history&amp;feed=atom&amp;title=IoT_-_Modular_-_WiFi.cpp"/>
	<link rel="alternate" type="text/html" href="https://wiki.tinkernet.ca/index.php?title=IoT_-_Modular_-_WiFi.cpp&amp;action=history"/>
	<updated>2026-05-04T14:47:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.tinkernet.ca/index.php?title=IoT_-_Modular_-_WiFi.cpp&amp;diff=1547&amp;oldid=prev</id>
		<title>Tinker: Created page with &quot;==#includes, Defines, etc...==  &lt;syntaxhighlight lang=&quot;cpp&quot; line=&quot;1&quot;&gt; #include &quot;libraries.h&quot; #include &quot;functions.h&quot;  //////////////////////////////////////////////////////////...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.tinkernet.ca/index.php?title=IoT_-_Modular_-_WiFi.cpp&amp;diff=1547&amp;oldid=prev"/>
		<updated>2021-04-29T18:23:45Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==#includes, Defines, etc...==  &amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt; #include &amp;quot;libraries.h&amp;quot; #include &amp;quot;functions.h&amp;quot;  //////////////////////////////////////////////////////////...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==#includes, Defines, etc...==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;libraries.h&amp;quot;&lt;br /&gt;
#include &amp;quot;functions.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////&lt;br /&gt;
// These exist because the variables are declared elsewhere in&lt;br /&gt;
// the project.  (Specifically, in TopSecret.h)&lt;br /&gt;
extern char *WiFi_ssid;&lt;br /&gt;
extern char *WiFi_password;&lt;br /&gt;
extern char *WiFi_ClientName;&lt;br /&gt;
////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==WiFi_init()==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
// Initialize the WiFi&lt;br /&gt;
//&lt;br /&gt;
// If we don't get a connection, we just keep trying forever.&lt;br /&gt;
// Probably be an idea to eventually just give up, but most&lt;br /&gt;
// ESP8266 devices are kinda useless without the connection...&lt;br /&gt;
void WiFi_init()&lt;br /&gt;
{&lt;br /&gt;
    char debugTEXT[46];&lt;br /&gt;
&lt;br /&gt;
    WiFi.mode(WIFI_STA); // Connecting as a STATION&lt;br /&gt;
    WiFi.begin(WiFi_ssid, WiFi_password);&lt;br /&gt;
&lt;br /&gt;
    // We start by connecting to a WiFi network&lt;br /&gt;
    sprintf(debugTEXT, &amp;quot;Connecting to: %-22s&amp;quot;, WiFi_ssid);&lt;br /&gt;
    debug_SectionTitle(debugTEXT);&lt;br /&gt;
    {&lt;br /&gt;
        debug_ProgressBar0();&lt;br /&gt;
        int dotcount = 0;&lt;br /&gt;
        while (WiFi.status() != WL_CONNECTED) // Give it a bit of time to establish the WiFi connection...&lt;br /&gt;
        {&lt;br /&gt;
            dotcount++;&lt;br /&gt;
            delay(500);&lt;br /&gt;
            debug_ProgressBar1();&lt;br /&gt;
            if (dotcount &amp;gt;= 46)&lt;br /&gt;
            {&lt;br /&gt;
                debug_ProgressBar2(dotcount);&lt;br /&gt;
                dotcount = 0;&lt;br /&gt;
                debug_ProgressBar0();&lt;br /&gt;
            }&lt;br /&gt;
            // SSD1306_Static(&amp;quot;  no WiFi  &amp;quot;, 3);&lt;br /&gt;
        }&lt;br /&gt;
        debug_ProgressBar2(dotcount);&lt;br /&gt;
    }&lt;br /&gt;
    sprintf(debugTEXT, &amp;quot;WiFi connected on Channel %-2d&amp;quot;, WiFi.channel());&lt;br /&gt;
    debug_LineOut(debugTEXT);&lt;br /&gt;
    sprintf(debugTEXT, &amp;quot;IP address: %-15s&amp;quot;, WiFi.localIP().toString().c_str());&lt;br /&gt;
    debug_LineOut(debugTEXT);&lt;br /&gt;
&lt;br /&gt;
    sprintf(debugTEXT, &amp;quot;My name is NOT %-22s&amp;quot;, wifi_station_get_hostname());&lt;br /&gt;
    debug_LineOut(debugTEXT);&lt;br /&gt;
    sprintf(debugTEXT, &amp;quot;Really... It's %-22s&amp;quot;, WiFi_ClientName);&lt;br /&gt;
    debug_LineOut(debugTEXT);&lt;br /&gt;
&lt;br /&gt;
    // SSD1306_Static(&amp;quot; WiFi good &amp;quot;, 3);&lt;br /&gt;
&lt;br /&gt;
    // Add &amp;quot;build_flags = -D DEBUG1&amp;quot; to your platformio.ini to get some extra WiFi stats&lt;br /&gt;
#ifdef DEBUG1&lt;br /&gt;
    WiFi.printDiag(Serial);&lt;br /&gt;
    sprintf(debugTEXT, &amp;quot;RSSI: %d dBm&amp;quot;, WiFi.RSSI());&lt;br /&gt;
    debug_LineOut(debugTEXT);&lt;br /&gt;
    sprintf(debugTEXT, &amp;quot;HostName: %-13s !!!! BULLSHIT !!!!&amp;quot;, WiFi.hostname().c_str());&lt;br /&gt;
    debug_LineOut(debugTEXT);&lt;br /&gt;
    // Apparently, the ESP8266WiFi library does not actually support DHCP completely&lt;br /&gt;
    // { https://www.reddit.com/r/arduino/comments/d6mvc7/getting_hostname_from_dhcp_with_esp8266/ }&lt;br /&gt;
    // { https://github.com/esp8266/Arduino/issues/5695 }&lt;br /&gt;
#endif&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==WiFi_strength()==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
int WiFi_strength()&lt;br /&gt;
{&lt;br /&gt;
    return (WiFi.RSSI());&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==WiFi_Test()==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
int blip[3] = {000, 255, 000};  // GRN&lt;br /&gt;
&lt;br /&gt;
void WiFi_Test()  // Is Good...  Maybe&lt;br /&gt;
{&lt;br /&gt;
    if (WiFi.status() != WL_CONNECTED)&lt;br /&gt;
    {&lt;br /&gt;
        Serial.println(&amp;quot;Oh Poop!&amp;quot;);&lt;br /&gt;
        blip[0] = 128;&lt;br /&gt;
        blip[1] = 128;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
    if (blip[1] == 255)&lt;br /&gt;
        blip[1] = 0;&lt;br /&gt;
    else&lt;br /&gt;
        blip[1] = 255;&lt;br /&gt;
    }&lt;br /&gt;
#ifdef d_Pixels&lt;br /&gt;
    SetAPixel(3, blip);&lt;br /&gt;
#endif // d_Pixels&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==WiFi_Test2()==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
int blip2[3] = {255, 000, 000}; // RED&lt;br /&gt;
&lt;br /&gt;
void WiFi_Test2() // Lost WiFi&lt;br /&gt;
{&lt;br /&gt;
    if (blip2[0] == 255)&lt;br /&gt;
        blip2[0] = 0;&lt;br /&gt;
    else&lt;br /&gt;
        blip2[0] = 255;&lt;br /&gt;
#ifdef d_Pixels&lt;br /&gt;
    SetAPixel(3, blip2);&lt;br /&gt;
#endif // d_Pixels&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==WiFi_Test3()==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
int blip3[3] = {255, 128, 000}; // ORA&lt;br /&gt;
&lt;br /&gt;
void WiFi_Test3() // lost MQTT&lt;br /&gt;
{&lt;br /&gt;
    if (blip3[0] == 255)&lt;br /&gt;
    {&lt;br /&gt;
        blip3[0] = 0;&lt;br /&gt;
        blip3[1] = 0;&lt;br /&gt;
        blip3[2] = 0;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
        blip3[0] = 255;&lt;br /&gt;
        blip3[1] = 128;&lt;br /&gt;
        blip3[2] = 000;&lt;br /&gt;
    }&lt;br /&gt;
#ifdef d_Pixels&lt;br /&gt;
    SetAPixel(3, blip3);&lt;br /&gt;
#endif // d_Pixels&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinker</name></author>
		
	</entry>
</feed>