ESP8266 + iOS devices will not connect? (help)

I am trying to following along with this tutorials here:

http://www.esp8266.com/viewtopic.php?f=32&t=3618

Which is a GREAT start for what I want to do on my current project…
(ESP in AP mode so I can connect directly to it… without any/need of local network, servers up an ‘embedded’ page, and will post back to itself … parsing the query params and passing it along (via serial) to a connect Pro-Micro)

I have both Arduino IDE v1.6.7 and v1.6.4 with board manager/install for the ESP8266 JSON file…etc

Reading this post here:
http://www.esp8266.com/viewtopic.php?f=32&t=3618&start=48#p45454

I only used the .ino/sketch posted here:

http://www.esp8266.com/viewtopic.php?f=32&t=3618&start=40#p23900

This default .ino file:

  • uploads fine (although it seems to take FOREVER!) :slight_smile:
  • connects fine using my Android (HTC One M8) phone…
  • will not connect to iPhone
  • will not connect to iPad/iPad mini

I keep getting the URI Not Found error message/output when trying to connect using an iOS device…

at that point it disconnects from the ESP AP… and re-connects to my local/saved wi-fi network.

I have done some searching… but I cant really grasp what is wrong?

  • if this is in fact working for others using iOS device (as mentioned in the thread)… then do I not have the correct files or something? What should be updated? (one of those posts above says those DNS lib files are not needed as they are now included?)

  • I read that the iOS devices are looking for a header and/or ‘success’ return message?

(I found some lines of code to send a header first…but it didnt seem to change anything)

What can I do to get this working?

(I hope someone chimes in with a response!)

I’m not sure if I need to update some core/lib file somewhere?

I’m not even clear where to update the:
DNSServer.h
DNSServer.cpp

files? If this all come through as core files from the install form the boards manager??

Anyone has some feedback? Direction?

I’m not clear if I have the correct updated files? (one of those links above makes me believe so)

If I ‘do’ have the correct/most current files… then?

1.) How are others claiming their projects working with iOS?

2.) Am I missing some sort of header to be sent? or handle some incorrect response?

Questions about this current sketch:

1.) Why is the HTML string data formatted like that?

const char* html = "<html><head><title>Success</title><style>.bt{display:block;width:250px;height:100px;padding:10px;margin:10px;"
                    "text-align:center;border-radius:5px;color:white;font-weight:bold;font-size:70px;text-decoration:none;} "
                    "body{background:#000;} .r{background:#933;} .g{background:#363;} .y{background:#EE0;height:100px;"
                    "width:100px;border-radius:50px;} .b{background:#000;height:100px;width:100px;border-radius:50px;} "
                    ".a{font-size:35px;} td{vertical-align:middle;}</style>"
                    "</head><body><table><tr><td><div class='TGT0'></div></td><td><a class='bt g' href='/L0?v=1'>ON</a></td>"
                    "<td><a class='bt r' href='/L0?v=0'>OFF</a></td></tr><tr><td><div class='TGT2'></div></td><td>"
                    "<a class='bt g' href='/L2?v=1'>ON</a></td><td><a class='bt r' href='/L2?v=0'>OFF</a></td></tr>"
                    "<tr><td>&nbsp;</td><td><a class='bt g a' href='/ALL?v=1'>
ALL ON</a></td><td>"
                    "<a class='bt r a' href='/ALL?v=0'>
ALL OFF</a></td></tr></body></html>"; - See more at: http://www.esp8266.com/viewtopic.php?f=32&t=3618&start=40#p23900

with all the spacing? and the “double quotes” around each line?

Is this done for readability?
length issues?

  • I created a new sketch… (exact copy of original) and edited the HTML to be VERY minimal…
  • the original codes loads/displays almost instantly.
  • edited HTML (trimmed down to only table, one tr/td and some text in it) take several seconds to load?

Re-Cap: Using the links above… I have the current version of the sketch provided by SwiCago.

I have installed ESP 2.1.0 support in boards manager (JSON file import)

When I try to connect to ESP device using iOS device… I get the URI not found message. Android devices work fine so far.

=================================================================================

Side topics/questions: (just for chit-chat/communication about ESP stuff in general)

