These are chat archives for esp8266/Arduino

3rd
Jan 2016
Harrison Mclean
@h4rm0n1c
Jan 03 2016 04:01
You can in fact, twiddle the right registers and make spi unidirectional, but there's not much point in doing so, I''
I've fiddled with it, just not worth it since the esp seems to handle one side of the transaction being ignored gracefully.
sticilface
@sticilface
Jan 03 2016 10:23

I'm using mobilejquery, loaded from SPIFFS, and it works perfectly except that the first page load requires a refresh. This has been consistent for months. It happens with cache disabled, and it required for a full refresh... It is manageable but I'm curious... and want to fix it. My suspicion is that the first load of the page, sends out requests for all the javascript dependancies at the same time, which the esp can't handle. I've tried various scripts to stagger loading, and they all fail. so i thought i'd ask if anyone has any solutions. i've been trying for a while on this..

this is the first failed load
http://pasteboard.co/vV9q0pu.png

this is the next one by pressing refresh
http://pasteboard.co/vVAPsHa.png

I realise using a CDN gets around this, but i use it for a configuration tool where the client might be connected to the ESP in AP and will not have internet. maybe it would be clever of the me to implement this browser side to work out if the client machine has internet if it does use CND, if not request local copies... i'd still like to solve this issue though
Looks like the second refresh doesn't make requests for all the files.

Markus
@Links2004
Jan 03 2016 10:42

yes you have overloaded the ESP.
sequence load files on js:

