• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


ping
#31
Can you ping that ip address from the command line ?
status reply 3 indicates to me: destination unreachable.
poll-interval is in sec / wiki is updated
 
Reply
#32
Thanks for updating the wiki. The error occurs when an IP address is not pingable, imho it should not give an error but set the state to disconnected when the ping exit code is equal to 3.
 
Reply
#33
It does, it only sets the state to connected when the exit code is 0:
https://github.com/pilight/pilight/blob/...ping.c#L77
 
Reply
#34
Sorry, that doesn't work for me. This works (L95):

Code:
} else if(ping(ip) != 0) {
                    state = DISCONNECTED;

                    pping->message = json_mkobject();
                    JsonNode *code = json_mkobject();
                    json_append_member(code, "ip", json_mkstring(ip));
                    json_append_member(code, "state", json_mkstring("disconnected"));

                    json_append_member(pping->message, "message", code);
                    json_append_member(pping->message, "origin", json_mkstring("receiver"));
                    json_append_member(pping->message, "protocol", json_mkstring(pping->id));

                    if(pilight.broadcast != NULL) {
                        pilight.broadcast(pping->id, pping->message);
                    }
                    json_delete(pping->message);
                    pping->message = NULL;
            }

I know it is now continuously broadcasting disconnected messages, but with the
Code:
if(state == CONNECTED)
there, it simply doesn't work.
 
Reply
#35
As curlymo said already, we only want to create a DISCONNECTED message when we had a CONNECT condition before, to avoid a stream of unwanted broadcasts.

The condition in L95 is not
if (state == connected),
the condition in L95 is:
if ( (ping(ip) != 0) && (state == connected) )
this is due to L77.

May be we have a problem to understand what kind of solution is required for your case.
Can you describe in more detail what is not working in your application.

I assume that the default setting of your connection is DISCONNECTED and thus you never get a trigger event for your application, if this is the case is it possible that you solve your problem by setting the default value in your configuration to CONNECTED and than the error condition will reset it to DISCONNECTED and you get the trigger event you are looking for ?
 
Reply
#36
Sorry for the confusion. To keep it simple, my tests show that if I :

- set the state of a ping device to connected in config.json
- I start pilight-daemon -D
- I disconnect the device (turn it off)
- Then pilight-daemon does not gives a disconnected message.

If I change the lined aaround L95, pilight does show a disconnect message. I will test again this evening.
 
Reply
#37
Update, tested with:

Code:
INFO: version 6.0, commit v6.0-1-g36f18f3

And the same test results as above. I set a device to "connected" in config.json and pilight does not set the state to "disconnected" if the device is not pingable:

Code:
DEBUG: unexpected status reply 3 from addr: 192.168.137.120

p.s. .120 is the rpi itself.
 
Reply
#38
Issue is identified, i can confirm that there are two bugs. Will also add a more detailled status reply.
 
Reply
#39
@curlymo:
libs/protocols/ping.c
In my opinion the issue is that the state condition for CONNECTED and DISCONNECTED within protocols/ping.c has to be initialized.
libs/pilight/ping.c
it will be beneficial to add the subcodes to the errorlog and to print source and destination ip addr
I'll issue a pull request for ping_v6
 
Reply
#40
(02-24-2015, 08:17 PM)meloen Wrote: Thanks for updating the wiki. The error occurs when an IP address is not pingable, imho it should not give an error but set the state to disconnected when the ping exit code is equal to 3.
The pilight driver module for ping reports that error, and this is correct. I will update that module at a later time, to enhance the information logged.
The problem is that the protocol driver has a bug. I have fixed that error at git wo-rasp v6_ping. I would appreciate if you can confirm that the driver is now working properly.
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)