1.) I have never been ‘clear’ on what firmware to load onto the ESP modules?

  • I believe mine came ‘blank’… as throwing AT commands at it didnt do anything, I loaded some 0.9.2/5 AT firmware to it… and when I did the AT command through serial monitor… I got “OK” as my response…

Do you leave the AT firmware on it… and upload your sketch as normal? (Thats what I have been doing)

When do you flash to say nodeMCU firmware? (difference? benefits?)

Or any of the other flavors out there?

2.) What is the preferred? (and differences) Software/toolchain to be used with these?

  • I read there is a standalone “ESP Arduino IDE”??
  • I read you can add support for Arduino IDE 1.6.4 and above using the boards manager JSON file? (this is what I did)
  • I have seen no less than 4 ESP ‘flasher’ apps? Some take one .bin file? some come along with many .bin files that need to be written to certain sectors/sections/address on the ESP

I’d like to maybe talk about what we ‘here’ on the Arduino forum consider the ‘go-to’ tool chain? At least an agreed upon process that can be referred back to,…or communicated to new members doing the same things?

3.) When I upload a sketch using the Arduino IDE (1.6.4)… the sketch eventually uploads… but sure does take a LONG TIME… (very long)…

Is this normal? Is it a setting I may have wrong in my Tools >> ESP board options?

I have it as:

Flash Mode: DIO
Flash Freq: 40MHz
Upload: Serial
CPU Freq: 80MHz
Flash Size: 64k SPIFFS
Debug Port: Disabled
Debug Level: None
Reset Method: ck
Upload Speed: 9600 ← have tried to change this to 115200 (didnt seem to change the speed of anything IMO)

TIP(s):
(this may depend on the current firmware, and the manual you find)

But I tried to change the default baudrate on my ESP… and it completely bricked it…

After some searching, I guess:

AT+CIOBAUD is no longer supported? (again I guess it depends on the version of firmware)

and were supposed to use:

AT+IPR instead.

Just an FYI… in case you brick yours… and you need to try and re-flash some firwarm back to it get it to be responsive again.

  • There are two DNS server files that have been edited, but the thread is old, and another post IN SAME thread says these updates are current int he core JSON files?

(post was too long)

example (stock) sketch to check out:

stock code (sketch) example:

[code]#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <DNSServer.h>
 
const char* ssid     = "esp8266";
boolean LEDstate[] = {LOW, false, LOW};

const char* html = "<html><head><title>Success</title><style>.bt{display:block;width:250px;height:100px;padding:10px;margin:10px;"
                    "text-align:center;border-radius:5px;color:white;font-weight:bold;font-size:70px;text-decoration:none;} "
                    "body{background:#000;} .r{background:#933;} .g{background:#363;} .y{background:#EE0;height:100px;"
                    "width:100px;border-radius:50px;} .b{background:#000;height:100px;width:100px;border-radius:50px;} "
                    ".a{font-size:35px;} td{vertical-align:middle;}</style>"
                    "</head><body><table><tr><td><div class='TGT0'></div></td><td><a class='bt g' href='/L0?v=1'>ON</a></td>"
                    "<td><a class='bt r' href='/L0?v=0'>OFF</a></td></tr><tr><td><div class='TGT2'></div></td><td>"
                    "<a class='bt g' href='/L2?v=1'>ON</a></td><td><a class='bt r' href='/L2?v=0'>OFF</a></td></tr>"
                    "<tr><td>&nbsp;</td><td><a class='bt g a' href='/ALL?v=1'>
ALL ON</a></td><td>"
                    "<a class='bt r a' href='/ALL?v=0'>
ALL OFF</a></td></tr></body></html>";

const byte DNS_PORT = 53;
IPAddress apIP(192, 168, 1, 1);
IPAddress netMsk(255, 255, 255, 0);
DNSServer dnsServer;
ESP8266WebServer server(80);