function loadjs(url, callback) {
    var script = document.createElement("script");
    script.setAttribute("src", url);
    script.addEventListener('load', function() {
        var script = document.createElement("script");
        script.textContent = "(" + callback.toString()  + ")();";
        document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
}

loadjs("https://code.jquery.com/jquery-1.10.2.min.js", function() {
    window.jQ=jQuery.noConflict(true);
    loadjs("some other url", function() {
        alert("done");
    });
});

with some simple modifications you can do the same with css.

sticilface
@sticilface
Jan 03 2016 10:55
cool thanks. I will have a go now and see what i can do.. :)
Me No Dev
@me-no-dev
Jan 03 2016 11:17
@sticilface what version of the core are you using?
sticilface
@sticilface
Jan 03 2016 11:20
latest... 'but'.. this issue has been there for like 2 months.. so i don't think it is 1.5 related...
i've just decided it is annoying enough now to figure out..
not having too much luck so far though.. where do you place this script in the html to load it
Me No Dev
@me-no-dev
Jan 03 2016 11:22
I asked because I could have offered the Async server to you
but 1.5 is no good for it
sticilface
@sticilface
Jan 03 2016 11:22
o right... :)
Me No Dev
@me-no-dev
Jan 03 2016 11:23
I also wrote a small class that I use for Sync server to load resources one after another
sticilface
@sticilface
Jan 03 2016 11:23
Is this the reason for your unhappiness with 1.5?
very cool
Me No Dev
@me-no-dev
Jan 03 2016 11:23
but what @Links2004 offered will do about the same
@sticilface mostly but ot all
FWeinb
@FWeinb
Jan 03 2016 11:24
Will there be a server that can handle multiple connections in the future?
sticilface
@sticilface
Jan 03 2016 11:24
what happens then.. does the client fire off all requests simultaneously.. but the esp only responds to the first?
Me No Dev
@me-no-dev
Jan 03 2016 11:25
@FWeinb there is now
FWeinb
@FWeinb
Jan 03 2016 11:25
Oh that sounds great.
Me No Dev
@me-no-dev
Jan 03 2016 11:25
@sticilface with the Async server it behaves like any other server
it answers to all in packets
so you can load a few files at the same time
the bigger files will take longer
the "Requester" class works like @Links2004 example above, but queues all requests and executes them in order
requests can be for AJAX, sctiprs, css and so on
FWeinb
@FWeinb
Jan 03 2016 11:27
Can I just use the ESP8266WebServer and it is async now?
Me No Dev
@me-no-dev
Jan 03 2016 11:28
no that one is synchronous
handles one after another
FWeinb
@FWeinb
Jan 03 2016 11:28
And where can I find the async one?
but it does not work good with 1.5
FWeinb
@FWeinb
Jan 03 2016 11:29
How comes?
Me No Dev
@me-no-dev
Jan 03 2016 11:30
well... some changes in 1.5 can not handle the load :D
FWeinb
@FWeinb
Jan 03 2016 11:30
Okay..
Will something like that be integrated into the Arudino project?
Me No Dev
@me-no-dev
Jan 03 2016 11:30
unalign exceptions
@FWeinb it will be once the SDK is stable
I have a few things waiting
FWeinb
@FWeinb
Jan 03 2016 11:31
That sounds good.
Me No Dev
@me-no-dev
Jan 03 2016 11:31
the server runs without single issue on 1.3
API is about the same as with the current server
Hope to have it running on ESP31B by tonight as well
FWeinb
@FWeinb
Jan 03 2016 11:35
Great! The ESP32 looks very great. Did you measure the power consumption when only using Bluethooth. Would be great to create cheep beacons.
Me No Dev
@me-no-dev
Jan 03 2016 11:36
I just got mine, so I'm at the Arduino env at the moment. Have lots of things to write before I start looking into consumption :)
Chris Elsworth
@celsworth
Jan 03 2016 11:37
@me-no-dev nice, is there a repo to test with yet? it might encourage me to wire mine up
Me No Dev
@me-no-dev
Jan 03 2016 11:37
@celsworth soon :) want to get the basics running first
Chris Elsworth
@celsworth
Jan 03 2016 11:37
alright :)
Me No Dev
@me-no-dev
Jan 03 2016 11:37
it's already plugged into the IDE and Eclipse
Chris Elsworth
@celsworth
Jan 03 2016 11:38
guess I'll have to install Eclipse then :D cos I ain't touching the IDE again if I can help it
Me No Dev
@me-no-dev
Jan 03 2016 11:38
it works with the plugin for Arduino
if you have that you will only need to change the path to the core
sticilface
@sticilface
Jan 03 2016 12:02
@sticilface
ooo.... mine had an attempted delivery before new years. but I'm away for 2 months :( Have to wait
@Links2004 I've managed to get it working for the js files but I'm failing miserable for the css....
This inserts the right thing into the head, but it just doesn't work
  function loadjs(url, callback) {
    var script = document.createElement("script");
    script.setAttribute("src", url);
    script.addEventListener('load', function() {
        var script = document.createElement("script");
        script.textContent = "(" + callback.toString()  + ")();";
        document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
}
Markus
@Links2004
Jan 03 2016 12:04
not tested but shut work like this:
function loadcss(url, callback) {
    var link= document.createElement("link");
    link.setAttribute("rel", "stylesheet");
 link.setAttribute("href", url);
    link.addEventListener('load', function() {
        var script = document.createElement("script");
        script.textContent = "(" + callback.toString()  + ")();";
        document.body.appendChild(script);
    }, false);
    document.body.appendChild(link);
}
Chris Elsworth
@celsworth
Jan 03 2016 12:04
does <link> work outside <head> ?
sticilface
@sticilface
Jan 03 2016 12:05
oops.. i just posted what you gave me. hang on
Markus
@Links2004
Jan 03 2016 12:05
may not rfc conform but yes.
sticilface
@sticilface
Jan 03 2016 12:05
  function loadcss(url, callback) {
    var script = document.createElement("link");   
   script.setAttribute("rel", "stylesheeet"); 
    script.setAttribute("href", url);
    script.addEventListener('load', function() {
        var script = document.createElement("link");
        script.textContent = "(" + callback.toString()  + ")();";
        document.head.appendChild(script);
    }, false);
    document.head.appendChild(script);
}
it appends it in the right place... but it just doesn't seem to work..
Markus
@Links2004
Jan 03 2016 12:06
the second var script = document.createElement("link"); is the problem, the callback is still javascript :)
sticilface
@sticilface
Jan 03 2016 12:10
ooo.. you genius..
thanks
i've been bugged by this for MONTHS...
the final.. thing.. is i've place all this at the end of the body... but it shows the html.. with css first before the jQuery, etc has rendered... can i stop this?
Markus
@Links2004
Jan 03 2016 12:13
you need a loading screen :)
Chris Elsworth
@celsworth
Jan 03 2016 12:13
no, this is why traditionally css and js go at the top, so the browser downloads/parses them before the html
this is really a hack :)
Markus
@Links2004
Jan 03 2016 12:14
hide all html contend in a div and only show the loading screen, if you have fun you can add a % bar since you know how many files will be loaded.
Chris Elsworth
@celsworth
Jan 03 2016 12:14
put your css/js on a cdn and load them from there? or is there no network access?
loading screens for webpages, you make me cry :(
sticilface
@sticilface
Jan 03 2016 12:15
@celsworth see earlier. i had tried that but wanted this for when esp is in AP mode..
Chris Elsworth
@celsworth
Jan 03 2016 12:16
I see
Markus
@Links2004
Jan 03 2016 12:16
if you have a slow webserver its the only possibility you have, or the side may looks strange for some time.
sticilface
@sticilface
Jan 03 2016 12:16
its fine. as it only does this the first time, then it is all cached... so its fine.
then it works super fast.
i was having far more issues trying to serve up dynamically created pages from the ESP, every time. now it all uses AJAX.. and is pretty smooth... that was apart from the first load...
which is now sorted :)
Markus
@Links2004
Jan 03 2016 12:18
if the browser cache is not working good, you can cache yourself, localStorage.
sticilface
@sticilface
Jan 03 2016 12:19
no it works fine. this is all just for that first page load! it was just annoying the crap out of me that you had to press refresh
FWeinb
@FWeinb
Jan 03 2016 12:26
Is there a fast way to transpose an array in c++?
I have an XBM but the display I am using needs the information flipped by 90deg to the right. I have a buffer in ram. So the simplest way would just write it to ram. but therefor I would first need to transpose it to the correct dimensions.
Markus
@Links2004
Jan 03 2016 12:29
the most displays can do this for you.
they have a rotate or view orientation setting
FWeinb
@FWeinb
Jan 03 2016 12:31
That is right, but the XBM format is defined this way. I can't change how the display is render because that would distort everything else on the display.
Mario Mikočević
@mozgy
Jan 03 2016 12:33
OLED displays I have here have only flip mode, there is no 90deg mode
Markus
@Links2004
Jan 03 2016 12:36
have no other idea then read byte for byte and write it to the new position, basically two for
FWeinb
@FWeinb
Jan 03 2016 12:39
Okay. I though i could just somehow copy the memory.
Markus
@Links2004
Jan 03 2016 12:39
since the image is on bit on pixel, copy is not a option.
Mario Mikočević
@mozgy
Jan 03 2016 12:40
for 90deg you are doing copy .. pixel by pixel :D
Markus
@Links2004
Jan 03 2016 12:41
you read one byte and need to write the 8 bits to 8 different bytes, no copy function will do that
may its easier to rotate the image on the PC and use it then.
Mario Mikočević
@mozgy
Jan 03 2016 12:43
only problem is what you will do with extra info
@Links2004 I never said copy function, but you do copy pixel data from here to there :P
90deg is easy if X == Y
FWeinb
@FWeinb
Jan 03 2016 12:45
Yeah rotation on the PC would be an option. But support for plain XBM would be good too.
Mario Mikočević
@mozgy
Jan 03 2016 13:42
huge debug menu now, nice :)
Chris Elsworth
@celsworth
Jan 03 2016 13:43
the gdb stuff?
Mario Mikočević
@mozgy
Jan 03 2016 13:43
no, todays git
Chris Elsworth
@celsworth
Jan 03 2016 13:43
oh, whats new?
ah ota debugging?
Mario Mikočević
@mozgy
Jan 03 2016 13:47
debug.jpg
Alexandro Todeschini
@asetyde
Jan 03 2016 13:50
Hi , if i not use spdiff .. in 2.0.0 i select 3mb o 1mb?, i not understand @igrr @Links2004
Mario Mikočević
@mozgy
Jan 03 2016 13:51
@Links2004 ->
In file included from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src\ESP8266WiFiMulti.cpp:26:0:
C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src\ESP8266WiFiMulti.cpp: In member function 'wl_status_t ESP8266WiFiMulti::run()':
C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src\ESP8266WiFiMulti.h:37:66: error: cannot pass objects of non-trivially-copyable type 'class String' through '...'
 #define DEBUG_WIFI_MULTI(...) DEBUG_ESP_PORT.printf( __VA_ARGS__ )

                                                                  ^
