Open exdirectory opened 8 years ago
Yes and something that needs thinking about. UDP offers no guarantee of message delivery so some sort of retry/acknowledgement system would be useful.
Is there any acknowledgement from the orvibo sent out? It seems the app is more consistent.
Yes, if the command was successfully received by the socket, you should get a response confirming the new state.
I'm just looking for a good way to handle the combination of request-response commands from the library, with the unsolicited messages that arrive if the status is changed from something other than the library.
@exdirectory I'm in the process of doing an overhaul of the network code. It should retry messages if it doesn't get a response from the device so once this is merged you shouldn't need to send commands in a loop.
ok great, will wait for your commit and try that, cheers
Dear Tavalin First at all, thnk you for your SDK and your efforts! I am also looking forward for that loop fix. I just bought an orvibo S20 and will start playing with your SDK next week. I just need my permanently-plugged tablet to switch ON the orvibo whenever battery level goes below say 20% and switch it back OFF when gets fully loaded.. I'll let you know how it goes Thanks a lot!
Could you give the dev branch a try if possible? I have pushed the new code with the message retry mechanism (although I haven't finished retrofitting the IR code)
Just tested the dev branch, initial reaction is this is not fixed, i removed the code to repeat the call 3 times, i then tried to turn on, nothing, tried again, nothing, third time and then it worked, then it worked seamlessly with a single call. But gave it 5 mins, tried to turn off and got no success, turned off again and it worked. So in short, think it has not helped.
This is the code i am using...
JSONObject json = new JSONObject();
try {
if (orvibo == null) {
orvibo = OrviboClient.getInstance();
orvibo.connect();
}
if (orvibo.isConnected()) {
Socket socket = orvibo.socketWithDeviceId(ORVIBO_MAC_ADDRESS);
//socket.find();
socket.subscribe();
// try three times
//for (int n=0; n<3; n++) {
if (turnOnOrvibo)
socket.on();
else
socket.off();
//}
json.put("success", Boolean.TRUE);
}
}
catch (SocketException e) {
e.printStackTrace();
json.put("success", Boolean.FALSE);
}
return json;
Any chance you could send a debug log?
To enable logging I added slf4j-simple to my test program and use the following VM options:
-Dorg.slf4j.simpleLogger.defaultLogLevel=debug -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat="dd-MM-yyyy HH:mm:ss:SSS" -Dorg.slf4j.simpleLogger.logFile="System.out"
I'd expect a line such as:
12-11-2016 11:45:34:288 [main] DEBUG com.github.tavalin.orvibo.messages.request.RetryableMessage - Response received
if the Socket replied
or
12-11-2016 11:46:45:312 [main] DEBUG com.github.tavalin.orvibo.messages.request.RetryableMessage - No response
if the socket didn't send a reply.
Sure, may not get chance until tomorrow evening though, will let you know.
Taking your example where the mac address is known, i found i had to create a loop to send the on or off signal three times to get a consistent result, i.e. the device turned on or off.
Have you a similar experience?