void setup() {
  pinMode(0, OUTPUT);
  pinMode(2, OUTPUT);
  digitalWrite(2, LEDstate[0]);
  digitalWrite(2, LEDstate[2]);
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(apIP, apIP, netMsk);
  WiFi.softAP(ssid);
  Serial.print("SSID: ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.softAPIP());
  dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
  dnsServer.start(DNS_PORT, "*", apIP);
  Serial.println("USP Server started");
  server.on("/", handle_root);
  server.on("/generate_204", handle_root);  //Android captive portal
  server.on("/L0", handle_L0);
  server.on("/L2", handle_L2);
  server.on("/ALL", handle_ALL);
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println("HTTP server started");

}

void loop() {
  dnsServer.processNextRequest();
  server.handleClient();
}

void handleNotFound() {
  Serial.print("\t\t\t\t URI Not Found: ");
  Serial.println(server.uri());
  server.send ( 200, "text/plain", "URI Not Found" );
}

void handle_root() {
  Serial.println("Page served");
  String toSend = html;
  toSend.replace("TGT0", LEDstate[0] ? "y" : "b");
  toSend.replace("TGT2", LEDstate[2] ? "y" : "b");
  server.send(200, "text/html", toSend);
  delay(100);
}

void handle_L0() {
  change_states(0);
  handle_root();
}

void handle_L2() {
  change_states(2);
  handle_root();
}

void handle_ALL() {
  change_states(0);
  change_states(2);
  handle_root();
}

void change_states(int tgt) {
  if (server.hasArg("v")) {
    int state = server.arg("v").toInt() == 1;
    Serial.print("LED");
    Serial.print(tgt);
    Serial.print("=");
    Serial.println(state);
    LEDstate[tgt] = state ? HIGH : LOW;
    digitalWrite(tgt, LEDstate[tgt]);
  }
}

bump^

anybody? :slight_smile:

why didn't you post this on the esp forum. people there are more likely to know.

my esp usually takes about 20 seconds to upload. if you implement ota flashing, it takes about three seconds.

I might would try changing the ap to 192.168.0.1

Apple devices are kind of picky. I had to do that to fix a wireless camera once.

I think the best way to flash an esp is to use ota flashing with arduino ide 1.6.9 and using esp core 2.20. If you use ofa flashing, you don't have to mash buttons to put it into boot loader mode.

I did post this there..

I have yet to have not one post get a response (even a me too! reply) at that forum.

I can try changing the IP.. see if that does anything.. but my gut says its something to do with the DNSServer.h/.cpp mods?

However.. I am not sure those are located if 'part of the core' like that link above mentions.

Do you use 1.6.9? I updated one machine to 1.6.7 and it was quite the PITA!. DIdnt work with WIn7 at first.. other compatibility issues..

When you say ESP Core 2.20.. what do you mean exactly?

Do you mean install from the board manager JSON file? v.2.20?

If so.. I checked my 1.6.7 IDE install.. and I have v.2.20 there.. (I should check my 1.6.4 install I have been using!... as well as do some tests on my 1.6.7 IDE install to see if same things happen.)

thanks!

update 1:
I tried to load the default sketch using IDE 1.6.7.. wouldnt even compile for some reason.
*(again., 1.6.7 IDE has v2.20 JSON ESP install in board manager)

This is not what I am doing with my project.. but I ran across this post:

https://www.hackster.io/rayburne/esp8266-captive-portal-5798ff?ref=user&ref_id=506&offset=3
that leads to here talking about IDE 1.6.7 IDE and 'his' code.. but maybe its the same issue?
https://www.hackster.io/rayburne/warwalking-a9c021

back to IDE 1.6.4 machine.. at least that uploads!..lol

Iphones get lost if you have the same ip as the wifi you use at home.
Your using the esp as access point set on 192.168.0.0 that would be the gate way address.
Then say you have wifi and the the Iphone gets a ip of 198.168.0.5 the esp gives it one of 198.168.0.6
The iphone didn't update the dns the phone is now lost in routing.
My kids iphones get lost like that I have fixed the routing on them a bunch of time playing with the esp

"playing with the esp"....how?

Are you talking about changing the IP stuff around?

I can try address 10.10.0.0 or whatever.. (shouldnt matter from what I read)

Also.. last night trying IDE 1.6.4 and updating the ESP 'core/JSON' install to 2.2.0..

I tried an iPad mini again.. same result.. however this time.. when checking the wi-fi networks available, and connecting to the 'esp' again.. I saw a message/tab say connect not using internet (and some other option, maybe 'other', I dont recall).. and I chose the connect not through interneet option.. and my HTML page from the ESP displayed..

I think this has something to do with the iOS 'CNA'? (read that mentioned a few times elsewhere)

I just told you that in my post it's because there's no dns with the iPad or phone it wants the DNS server so I set my kids up with that settings manually. Even with are wifi it has problems thats why I use a s7 lol
But I've use the esp to turn on lamps my s7 worked fine but the iPhone I had to set it all manually but they work too after that you can log onto the esp just like a Hotspot

Thanks for 'just telling me'... but it was clear, hence the re-question.

I guess I'm still confused on why others arent having these issues then?

Others in the post/thread linked to seem to state it works fine for them on iOS.

Also: 192, 168, 1, 1

it NOT the same IP as my wi-fi at home. (not sure where you got that from)

but because my wi-fi network credentials were SAVED from a previous connection.. after 'disconnecting' from the AP (yes it makes connection).. it will show the no URI error message.. un-connect from my ESP AP.. and then connect back to my default wi-fi network.

const byte DNS_PORT = 53;
IPAddress apIP(192, 168, 1, 1);
IPAddress netMsk(255, 255, 255, 0);

but doesnt matter if I use 10, 10, 0, 0 either..

in AP mode.. you should -not- need any sort of wi-fi network.. (its the whole point of it being an AP)

I could take this thing out to the 'boonies'.. without a network in sight.. and still be able to connect with my cell phone directly to the AP.. and have it server up a page.

In the thread.. there was/is talk about the DNSServer lib files being mod'd... that (I believed) corrected this.

Another post (page 13/14?) after states no need to update these lib files anymore as they are now part of the new 'core'.

I'm wondering if I do not have the most up-to-date DNSServer.h/.cpp files?

and if not.. where do I update these? I did a search and didnt find them?

It's not the esp it's the iPhone it wants dns server wants to have you on the internet

That is NOT what is being reported in that thread linked to:

"Burkmurry and others, I can confirm that Blackies code change, which I quoted above works for Android and iOS and returns correct DNS response. In order to make Android go to Captive portal login I added Blackies code change plus the following in setup"

along with other reference to it working iOS/OSX devcies

Try changing your handleNotFound function to this:

void handleNotFound(){
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  Serial.print(message);
  server.send(404, "text/plain", message);
}

That should feed information back to you and the web browser about WHAT was ‘not found’.

Thanks John-

I'll give it a 'go' and see what it spits out.

(stay tuned!) :slight_smile:

xl97:
Questions about this current sketch:

1.) Why is the HTML string data formatted like that?