C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src\ESP8266WiFiMulti.cpp:130:25: note: in expansion of macro 'DEBUG_WIFI_MULTI'

                         DEBUG_WIFI_MULTI("[WIFI] SSID: %s\n", WiFi.SSID());
                         ^
FWeinb
@FWeinb
Jan 03 2016 14:22
I have a for loop iterating to the whole array is ist fast to just do a buffer[i] = other[i]. Or doing a memcpy afterwards?
Markus
@Links2004
Jan 03 2016 14:23
@mozgy a .c_str() is missing
Mario Mikočević
@mozgy
Jan 03 2016 14:25
@Links2004 ok, that single line is the only culprit, it compiles with DEBUG_WIFI_MULTI("[WIFI] SSID: %s\n", WiFi.SSID().c_str());
Markus
@Links2004
Jan 03 2016 14:26
@mozgy i think we have change the SSID from char * to String at some point
Mario Mikočević
@mozgy
Jan 03 2016 14:26
that works too :)
oh boy Serial debug spam now :D
Markus
@Links2004
Jan 03 2016 14:26
have you enabled all ?
Mario Mikočević
@mozgy
Jan 03 2016 14:26
yep :D
Markus
@Links2004
Jan 03 2016 14:27
yes overkill debugging :P
Mario Mikočević
@mozgy
Jan 03 2016 14:27
(y)
hmm, @Links2004 question ->
I have this code
Mario Mikočević
@mozgy
Jan 03 2016 14:32
  httpServer.on( "/arducam", HTTP_GET, [](){
    if(!handleFileRead("arducam0.jpg")) httpSend404();
  });
