These are chat archives for esp8266/Arduino

16th
Jan 2016
Helio Machado
@crushedice2000
Jan 16 2016 10:02
Good morning!
0xPIT
@0xPIT
Jan 16 2016 10:23
Is the volume formatted?
Helio Machado
@crushedice2000
Jan 16 2016 10:28
@0xPIT: What do you mean? If you mean if the SPIFFS "partition" is set, yes. In fact I can the same file for read.
sticilface
@sticilface
Jan 16 2016 10:38
@crushedice2000 does it work with a different filename?
Helio Machado
@crushedice2000
Jan 16 2016 10:38
@sticilface: Untested. Testing... Also, will the w mode create a non-existent file?
should do
Helio Machado
@crushedice2000
Jan 16 2016 10:39
I'm doing something wrong calling this after SPIFFS.begin()?
  configFile = SPIFFS.open("/config1.json", "w");
  if (configFile) {
   json.printTo(configFile);
 }
With another name does the same thing.
Also, please note that "ConfigFile.ino" works well. That is really strange.
sticilface
@sticilface
Jan 16 2016 10:42
sometimes, when i've been trying to use SPIFFS and having trouble... I format the partition and it works again. That would be my next step
Helio Machado
@crushedice2000
Jan 16 2016 10:42
@sticilface: I formatted it.
sticilface
@sticilface
Jan 16 2016 10:43

With another name does the same thing.
and then
Also, please note that "ConfigFile.ino" works well. That is really strange.

so does it work for a different file name or not?