const char* html = "<html><head><title>Success</title><style>.bt{display:block;width:250px;height:100px;padding:10px;margin:10px;"

“text-align:center;border-radius:5px;color:white;font-weight:bold;font-size:70px;text-decoration:none;} "
                   “body{background:#000;} .r{background:#933;} .g{background:#363;} .y{background:#EE0;height:100px;”
                   “width:100px;border-radius:50px;} .b{background:#000;height:100px;width:100px;border-radius:50px;} "
                   “.a{font-size:35px;} td{vertical-align:middle;}”
                   “”
                   “”
                   "”;



with all the spacing? and the "double quotes" around each line?
Is this done for readability?
length issues?

The spaces outside of the quotes are not part of the string.
Most spaces inside the quotes were removed because they are irrelevant to the resulting display and just waste bandwidth. Adjacent string constants are merged so all of the lines get merged into one. They are split into reasonable-length lines for readability and editability. You could write it as one line but that makes it hard to read and edit.

ON OFF

                   “ON
OFF
 
ALL ON

                   "
ALL OFF

@johnwasser

thanks for clarification on the string (ie: readability only)

I have some ‘strange’ results on my current project…

after updating to ESP/JSON board manager files to 2.2.0

I ‘could’ connect to using my iPad mini… I had gotten a pop-up option to connect -NOT- using the internet or OTHER,… I chose connect not using internet… and BOOM! the page displayed.

I had updated to 2.2.0 AFTER that (I believe)… and also tried connecting using my wifes and kids iPad mini’s…

all seemed to work without getting that pop-up/prompt.

I am also using your new function handler as well… not sure if that helped anything or not? (sending 404?)…

I do have some output recorded fro each connection (Android, iPad with no internet connection chosen, and the iPad ‘default/as-is’)…

my current code is the following: (updated for easier readability only)

  • IDE 1.6.4
  • Board Manager: ESP 2.2.0 JSON version
//upload @9600 if any troubles

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <DNSServer.h>

const char* ssid = "esp8266-1";

const byte DNS_PORT = 53;
IPAddress apIP(10, 10, 0, 1);
IPAddress netMsk(255, 255, 255, 0);
DNSServer dnsServer;
ESP8266WebServer server(80);

const char* html = "<html><head><title>Success</title><style>.btn{display:block;width:250px;height:100px;padding:10px;margin:10px;"
                  "text-align:center;border-radius:5px;color:white;font-weight:bold;font-size:70px;text-decoration:none;}"
                  "body{background:#000;}.red{background:#933;}.green{background:#363;}.onstate{background:#EE0;height:100px;"
                  "width:100px;border-radius:50px;}.offstate{background:#000;height:100px;width:100px;border-radius:50px;}"
                  ".smallfont{font-size:35px;}td{vertical-align:middle;}</style></head><body><table><tr><td><div class='lstate0'>"
                  "</div></td><td><a class='btn green' href='/L0?v=1'>ON</a></td><td><a class='btn red' href='/L0?v=0'>OFF</a></td>"
                  "</tr><tr><td><div class='lstate1'></div></td><td><a class='btn green' href='/L2?v=1'>ON</a></td><td>"
                  "<a class='btn red' href='/L2?v=0'>OFF</a></td></tr><tr><td>&nbsp;</td><td><a class='btn green smallfont' href='/ALL?v=1'>"
                  "
ALL ON</a></td><td><a class='btn red smallfont' href='/ALL?v=0'>
ALL OFF</a></td></tr></table></body></html>";

boolean LEDstate[] = {LOW, false, LOW};

void setup() {
  Serial.begin(115200);

  Serial.setDebugOutput(true);

  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(apIP, apIP, netMsk);
  WiFi.softAP(ssid);
  Serial.print("SSID: ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.softAPIP());
  dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
  dnsServer.start(DNS_PORT, "*", apIP); // '*' sets it to captive portal/esp itself

  pinMode(0, OUTPUT);
  pinMode(2, OUTPUT);
  digitalWrite(2, LEDstate[0]);
  digitalWrite(2, LEDstate[2]);

  Serial.println("USP Server started");
  server.on("/", handle_root);
  server.on("/generate_204", handle_root);  //Android captive portal
  server.on("/L0", handle_L0);
  server.on("/L2", handle_L2);
  server.on("/ALL", handle_ALL);
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println("HTTP server started");

}

void loop() {
  dnsServer.processNextRequest();
  server.handleClient();
}

void handleNotFound_og() {
  Serial.print("\t\t\t\t URI Not Found: ");
  Serial.println(server.uri());
  server.send ( 200, "text/plain", "URI Not Found" );
}


void handleNotFound() {
  String message = "URI Not Found\n\n";
  message += "Target URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  Serial.print(message);
  server.send(404, "text/plain", message);
}

void handle_root() {
  Serial.println("Page served");
  String htmlString = html;
  htmlString.replace("lstate0", LEDstate[0] ? "onstate" : "offstate");
  htmlString.replace("lstate1", LEDstate[2] ? "onstate" : "offstate");
  server.send(200, "text/html", htmlString);
  delay(100);
}

void handle_L0() {
  change_states(0);
  handle_root();
}

void handle_L2() {
  change_states(2);
  handle_root();
}

void handle_ALL() {
  change_states(0);
  change_states(2);
  handle_root();
}

void change_states(int tgt) {
  if (server.hasArg("v")) {
    int state = server.arg("v").toInt() == 1;
    Serial.print("LED");
    Serial.print(tgt);
    Serial.print("=");
    Serial.println(state);
    LEDstate[tgt] = state ? HIGH : LOW;
    digitalWrite(tgt, LEDstate[tgt]);
  }
}

The uploading has been flakey/sketchy at BEST!.. usually I need to unplug the ESP module… and then try again for an upload…

One of the biggest issues I am having now is…

it seems to stop broadcasting the SSIS/available network after a few minutes??

And I’m not clear as to why this could be happening?

even a power cycle doesnt seem to bring it ‘back on line’ (so to speak)… I literally need to re-upload the sketch… (which seems super odd to me)

I havent tried find any pattern to this yet (after a certain time length? after an initial ‘connection’ from any device?..etc)

maybe a power issue? although I’m not clear why it would broadcast fine a while…then stop?

here are my results/output from using your handler method:

Android  Output:



add 1
aid 1
station: 00:ee:bd:a0:ec:d5 join, AID = 1
Page served
add 2
aid 2
station: 68:9c:70:48:0e:be join, AID = 2
File Not Found

URI: /bag
Method: GET
Arguments: 0
File Not Found

URI: /bag
Method: GET
Arguments: 0


station: 68:9c:70:48:0e:be leave, AID = 2
rm 2


After I opened up chrome and requested abc.com

Page served
Page served
Page served
LED0=1
LED2=1
Page served
File Not Found

URI: /favicon.ico
Method: GET
Arguments: 0




=====================================

iPad: (connect not using internet option clicked one time.. never got it again)



add 1
aid 1
station: 68:9c:70:48:0e:be join, AID = 1
File Not Found

URI: /bag
Method: GET
Arguments: 0
File Not Found

URI: /bag
Method: GET
Arguments: 0
File Not Found

URI: /bag
Method: GET
Arguments: 0


==========================================================


ipad 2:



add 2
aid 2
station: 68:9c:70:46:7d:85 join, AID = 2
File Not Found

URI: /eEdpzlCl/RF9ZcejQ.html
Method: GET
Arguments: 0




after page request:
File Not Found

URI: /bag
Method: GET
Arguments: 0
File Not Found

URI: /assets/com_apple_MobileAsset_SafariCloudHistoryConfiguration/com_apple_MobileAsset_SafariCloudHistoryConfiguration.xml
Method: GET
Arguments: 0
File Not Found

URI: /assets/com_apple_MobileAsset_SafariCloudHistoryConfiguration/com_apple_MobileAsset_SafariCloudHistoryConfiguration.xml
Method: GET
Arguments: 0
Page served

I have also gotten several ‘errors’ (hangs during compile…odd error messages…etc)

  • about the String.replace lines
  • when I had the new HTML string all as one line

maybe coincidence stemming from other issues?

my main focus now is the loss of connection and broadcasting of SSID/available wi-fi network

thanks!

Since you only have handlers for "/", "/generate_204", "/L0", "/L2", and "/ALL" it makes sense that requests for "/bag" are resulting in File Not Found. Is the "/bag" from something you wrote or is it something the iPhone/iPad does on its own?

default from iPad I believe…

when doing some testing and having a buddy try to connect with an iPhone (not iPad)…

I got/hot-spot-detect.html URL as well in the mix…

Also… when my buddy tried to connect using his iPhone he got error message (URI not found)… but when I use iPad (mine at least)… the page DOES load…

any ideas on the connection issues? (maybe something to save for later?)

not sure if using diff. IP’s has any difference on results?

latest code version:

//upload @9600 if any troubles

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <DNSServer.h>

const char* ssid = "esp8266-1";

const byte DNS_PORT = 53;
IPAddress apIP(10, 10, 0, 1);
IPAddress netMsk(255, 255, 255, 0);
DNSServer dnsServer;
ESP8266WebServer server(80);

const char* html = "<html><head><title>Success</title><style>.btn{display:block;width:250px;height:100px;padding:10px;margin:10px;"
                  "text-align:center;border-radius:5px;color:white;font-weight:bold;font-size:70px;text-decoration:none;}"
                  "body{background:#000;}.red{background:#933;}.green{background:#363;}.onstate{background:#EE0;height:100px;"
                  "width:100px;border-radius:50px;}.offstate{background:#000;height:100px;width:100px;border-radius:50px;}"
                  ".smallfont{font-size:35px;}td{vertical-align:middle;}</style></head><body><table><tr><td><div class='lstate0'>"
                  "</div></td><td><a class='btn green' href='/L0?v=1'>ON</a></td><td><a class='btn red' href='/L0?v=0'>OFF</a></td>"
                  "</tr><tr><td><div class='lstate1'></div></td><td><a class='btn green' href='/L2?v=1'>ON</a></td><td>"
                  "<a class='btn red' href='/L2?v=0'>OFF</a></td></tr><tr><td>&nbsp;</td><td><a class='btn green smallfont' href='/ALL?v=1'>"
                  "
ALL ON</a></td><td><a class='btn red smallfont' href='/ALL?v=0'>
ALL OFF</a></td></tr></table></body></html>";

boolean LEDstate[] = {LOW, false, LOW};

void setup() {
  Serial.begin(115200);

  Serial.setDebugOutput(true);

  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(apIP, apIP, netMsk);
  WiFi.softAP(ssid);
  Serial.print("SSID: ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.softAPIP());
  dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
  dnsServer.start(DNS_PORT, "*", apIP); // '*' sets it to captive portal/esp itself

  pinMode(0, OUTPUT);
  pinMode(2, OUTPUT);
  digitalWrite(2, LEDstate[0]);
  digitalWrite(2, LEDstate[2]);

  Serial.println("USP Server started");
  server.on("/", handle_root);
  server.on("/hotspot-detect.html", handle_iphone);
  server.on("/bag.html", handle_ipad);
  server.on("/generate_204", handle_root);  //Android captive portal
  server.on("/L0", handle_L0);
  server.on("/L2", handle_L2);
  server.on("/ALL", handle_ALL);
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println("HTTP server started");

}

void loop() {
  dnsServer.processNextRequest();
  server.handleClient();
}

void handleNotFound_og() {
  Serial.print("\t\t\t\t URI Not Found: ");
  Serial.println(server.uri());
  server.send ( 200, "text/plain", "URI Not Found" );
}


void handleNotFound() {
  String message = "URI Not Found\n\n";
  message += "Target URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  Serial.print(message);
  server.send(404, "text/plain", message);
}

void handle_root() {
  Serial.println("Page served");
  String htmlString = html;
  htmlString.replace("lstate0", LEDstate[0] ? "onstate" : "offstate");
  htmlString.replace("lstate1", LEDstate[2] ? "onstate" : "offstate");
  server.send(200, "text/html", htmlString);
  delay(100);
}

void handle_iphone() {
  Serial.println("Page served");
  String toSend = html;
  toSend.replace("TGT0", LEDstate[0] ? "y" : "b");
  toSend.replace("TGT2", LEDstate[2] ? "y" : "b");
  server.send(200, "text/html", toSend);
  delay(100);
}

void handle_ipad() {
  Serial.println("Page served");
  String toSend = html;
  toSend.replace("TGT0", LEDstate[0] ? "y" : "b");
  toSend.replace("TGT2", LEDstate[2] ? "y" : "b");
  server.send(200, "text/html", toSend);
  delay(100);
}


void handle_L0() {
  change_states(0);
  handle_root();
}

void handle_L2() {
  change_states(2);
  handle_root();
}

void handle_ALL() {
  change_states(0);
  change_states(2);
  handle_root();
}

void change_states(int tgt) {
  if (server.hasArg("v")) {
    int state = server.arg("v").toInt() == 1;
    Serial.print("LED");
    Serial.print(tgt);
    Serial.print("=");
    Serial.println(state);
    LEDstate[tgt] = state ? HIGH : LOW;
    digitalWrite(tgt, LEDstate[tgt]);
  }
}

@johnwasser

Well I have another piece of the puzzle in regards to the ESP not broadcasting the SSID/cant connect to it after a short period of time..

so I left my serial monitor open and 'waited'... after I saw the ESP was no longer available in my available wi-fi networks...

I checked the serial monitor and saw the ESP was in-fact being RESET!!!!

RST cause:4, boot mode:(1, 6) (now I just need to search about the watchdog timer reset stuff)

a quick search says that cause: 4 is the watchdog timer!?

How (why) is becoming factor/issue here?

update:

DOH!..

ok.. I believe "I" may have been causing the REST issues..

When uploading sketch/flashing firmware.. I have been leaving my GPIO0 pin connected to GND..

After reading up on the REST error codes above.. it was the watchdog and being in bootloader mode.

It 'clicked' that I probably shouldnt be leaving the GPIO0 pin LOW when I'm trying to 'use' it..

so far it has been broadcasting and available for over 15-20+ minutes!

For iPad/iPhone devices...

I changed the IP back to be 10, 10, 0, 1 (or whatever).. just to eliminate any issues as suggested by @be80be

I also added in handlers for both /bag and /hotspot-detect

(/bag was from iPad, /hotspot-detect was from new iPhone)