and
    File file = SPIFFS.open( path, "r" );
    size_t sent = httpServer.streamFile( file, contentType );
    file.close();
and ESP sends that file twice
aaand, in that httpServer.streamFile() between each 1460 block there's slight pause
Chris Elsworth
@celsworth
Jan 03 2016 14:34
flash reading time?
or wifi sending, 1460 is about the mtu size
Mario Mikočević
@mozgy
Jan 03 2016 14:35
slow flash possibly ..
network part should be very fast no matter what MTU is (as long as it's not packet fragmenting :) )
SPIFFS debug is reasonable, httpServer is spamming, WiFi is cryptic ..
Markus
@Links2004
Jan 03 2016 14:40
@mozgy try WiFi.setSleepMode(WIFI_NONE_SLEEP); SDK 1.5 has some lag sometimes
Mario Mikočević
@mozgy
Jan 03 2016 14:41
ok, still does not explain why ESP is sending that twice
or darned firefox requests it twice
Markus
@Links2004
Jan 03 2016 14:42
no idea for the moment I not really use the webserver since i have a real server in my basement i only have a ws connection to my ESPs
Mario Mikočević
@mozgy
Jan 03 2016 14:43
yeh, thats next on my todo list, connect cam with ws socket ..
whoa, while OTAing spam .. :D
MD5 Success: a646bcbcd101285670ab26930366b0bc
Staged: address:0x002B4000, size:0x0004B8C0
sticilface
@sticilface
Jan 03 2016 14:45
mmm... thats interesting.. i recently started getting multiple requests hitting my ESPs...
as well... the same parameters coming through, and slowing things down.. was a pain in the ass for say my command that did a self upgrade from github!
Mario Mikočević
@mozgy
Jan 03 2016 14:46
yep, firefox sends GET twice ..
sticilface
@sticilface
Jan 03 2016 14:47
I'm using safari, and it never used to do it!
i implemented an MD5 checksum and timeout, for requests to ignore them:)
Mario Mikočević
@mozgy
Jan 03 2016 14:54
@Links2004 nice, this works now
  if( !WiFi.isConnected() ) {
    Serial.println( "Disconnected AGAIN!" );
    WiFi.reconnect();
    WiFi.waitForConnectResult();
  }