im confused
Helio Machado
@crushedice2000
Jan 16 2016 10:44
@sticilface: It fails also with a different name.
@sticilface: Some recipe to do a cat /* on spiffs?
It would help me to debug.
Helio Machado
@crushedice2000
Jan 16 2016 10:50
@sticilface: I'm modifying the ConfigFile.ino example until it fails, and then see what I'm doing wrong. This is the best method.
sticilface
@sticilface
Jan 16 2016 10:54
agreed
Helio Machado
@crushedice2000
Jan 16 2016 10:56
@sticilface: Going offline, see you later! Thank you!
0xPIT
@0xPIT
Jan 16 2016 11:20
@crushedice2000 is a timer running? interrupts must be disabled while you access flash. Timer0 can obviously not be disabled using InterruptLock lock; at the beginning of the code block that writes to flash, I had to stop timer0 manually.
Helio Machado
@crushedice2000
Jan 16 2016 11:39
@0xPIT: I don't have any (visible) interrupt code. Maybe the WiFi is doing that?
Helio Machado
@crushedice2000
Jan 16 2016 13:22
@/all: Can I open a spiffs file for read/write instead of only read or only write?
Also, is ok to ping all the living users here to ask these questions, or should I simply leave them without ping?
Chris Elsworth
@celsworth
Jan 16 2016 13:24
this is in the docs
Opens a file. path should be an absolute path starting with a slash (e.g. /dir/filename.txt). mode is a string specifying access mode. It can be one of "r", "w", "a", "r+", "w+", "a+". Meaning of these modes is the same as for fopen C function.
so you want either r+ or w+, check fopen for the difference
Helio Machado
@crushedice2000
Jan 16 2016 13:24
@celsworth: Thanks! I already read that. What I don't understand if opening as "w" can also used for read.
Chris Elsworth
@celsworth
Jan 16 2016 13:25
w
Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file.
Helio Machado
@crushedice2000
Jan 16 2016 13:25
@celsworth: Ok, r+
Chris Elsworth
@celsworth
Jan 16 2016 13:25
:)
Helio Machado
@crushedice2000
Jan 16 2016 13:26
@celsworth: Sorry, I'm a bit stupid. (also I'm not a frequent C/++ programmer)
Chris Elsworth
@celsworth
Jan 16 2016 13:26
The critical bit in that sentence is "Meaning of these modes is the same as for fopen C function" so the next step is to find the documentation for fopen ;)
google knows all :D
if you have a linux box handy then man fopen would get you the same thing
Helio Machado
@crushedice2000
Jan 16 2016 13:27
@celsworth: :smile: Sorry.
@celsworth: I have a Linux box connected to this keyboard :smile_cat:
Could you answer also the 2nd question?
Chris Elsworth
@celsworth
Jan 16 2016 13:27
pinging? I don't know to be honest
I'm not channel operator or anything
Helio Machado
@crushedice2000
Jan 16 2016 13:28
Ok, :satisfied:. I'll simply ping for major questions, leaving minor ones "unpinged".
Thank you!
0xPIT
@0xPIT
Jan 16 2016 13:36
Mode "w" alone works for me. can you post your whole code in a gist or so?
I don't know how wifi influences interrupts, but I'd expect that it might interrupt your code to fulfill the 802.11 protocols. So, I'd suggest to try to #include <interrupts.h> and add InterruptLock lock; in the { ... } block of your code, this should disable all interrupts while your write to the file.
Helio Machado
@crushedice2000
Jan 16 2016 13:40

@0xPIT

main.h

#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
// // #include <WiFiUdp.h>
// // #include <ArduinoOTA.h>
#include <ESP8266WebServer.h>
#include <ArduinoJson.h>
#include <DNSServer.h>
#include <FS.h>

void streamFile();
void handleRoot();
void config_read();
void config_write();
void setBrightness();

DNSServer dnsServer;
ESP8266WebServer webServer(80);
IPAddress apIP(192, 168, 1, 1);

File configFile;
DynamicJsonBuffer jsonBuffer;

main.cpp

#include "main.h"

void config_read() {
  configFile = SPIFFS.open("/config.json", "r+");
  size_t size = configFile.size();
  std::unique_ptr<char[]> buf(new char[size]);
  configFile.readBytes(buf.get(), size);
  JsonObject& json = jsonBuffer.parseObject(buf.get());
  const char* brightness = json["brightness"];
  Serial.print("Level: ");
  Serial.println(brightness);
}

void config_write() {
  // configFile = SPIFFS.open("/config.json", "w");
  JsonObject& json = jsonBuffer.createObject();
  json["brightness"] = "brightnessQ";
  json.printTo(configFile);
}


void setup() {
  Serial.begin(115200);
  //Serial.setDebugOutput(true);
  // ArduinoOTA.begin();
  SPIFFS.begin();
  //delay(1000);
  config_read();
  config_write();
} 

void loop() {}
Chris Elsworth
@celsworth
Jan 16 2016 13:42
just using "w" shouldn't let you read if I'm reading https://github.com/esp8266/Arduino/blob/master/cores/esp8266/FS.cpp#L248 right
if it does, its probably a bug
0xPIT
@0xPIT
Jan 16 2016 13:43
@celsworth right, "w" alone only allows writing, "w+" write and read. I thought the question was solely about the writing that does not work.
Chris Elsworth
@celsworth
Jan 16 2016 13:43
ah ok
0xPIT
@0xPIT
Jan 16 2016 13:44
@crushedice2000 I did a if (!SPIFFS.begin()) { Serial.println("Failed to mount file system"); } to see if mounting the filesystem works.
@crushedice2000 but you should open "w+", as it is you can not write to the file.
Helio Machado
@crushedice2000
Jan 16 2016 13:45
@0xPIT: Ok, testing...
0xPIT
@0xPIT
Jan 16 2016 13:46
also, it's really useful to post larger code snippets to a github gist, one can comment and such :)
Helio Machado
@crushedice2000
Jan 16 2016 13:46
@0xPIT: It don't showed the fail, but not works.
@0xPIT: Gisting it in 3, 2, 1...
0xPIT
@0xPIT
Jan 16 2016 13:48
(not complete)
Helio Machado
@crushedice2000
Jan 16 2016 13:49
0xPIT
@0xPIT
Jan 16 2016 13:50
:)
Helio Machado
@crushedice2000
Jan 16 2016 13:50
@0xPIT :smile_cat:
0xPIT
@0xPIT
Jan 16 2016 13:51
have you established that reading works?
like, manually upload the json via the arduino ide?
Helio Machado
@crushedice2000
Jan 16 2016 13:52
@0xPIT: Trying...
sticilface
@sticilface
Jan 16 2016 13:52
@crushedice2000 IMPORTANT... you have declared a global instance of dynamicjson buffer.. this is a big no no... you need to declare it within each function that uses the json so that it is destroyed once it goes out of scope. You cannot reuse the buffer..
Helio Machado
@crushedice2000
Jan 16 2016 13:52
@sticilface: May be that :question:
@sticilface: Still not working.
This might seem like an obvious question, but what ESP are you using? What is the Flash chip size? and what do you have the flash chip size set to in the arduino IDE?
Helio Machado
@crushedice2000
Jan 16 2016 13:56
@sticilface: ESP-01 512+512. Using PlatformIO with ESP8266Arduino framework
sticilface
@sticilface
Jan 16 2016 13:57
ok, and your ESP definitely has 1Mb of flash, not like the old ones that only have 512k
Helio Machado
@crushedice2000
Jan 16 2016 13:57
@sticilface: If you wait ~30s I'll send you the data.
Flash real id:   001440E0
Flash real size: 1048576

Flash ide  size: 1048576
Flash ide speed: 40000000
Flash ide mode:  DIO
Flash Chip configuration ok.
@sticilface: I'm wrong?
sticilface
@sticilface
Jan 16 2016 14:00
ok... i might know what is going on...
you chip is fine
so you only open the file once, in configured... you do this using r+. r+ will only open a file that already exists...
so that fails, but you think that because you then write after using configwrite that you should be writing...
r+ will always fail first as there is no file,
then configwrite fails as there is no open file
I use this
    _settings = SPIFFS.open(MELVANA_SETTINGS, "r+");

    if (!_settings) {
        Debugln("ERROR File open for failed!");
        _settings = SPIFFS.open(MELVANA_SETTINGS, "w+");
        if (!_settings) Debugln("Failed to create empty file too");
    }
Helio Machado
@crushedice2000
Jan 16 2016 14:14
@sticilface: Lunch time! See you later! The only thing I notice is that it doesn't work your way. Could you try my latest gist? https://gist.github.com/crushedice2000/c804f4d8a25c87b8ac45
sticilface
@sticilface
Jan 16 2016 14:16
ok i modified your code and it works fine
serial output
Read worked
write worked
tested the buffer as well, and it is definitely working!
nanobyte84
@nanobyte84
Jan 16 2016 15:34
@me-no-dev thx i figuered out that Interrupts don't work on gpio16
Me No Dev
@me-no-dev
Jan 16 2016 15:34
yeah :) that is documented :)
the rest of the functions work for it though
probonopd
@probonopd
Jan 16 2016 16:01
hi, BasicOTA.ino is supposed to be working, right?
Chris Elsworth
@celsworth
Jan 16 2016 16:01
yes :)
probonopd
@probonopd
Jan 16 2016 16:01
for me it does not seem to advertise itself with mdns-sd
how can i debug that?
avahi-browse -a does not show the esp
Btw, is "Debug port:" working for anyone? All it does for me is lead to a compile error whenever I select "Serial" or "Serial1"
probonopd
@probonopd
Jan 16 2016 16:12
@Links2004 here is the error:
I am using the mDNS_Web_Server sketch
Chris Elsworth
@celsworth
Jan 16 2016 16:13
for what its worth I don't seem to get any MDNS announcements from ArduinoOTA.begin()either, just never noticed before cos I don't use the MDNS part of it
probonopd
@probonopd
Jan 16 2016 16:13
@celsworth isn't that needed for it to show up as a Port in the IDE?
Chris Elsworth
@celsworth
Jan 16 2016 16:13
probably, but I don't use the IDE :)
probonopd
@probonopd
Jan 16 2016 16:14
ok, I think I'm going to open an issue on it then
Chris Elsworth
@celsworth
Jan 16 2016 16:14
there's no check whether MDNS actually worked
probonopd
@probonopd
Jan 16 2016 16:18
esp8266/Arduino#1447
Martin Ayotte
@martinayotte
Jan 16 2016 16:20
Is there a call to ArduinoOTA.handle(); in your loop()
Chris Elsworth
@celsworth
Jan 16 2016 16:20
I hacked in a call to print the return value of MDNS.begin() there, and I got 0
0 == false, so MDNS.begin looks to be failing somewhere
digging deeper ;)
oh, think I see it already..
    uint32_t ourIp = _getOurIp();
    if(ourIp == 0){
      return false;
    }
and my sketch doesn't bother waiting for a DHCP IP before running ArduinoOTA.begin ;)
BasicOTA does though.
yeah fixed that then MDNS.begin() succeeds..
but still no announcement. hm.
probonopd
@probonopd
Jan 16 2016 16:24
do you get an announcement with mDNS_Web_Server?
(it's one of the example sketches)
cause I don't seem to
Chris Elsworth
@celsworth
Jan 16 2016 16:25
I'll try
quick look at it suggests I won't cos its more or less the same code, just calls MDNS.begin directly instead of through ArduinoOTA
Markus
@Links2004
Jan 16 2016 16:26
@probonopd this error is fixed in latest git, if you not select wifi or all, it will work in you case.
or you update to git version there wifi work too.
Chris Elsworth
@celsworth
Jan 16 2016 16:27
oh, MDNS was broken in 2.0.0?
probonopd
@probonopd
Jan 16 2016 16:27
@Links2004 you are referring to which one of my issues? the debug compile error?
Does anyone know if "WiFiClientSecure client;" is stable for "long term" connections like MQTT?
ladyada is asking that on https://github.com/adafruit/Adafruit_MQTT_Library/issues/26#issuecomment-172220774 and I don't know the answer...
Chris Elsworth
@celsworth
Jan 16 2016 16:34
@probonopd nope. no MDNS from that sketch.
.
Connected to AirPort
IP address: 192.168.0.212
mDNS responder started
TCP server started
looks like it should work. then doesn't.
definitely on network, can telnet to port 80 on that IP just fine
oh wait wait wait
mint:~/.platformio/packages> ping esp8266.local
PING esp8266.local (192.168.0.212) 56(84) bytes of data.
64 bytes from 192.168.0.212: icmp_seq=1 ttl=255 time=1.28 ms
but avahi-browse did not see anything?!
Martin Ayotte
@martinayotte
Jan 16 2016 16:36
try avahi-discover
Me No Dev
@me-no-dev
Jan 16 2016 16:36
the answers for the service and the host IP are different
Chris Elsworth
@celsworth
Jan 16 2016 16:36
ooh, ok
hm thats not seeing anything either
@probonopd anyway, so with that mDNS_Web_Server sketch, you can't ping esp8266.local?
Markus
@Links2004
Jan 16 2016 16:39
@probonopd debug compile error
probonopd
@probonopd
Jan 16 2016 16:47
mDNS_Web_Server responds to esp8266.local. just fine but esp8266.local. does not show up in avahi-discover
Chris Elsworth
@celsworth
Jan 16 2016 17:02
yeah same here.
aah. see WereCatf's reply.
mint:~> avahi-browse _http._tcp
+   eth0 IPv4 esp8266                                       Web Site             local
seems a bit of a shortcoming, wonder if that can be fixed or its buried in the sdk
Me No Dev
@me-no-dev
Jan 16 2016 17:05
wait... what is the problem that needs fixing?
Chris Elsworth
@celsworth
Jan 16 2016 17:05
esp8266/Arduino#1447
The mDNS-responder doesn't understand mDNS-queries for all services
is that fixable? or espressif has to do it?
Me No Dev
@me-no-dev
Jan 16 2016 17:06
there is nothing to fix :)
it is ok no not respond for services that you do not host
Chris Elsworth
@celsworth
Jan 16 2016 17:06
well it'd be nice if it worked as expected
Me No Dev
@me-no-dev
Jan 16 2016 17:06
actually that is how it should be
what do you mean by that?
Chris Elsworth
@celsworth
Jan 16 2016 17:07
ok, just everything else responds with what services it has, when you ask
this, you need to ask for the specific service
a bit unexpected
Me No Dev
@me-no-dev
Jan 16 2016 17:07
what should I do to get this on my end?
when I was writing it I checked all the queries that I was getting
so i'm not sure if I got something missed or wht
Chris Elsworth
@celsworth
Jan 16 2016 17:08
just run avahi-browse I guess?
Me No Dev
@me-no-dev
Jan 16 2016 17:08
let me see what the Pi will say
Chris Elsworth
@celsworth
Jan 16 2016 17:09
mint:~> avahi-browse -t _http._tcp | grep -i esp
+   eth0 IPv4 esp8266                                       Web Site             local
mint:~> avahi-browse -at | grep -i esp
mint:~>
this is the issue as far as I can see
it doesn't show up for a general browse, only when you specifically request the right service
sure, it doesn't specifically break anything, but its caused an hour of "wtf?" this afternoon between me and @probonopd :D
because something we expected to see was not there ;)
Me No Dev
@me-no-dev
Jan 16 2016 17:11
unpacking now
will power the yun as well
Me No Dev
@me-no-dev
Jan 16 2016 17:16
root@piduino1:/opt/vc/bin # avahi-browse -at
+  wlan0 IPv4 esp8266-a65195                                _arduino._tcp        local
+  wlan0 IPv4 piduino1                                      _arduino._tcp        local
+   eth0 IPv4 Arduino                                       _arduino._tcp        local
+   eth0 IPv4 esp8266-a65195                                _arduino._tcp        local
+   eth0 IPv4 piduino1                                      _arduino._tcp        local
+  wlan0 IPv6 piduino1                                      _arduino._tcp        local
+   eth0 IPv6 piduino1                                      _arduino._tcp        local
you can see my Pi, my ESP and my Yun in that result
Chris Elsworth
@celsworth
Jan 16 2016 17:23
interesting, so you get them without specifying the service
is this 2.0.0?
Me No Dev
@me-no-dev
Jan 16 2016 17:23
as you see, I just run avahi-browse -at :) lots of things showed but nopoint in pasting
this is 1.5.1
Chris Elsworth
@celsworth
Jan 16 2016 17:24
huh :)
oh sdk 1.5.1?
I wonder if they changed something then
Me No Dev
@me-no-dev
Jan 16 2016 17:24
it's the same as this repo's git
Chris Elsworth
@celsworth
Jan 16 2016 17:24
yeah, I'm with you
I'm running 2.0.0 (so sdk 1.3 I think?)
Me No Dev
@me-no-dev
Jan 16 2016 17:25
well... can you check how many libwip.a you have in your sdk/lib folder?
if there are two, I have a clue
Chris Elsworth
@celsworth
Jan 16 2016 17:25
yeah two
liblwip.a and liblwip_536.a
Me No Dev
@me-no-dev
Jan 16 2016 17:26
rename the one called libwip.a to something else and the other one to libwip.a and give it another go
please report :)
Chris Elsworth
@celsworth
Jan 16 2016 17:26
doing :)
no change
Me No Dev
@me-no-dev
Jan 16 2016 17:28
alright :) another idea
Chris Elsworth
@celsworth
Jan 16 2016 17:28
the _536.a was much smaller
Me No Dev
@me-no-dev
Jan 16 2016 17:28
grab the latest mdns lib frm the repo master and replace the one you have
Chris Elsworth
@celsworth
Jan 16 2016 17:28
ok
Me No Dev
@me-no-dev
Jan 16 2016 17:29
the one you were using is the onefrom source
it gave me lots of headaches
and i even branched my git to not use it
Chris Elsworth
@celsworth
Jan 16 2016 17:29
we are talking about ESP8266mDNS.cpp right?
Me No Dev
@me-no-dev
Jan 16 2016 17:29
yes
Chris Elsworth
@celsworth
Jan 16 2016 17:29
ok
Me No Dev
@me-no-dev
Jan 16 2016 17:30
libwip is what I was talking "from source"
libwip_536.a is the stock one that comes with sdk 1.3
Chris Elsworth
@celsworth
Jan 16 2016 17:30
and you recommend the 536?
Me No Dev
@me-no-dev
Jan 16 2016 17:30
all the way
Chris Elsworth
@celsworth
Jan 16 2016 17:31
hm, still the same
Me No Dev
@me-no-dev
Jan 16 2016 17:31
wow...
you are running the same source as me. I'm seeing things and you not
Chris Elsworth
@celsworth
Jan 16 2016 17:32
strange
Me No Dev
@me-no-dev
Jan 16 2016 17:34
wanna give me your sketch so i run the same exact one?
Chris Elsworth
@celsworth
Jan 16 2016 17:34
its just mDNS_Web_Server.ino
Me No Dev
@me-no-dev
Jan 16 2016 17:34
ok :) loading in a sec
Chris Elsworth
@celsworth
Jan 16 2016 17:35
so its putting a service on _http._tcp, which I can see if I do avahi-browse _http._tcp, but not avahi-browse -a
but you can see it both ways, which is the odd thing
probonopd
@probonopd
Jan 16 2016 17:37
well for me it shows up in avahi-browse -a btu only ofter I had been gone for 30 minutes and then had done avahi-browse -t _http._tcp
so I still think the way it should work is: connect the ESP to WIFI, do avahi-browse -a and see the services the ESP advertises. Or am I wrong? (All my other gadgets seem to work that way)
Chris Elsworth
@celsworth
Jan 16 2016 17:39
yeah thats how it should work
Me No Dev
@me-no-dev
Jan 16 2016 17:39
hold on
not seing it anymore
let me debug a bit
maybe avahi issue
probonopd
@probonopd
Jan 16 2016 17:49
strange, with sudo service avahi-daemon restart && avahi-browse -t -a | grep esp it seems to work for me now
Chris Elsworth
@celsworth
Jan 16 2016 17:51
do you know what to tcpdump to watch these packets?
probonopd
@probonopd
Jan 16 2016 17:51
no
Me No Dev
@me-no-dev
Jan 16 2016 17:52
port is 5353 udp
filter on that and you will see all mdns packets on your local net
i can definetely say there is an issue somewhere
Chris Elsworth
@celsworth
Jan 16 2016 17:53
ok, going to try rebooting the esp while watching that..
Me No Dev
@me-no-dev
Jan 16 2016 17:53
as soon as I loded my previous sketch that has Arduino enabled, the ESP showed again in avahi-browse
probonopd
@probonopd
Jan 16 2016 17:53
thanks @me-no-dev I was thinking it's only broken for me ;-)
Chris Elsworth
@celsworth
Jan 16 2016 17:54
hm odd, no packet seen.
ok, so its not on boot, its just when I ask for it:
17:54:59.460453 IP 192.168.0.140.mdns > 224.0.0.251.mdns: 0 PTR (QM)? _http._tcp.local. (34)
17:54:59.549695 IP 192.168.0.212.mdns > 224.0.0.251.mdns: 0*- [0q] 4/0/0 PTR esp8266._http._tcp.local., TXT, (Cache flush) SRV esp8266.local.:80 0 0, (Cache flush) A 192.168.0.212 (188)
probonopd
@probonopd
Jan 16 2016 17:56
did you specifically ask for _http._tcp?
Chris Elsworth
@celsworth
Jan 16 2016 17:56
yes, thats when it replies
if I just do avahi-browse without putting in _http._tcp, then tcpdump shows:
17:55:57.061397 IP 192.168.0.140.mdns > 224.0.0.251.mdns: 0 [20a] [11q] PTR (QM)? _services._dns-sd._udp.local. PTR (QM)? _adisk._tcp.local. PTR (QM)? _afpovertcp._tcp.local. PTR (QM)? _ssh._tcp.local. PTR (QM)? _sftp-ssh._tcp.local. PTR (QM)? _rfb._tcp.local. PTR (QM)? _atc._tcp.local. PTR (QM)? _bttremote._tcp.local. PTR (QM)? _apple-mobdev2._tcp.local. PTR (QM)? _udisks-ssh._tcp.local. PTR (QM)? _workstation._tcp.local. (573)
Me No Dev
@me-no-dev
Jan 16 2016 17:57
can you see what packet comes out of the host when you just browse
Chris Elsworth
@celsworth
Jan 16 2016 17:57
and I note there is no _http._tcp there.. wonder where it gets taht list of services from th en
heh snap! see above.
Me No Dev
@me-no-dev
Jan 16 2016 17:57
:D
Chris Elsworth
@celsworth
Jan 16 2016 17:58
       -a | --all
              Browse for all service types registered on the LAN, not just the
              one specified on the command line.
"registered on the LAN" whatever that means
probonopd
@probonopd
Jan 16 2016 17:58
"advertised"
Me No Dev
@me-no-dev
Jan 16 2016 17:58
the packet pasted above seem to look for specific services
Chris Elsworth
@celsworth
Jan 16 2016 17:59
ok.. so the esp should be announcing on boot?I don't think it currently is?
Me No Dev
@me-no-dev
Jan 16 2016 17:59
maybe _services._dns-sd._udp.local. is something we need to reply to
but why the hell it works with OTA?
Chris Elsworth
@celsworth
Jan 16 2016 17:59
certainly don't see it when I boot my esp and tcpdumping
Me No Dev
@me-no-dev
Jan 16 2016 17:59
i was thinking maybe because I had other devices advertising _arduino_tcp
Chris Elsworth
@celsworth
Jan 16 2016 18:00
yes that sounds likely
probonopd
@probonopd
Jan 16 2016 18:00
well for me the purpose of dns-sd is so that i can see all services on the network without me needing to know beforehand which services to look for
Me No Dev
@me-no-dev
Jan 16 2016 18:00
but i have other http servers as well and those showed
probonopd
@probonopd
Jan 16 2016 18:00
and non-esp devices seem to do just that
Me No Dev
@me-no-dev
Jan 16 2016 18:01
can you load the BasicOTA example and see if a packet comes out as advertisement from the ESP
do not set hstname/pass and so on
just default ArduinoOTA.begin();
Chris Elsworth
@celsworth
Jan 16 2016 18:01
yep, will do
nop. no advertisement on port 5353 udp
with BasicOTA untouched other than set ssid/pass
think this is the core of the problem? it should announce so caches see it, then possibly re-announce occasionally (not sure of the details on this..)
Me No Dev
@me-no-dev
Jan 16 2016 18:06
no need to reannounce but maybe announce all services on start
reading the source :)
(not sure if that is of any help)
Chris Elsworth
@celsworth
Jan 16 2016 18:08
eek :D
I have some apple devices on my net
I'll watch for a while, see what they do
Me No Dev
@me-no-dev
Jan 16 2016 18:09
i'll write some quick hack to see if advertisement on boot helps
Chris Elsworth
@celsworth
Jan 16 2016 18:16
yeah there's certainly some intermittent advertising going on
eg:
18:14:16.653904 IP 192.168.0.150.mdns > 224.0.0.251.mdns: 0*- [0q] 2/0/0 TXT "model=iMac15,1" "osxvers=15", PTR iMac._rfb._tcp.local. (102)
this is my desktop mac re-announcing that it has remote desktop available, I think
Me No Dev
@me-no-dev
Jan 16 2016 18:16
alright :) you both are running tha latest ESP8266mDNS source, wright?
if not please update
Chris Elsworth
@celsworth
Jan 16 2016 18:17
I'm not even using it right now, but it did it :)
yeah just updated it from git HEAD
Me No Dev
@me-no-dev
Jan 16 2016 18:17
then add this to the cpp:

size_t MDNSResponder::advertiseServices(){
  MDNSService* servicePtr;
  size_t i = 0;
  for (servicePtr = _services; servicePtr; servicePtr = servicePtr->_next) {
    if(servicePtr->_port > 0){
      _reply(0x0F, servicePtr->_name, servicePtr->_proto, servicePtr->_port);
      i++;
    }
  }
  return i;
}
and this to the header
size_t advertiseServices();//advertises all hosted services
run it after you setup all services (the end of setup())
see if there is any change
Chris Elsworth
@celsworth
Jan 16 2016 18:18
ok, just got to nip afk for 5 mins then will try this
Me No Dev
@me-no-dev
Jan 16 2016 18:19
maybe the advertisement should be sent every ttl seconds
Chris Elsworth
@celsworth
Jan 16 2016 18:29
does this go to 224.0.0.251?
trying now..
Me No Dev
@me-no-dev
Jan 16 2016 18:29
yes :)
Chris Elsworth
@celsworth
Jan 16 2016 18:30
18:30:02.874386 IP 192.168.0.212.mdns > 224.0.0.251.mdns: 0*- [0q] 4/0/0 PTR esp8266-f33436._arduino._tcp.local., TXT "tcp_check=no" "ssh_upload=no" "board=generic" "auth_upload=no", (Cache flush) SRV esp8266-f33436.local.:8266 0 0, (Cache flush) A 192.168.0.212 (291)
:))
Me No Dev
@me-no-dev
Jan 16 2016 18:30
try it with the http thing
Chris Elsworth
@celsworth
Jan 16 2016 18:31
hm, my avahi-browse -at still doesn't have _arduino._tcp in its list :(
Me No Dev
@me-no-dev
Jan 16 2016 18:31
wow...
found some info for some tool regarding discovering all services and here is what is written:
mdns-scan is a tool for scanning for mDNS/DNS-SD published services  on
       the  local  network.  It  issues  a  mDNS  PTR  query to the special RR
       _services._dns-sd._udp.local for retrieving a  list  of  all  currently
       registered services on the local link.
_services._dns-sd._udp.local is what avahi was looking for
Me No Dev
@me-no-dev
Jan 16 2016 18:37
will see to make it respond to those :)
Chris Elsworth
@celsworth
Jan 16 2016 18:37
ok, I ran that:
18:36:58.876171 IP 192.168.0.140.mdns > 224.0.0.251.mdns: 0 PTR (QM)? _services._dns-sd._udp.local. (46)
and then there are various replies:
18:36:58.876441 IP 192.168.0.150.mdns > 224.0.0.251.mdns: 0*- [0q] 5/0/0 PTR _ssh._tcp.local., PTR _sftp-ssh._tcp.local., PTR _rfb._tcp.local., PTR _atc._tcp.local., PTR _bttremote._tcp.local. (151)
Me No Dev
@me-no-dev
Jan 16 2016 18:37
it's not gonna respond currently
Chris Elsworth
@celsworth
Jan 16 2016 18:37
yep, but no esp. ok.
probonopd
@probonopd
Jan 16 2016 18:38
@me-no-dev I can confirm that the ESP is not showing but everything else is in mdns-scan
Me No Dev
@me-no-dev
Jan 16 2016 18:38
ok giime a few to write it up
Chris Elsworth
@celsworth
Jan 16 2016 18:38
that services reply seems to be the missing link
probonopd
@probonopd
Jan 16 2016 18:38
cool
Me No Dev
@me-no-dev
Jan 16 2016 18:53
diff --git a/libraries/ESP8266mDNS/ESP8266mDNS.cpp b/libraries/ESP8266mDNS/ESP8266mDNS.cpp
index a690bdf..04b66fe 100644
--- a/libraries/ESP8266mDNS/ESP8266mDNS.cpp
+++ b/libraries/ESP8266mDNS/ESP8266mDNS.cpp
@@ -366,6 +366,10 @@ void MDNSResponder::_parsePacket(){
       memmove(protoName, protoName+1, protoNameLen);
       protoNameLen--;
       protoParsed = true;
+    } else if(strcmp("services", serviceName) == 0 && strcmp("_dns-sd", protoName) == 0){
+      _conn->flush();
+      advertiseServices();
+      return;
     } else {
 #ifdef MDNS_DEBUG_ERR
       Serial.printf("ERR_PROTO: %s\n", protoName);
@@ -479,6 +483,18 @@ void MDNSResponder::enableArduino(uint16_t port, bool auth){
   addServiceTxt("arduino", "tcp", "auth_upload", (auth) ? "yes":"no");
 }

+size_t MDNSResponder::advertiseServices(){
+  MDNSService* servicePtr;
+  size_t i = 0;
+  for (servicePtr = _services; servicePtr; servicePtr = servicePtr->_next) {
+    if(servicePtr->_port > 0){
+      _reply(0x0F, servicePtr->_name, servicePtr->_proto, servicePtr->_port);
+      i++;
+    }
+  }
+  return i;
+}
+
 void MDNSResponder::_reply(uint8_t replyMask, char * service, char *proto, uint16_t port){
   int i;
   if(replyMask == 0) return;
diff --git a/libraries/ESP8266mDNS/ESP8266mDNS.h b/libraries/ESP8266mDNS/ESP8266mDNS.h
index 28ef715..1bdcadc 100644
--- a/libraries/ESP8266mDNS/ESP8266mDNS.h
+++ b/libraries/ESP8266mDNS/ESP8266mDNS.h
@@ -83,6 +83,7 @@ public:
   }

   void enableArduino(uint16_t port, bool auth=false);
+  size_t advertiseServices();//advertises all hosted services

   void setInstanceName(String name);
   void setInstanceName(const char * name){
Helio Machado
@crushedice2000
Jan 16 2016 18:55
@sticilface: Thanks! It works now! r+ and w+ doesn't work. But now all works well.
Me No Dev
@me-no-dev
Jan 16 2016 18:56
root@piduino1:/opt/vc/bin # avahi-browse -at
+   eth0 IPv4 esp8266-a65195                                Web Site             local
+   eth0 IPv4 esp8266-a65195                                _arduino._tcp        local
probonopd
@probonopd
Jan 16 2016 18:59
@me-no-dev where do I apply this?
~/.arduino15/packages/esp8266/hardware/esp8266/2.1.0-rc1
patch -p0 < /home/me/the_patch
Me No Dev
@me-no-dev
Jan 16 2016 18:59
@probonopd replace the source with the one in the git master
then apply the patch
this patch includes the previous change I gave you
probonopd
@probonopd
Jan 16 2016 19:01
ok
patching file libraries/ESP8266mDNS/ESP8266mDNS.cpp
patching file libraries/ESP8266mDNS/ESP8266mDNS.h
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 83 with fuzz 2.
can you paste the patch somewhere?
i think gitter.im destroyed it
Me No Dev
@me-no-dev
Jan 16 2016 19:04
probonopd
@probonopd
Jan 16 2016 19:08
Thanks. patch applied cleanly. testing.
right now avahi-browse -a sees the esp
but mdns-scan doesn't
Me No Dev
@me-no-dev
Jan 16 2016 19:09
mdns-scan is not the best tool :) but it was the first hit on the service query search
probonopd
@probonopd
Jan 16 2016 19:09
let me see if this helps my system to see ArduinoOTA now...
BasicOTA.ino
avahi-browse -a shows _arduino._tcp, yay :-)
Me No Dev
@me-no-dev
Jan 16 2016 19:11
:)
probonopd
@probonopd
Jan 16 2016 19:11
you are a genius, the port is showing up in the IDE now
Me No Dev
@me-no-dev
Jan 16 2016 19:12
thanks :) now someone should commit this
probonopd
@probonopd
Jan 16 2016 19:12
hold on: OTA'ing itself doesn't work
ERROR: No answer
now why is that...
the port does show a correct IP address
and I selected "upload using: OTA"
(although i wonder why it doesn't figure out so much on its own)
Me No Dev
@me-no-dev
Jan 16 2016 19:13
what IDE?
do not use "upload using: OTA" if ide it 1.6.5+
you just upload
;)
probonopd
@probonopd
Jan 16 2016 19:14
Arduino 1.6.7 HourlyBuild 2015/12/17 04:29
is that too old?
Me No Dev
@me-no-dev
Jan 16 2016 19:14
no
go back to Serial option and try again
that option should go but it's there for older versions compatibility
probonopd
@probonopd
Jan 16 2016 19:14
same thing
ERROR: no ansewr
Me No Dev
@me-no-dev
Jan 16 2016 19:15
i use OTA only so i know it works
here is my setup
probonopd
@probonopd
Jan 16 2016 19:15
but when I try to open the serial monitor it asks for a password
Me No Dev
@me-no-dev
Jan 16 2016 19:16
Screen Shot 2016-01-16 at 21.15.51.png
monitor does not work
probonopd
@probonopd
Jan 16 2016 19:17
does the baudrate matter here?
Me No Dev
@me-no-dev
Jan 16 2016 19:17
no
probonopd
@probonopd
Jan 16 2016 19:17
cranking up verbosity
Me No Dev
@me-no-dev
Jan 16 2016 19:17
open the serial of the board on another terminal so you can see what isgoing on while OTAing
probonopd
@probonopd
Jan 16 2016 19:18
how do I copy text our of the output window in the stupid IDE...
Me No Dev
@me-no-dev
Jan 16 2016 19:18
OS?
probonopd
@probonopd
Jan 16 2016 19:18
linux
Me No Dev
@me-no-dev
Jan 16 2016 19:18
Ctrl+C
probonopd
@probonopd
Jan 16 2016 19:19
stpuid me
can i make espota.py more verbose?
Me No Dev
@me-no-dev
Jan 16 2016 19:20
manually yes
not through the IDE
but copy the executed command then run it in another terminal
espota.py -h will give you the options
probonopd
@probonopd
Jan 16 2016 19:21
will do
Me No Dev
@me-no-dev
Jan 16 2016 19:21
-d was the key as far as I remember
probonopd
@probonopd
Jan 16 2016 19:22
interesting! with -d -r it uploaded at once!
Me No Dev
@me-no-dev
Jan 16 2016 19:22
ok have those blond twins to go to dinner with
Helio Machado
@crushedice2000
Jan 16 2016 19:22
This message was deleted
Me No Dev
@me-no-dev
Jan 16 2016 19:22
maybe network was some busy
no clue
probonopd
@probonopd
Jan 16 2016 19:22
thanks so much @me-no-dev
Me No Dev
@me-no-dev
Jan 16 2016 19:23
no probs :)
probonopd
@probonopd
Jan 16 2016 19:23
this is seriously awesome
Chris Elsworth
@celsworth
Jan 16 2016 19:25
my esp's generally get connected to serial just once to put an OTA-capable firmware on, then never again :) really nice
probonopd
@probonopd
Jan 16 2016 19:33
cool. although it would be nice if the sketch wouldn't have to be modified for this to work
e.g., by including the necessary stuff "behind the scenes"
when a checkbox in the IDE is set to do so
Chris Elsworth
@celsworth
Jan 16 2016 19:34
have to disagree on that, the IDE isn't the only way to work with this library :)
anyway I don't think thats going to happen, the ArduinoIDE.handle() call in loop is how all the magic happens.. something has ot call it
I guess it could be in the user_main() that you don't normally see.
so set a #define and it could call .begin and .handle for you
I don't think its a huge problem to include those two calls myself :D
probonopd
@probonopd
Jan 16 2016 19:46
i agree, definitely not a "huge problem" ;-)
but easy to forget when you just ota-upload some random sketch off the net
Chris Elsworth
@celsworth
Jan 16 2016 19:47
true, then you have to dig out the serial adapter
can be a hassle :/
Helio Machado
@crushedice2000
Jan 16 2016 19:49
How to specify the channel for a open softAP?
Chris Elsworth
@celsworth
Jan 16 2016 19:50
bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden) {
just supply it in third arg, by the look of it :)
Helio Machado
@crushedice2000
Jan 16 2016 19:51
@celsworth: I mean to specify channel without specifying password.
Chris Elsworth
@celsworth
Jan 16 2016 19:51
oh, hmm
I can't see a way
may need a new function adding for it
oh wait, just use NULL for password?
you mean set it up but with no password?
I thought you meant change channel for an existing softAP ;)
Helio Machado
@crushedice2000
Jan 16 2016 19:54
@celsworth: Yes
Chris Elsworth
@celsworth
Jan 16 2016 19:54
try just NULL as second arg
Helio Machado
@crushedice2000
Jan 16 2016 19:54
@celsworth: I'll try. Thanks!
Flashing...
Wow! PlatformIO builds fast!
@celsworth: It works!
Chris Elsworth
@celsworth
Jan 16 2016 19:58
yay :)
probonopd
@probonopd
Jan 16 2016 20:02
@celsworth I'm not capable of implementing it myself but I've added it to esp8266/Arduino#1452 so that it doesn't get forgotten :-)
Chris Elsworth
@celsworth
Jan 16 2016 20:02
yeah I got the email :D
probonopd
@probonopd
Jan 16 2016 20:03
this OTA stuff is really awesome
makes it a joy to deploy ESPs everywhere in the house
Helio Machado
@crushedice2000
Jan 16 2016 20:42
Another silly question: How could I output a SPIFFS file in the serial port? (something like cat /myfile.txt)
As the desktop notifications seems a unused feature, I'll ping to @/all. However I fear that this is a kind of spamming, so please kindly let me know if I shouldn't do that.
Helio Machado
@crushedice2000
Jan 16 2016 21:00
Dinner time, see you later!
Michael Miller
@Makuna
Jan 16 2016 21:48
@Links2004 Under the subject of the issue I hit around "c causes a section type conflict with c", I figured out what was happening. The preprocessor seems to be including subdirectories now. I switch back and forth between Visual Micro and the Arduino IDE as I build libraries. Visual Micro when it builds puts all its temp files under a subdirectory to the project file, usually _VM or VISUALMICRO. These files are now being included. One of the files was so old it contained an older Arduino.h (preprocessed in) that had a different implementation of F(). Deleting these VM folders solved the problem.