and debug ->
:urn 83
:urd 9, 83, 13
:urch 83, 83
:urd 9, 83, 13
:urch 83, 83
:urd 9, 83, 13
:urch 83, 195
:urch 195, 86
:urch 86, 195
:urch 195, 250
:urch 250, 250
state: 5 -> 2 (6c0)
rm 0
pm close 7
wifi evt: 1
STA disconnect: 6
Disconnected AGAIN!
state: 2 -> 0 (0)
f r0, wifi evt: 1
STA disconnect: 202
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 4
cnt
where can I find more info of :ur?? ?
Mario Mikočević
@mozgy
Jan 03 2016 15:06
ok, it's definately firefox, just tried chrome and it's blazing fast and url requested only once ..
so, it's not flash either, that's nice
Anwar Hahj Jefferson-George
@anwarhahjjeffersongeorge
Jan 03 2016 16:10
if I am working on a fork that changes the source in the core folder do i need to rebuild each time i test
Hassanbenlebsir
@Hassanbenlebsir
Jan 03 2016 16:35
what are the interrupt inputs for the esp8266 nodemcu
Aditya Tannu
@AdySan
Jan 03 2016 17:20
blob
From reddit, is this true? Sorry, I'm not a web developer, so I cannot judge this one for myself

In plain text:

HTTPS on the esp8266 is a bit of a problem right now, I'm not sure there's a working implementation that also checks the certificates.

True/False?
Markus
@Links2004
Jan 03 2016 17:23
@AdySan true and false, there is no full check if it withdrawn for example, you can compare the fingerprint but this is all.
Aditya Tannu
@AdySan
Jan 03 2016 17:24
I see, thanks people.
Chris Elsworth
@celsworth
Jan 03 2016 17:26
for most of the above reasons it's my (very personal) opinion that putting an esp on the internet and trying to do ssl with it is crazy :)
I keep mine very local and very simple, spitting out some udp data to a real server that can decide what to do with it
Aditya Tannu
@AdySan
Jan 03 2016 17:28
Yep, all MQTT within the personal wifi seems the safest and most reliable way.
I'm mostly trying to implement HomeKit accessories right now, iCloud takes care of making it accessible from outside my wifi. I assume that's secure enough.
Chris Elsworth
@celsworth
Jan 03 2016 17:30
oh nice :) is this public?
I'm an apple weenie so I'd be interested in browsing around that :)
Aditya Tannu
@AdySan
Jan 03 2016 17:30
But yeah, to get notifications from IFTTT, I have to connect to their servers, not sure if I need HTTPS for that. I don't see the point.
FWeinb
@FWeinb
Jan 03 2016 17:30
HomeKit sounds great. I have a working Homebridge on the Raspberry to controll some power outlets via 433mhz transmitter.
Chris Elsworth
@celsworth
Jan 03 2016 17:31
thanks :)
FWeinb
@FWeinb
Jan 03 2016 17:31
That sound exactly like my configuration except the integration of the esp.
Aditya Tannu
@AdySan
Jan 03 2016 17:32
@FWeinb Yes, so far the ESP8266 side has been rather reliable with MQTT. Just HAP-NodeJS keeps crashing on the RPi for various reasons every few days
like the RPi just stops reponding to pings, stops advertising on bonjour, etc.
FWeinb
@FWeinb
Jan 03 2016 17:32
Yeah. That is an on going problem.
Aditya Tannu
@AdySan
Jan 03 2016 17:33
Also got a Philips Hue clone working the other day. Light up our bedroom nicely now! https://twitter.com/Ady/status/679146825136259073
FWeinb
@FWeinb
Jan 03 2016 17:34
This is just so useful.
Aditya Tannu
@AdySan
Jan 03 2016 17:35
I'm really hoping ESP32 can run something like this in the future https://github.com/aanon4/HomeKit, so we can get rid of Homebridge too.
just ESP32 based bluetooth accessories.
FWeinb
@FWeinb
Jan 03 2016 17:40
This sounds promising: http://esp32.com/viewtopic.php?t=13
Aditya Tannu
@AdySan
Jan 03 2016 17:42
@FWeinb indeed! I know about the encryption part, do accessories also need an MFi chip in them?
Well there's certainly got to be a way to fake it, since it's already working.
FWeinb
@FWeinb
Jan 03 2016 17:43
Yeah. It should be possible to fake it.
With MDNS working on the ESP i hope there will be an implementation.