riptidewave93 / RFLED-Server

http://servernetworktech.com/2014/09/limitlessled-wifi-bridge-4-0-conversion-raspberry-pi/
GNU General Public License v3.0
42 stars 12 forks source link

Short Write errors #14

Closed mattnewham closed 7 years ago

mattnewham commented 7 years ago

Hey

I have this running on a raspberry pi zero w - issue is, running in debug mode, all I get when I select a remote in the iOS app is "short write" then the rfled-server quits.

Im not sure where to go with this. Any pointers?

riptidewave93 commented 7 years ago

@mattnewham Any chance you can share the output from RFLED-Server when running in debug mode? That may contain some clues as to what is going on. Also, what iOS app are you using?

Note that this is most likely an issue with that specific client app so I am not sure much can be done, but it's possible a workaround could be implemented.

mattnewham commented 7 years ago

Hey will do when I'm back home but I'm using the milight app and also tried LimitlessLED app both with the same issue

I'm actually looking to use the milight home assistant plugin but have t tested it yet so if that works we can leave it!

-- Matt Newham

On 9 March 2017 at 18:39:29, Chris Blake (notifications@github.com) wrote:

@mattnewham https://github.com/mattnewham Any chance you can share the output from RFLED-Server when running in debug mode? That may contain some clues as to what is going on. Also, what iOS app are you using?

Note that this is most likely an issue with that specific client app so I am not sure much can be done, but it's possible a workaround could be implemented.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/riptidewave93/RFLED-Server/issues/14#issuecomment-285440565, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMt725Zkeh6TOqXTLskrXepYIhnjAbuks5rkEdhgaJpZM4MX6bD .

mattnewham commented 7 years ago

2017/03/09 10:49:41 DEBUG: "Error with user.Current(), failing back..." 2017/03/09 10:49:41 DEBUG: "IntLookup vars: eth=wlan0 ip=0.0.0.0" 2017/03/09 10:49:41 DEBUG: "Our Info: mac=b827eb033d43 ip=192.168.60.235" 2017/03/09 10:49:41 "rfled-server started!" 2017/03/09 10:49:49 DEBUG: "LED: message was F\x00 from 192.168.60.118:48899" 2017/03/09 10:49:49 short write

mattnewham commented 7 years ago

2017/03/09 10:38:28 DEBUG: "Error with user.Current(), failing back..." 2017/03/09 10:38:28 DEBUG: "IntLookup vars: eth=wlan0 ip=0.0.0.0" 2017/03/09 10:38:28 DEBUG: "Our Info: mac=b827eb033d43 ip=192.168.60.235" 2017/03/09 10:38:28 "rfled-server started!" 2017/03/09 10:38:32 DEBUG: "LED: message was N\x01 from 192.168.60.118:48899" 2017/03/09 10:38:32 short write

mattnewham commented 7 years ago

Those are a couple of errors from the two different apps I have tried so far. It doesnt seem to matter what remote control panel I open, it always gives the short write error

mattnewham commented 7 years ago

Hey @riptidewave93 - so I am now testing with Home Assistant limitlessLED component:

https://home-assistant.io/components/light.limitlessled/

This appears to send out an ADM message on occasion:

"ADM: message was HF-A11ASSISTHREAD from 192.168.60.50:48899"

However, when attempting to turn on/off a switch or any other operation, I am seeing no debug output at all. Is this likely because the commands are not recognised? Im about to do a packet capture on the raspberry pi to see what it is receiving

mattnewham commented 7 years ago

OK so the home assistant plugin seems to have the same issue:

2017/03/09 23:01:58 DEBUG: "ADM: message was HF-A11ASSISTHREAD from 192.168.60.50:48899" 2017/03/09 23:01:58 DEBUG: "ADM: replied +ok" 2017/03/09 23:03:13 DEBUG: "LED: message was E\x00 from 192.168.60.50:32886" 2017/03/09 23:03:13 short write

Does the short write error mean that the message is not sucessfully passed to the UART serial output? Im wondering even if my GPIO pins are working as expected. If the GPIO output wasnt working, could that create the above error? From reading the Go IO page it seems that short write may be output if there is no specific error returned from the IO function?

riptidewave93 commented 7 years ago

Hey @mattnewham, did some digging, and it seems this may be caused due to the new API used by these LEDs. For reference, it seems your apps are using API v6, while my application was designed around API v5, which would explain the issue you are seeing. More info is at http://www.limitlessled.com/dev/

It seems the entire packet structure for v6 is different, so the application may need to be modified to only respond to v5 API requests, which seems it should not be too hard to implement. :smile:

Will try to get this done in the next few days, time permitting.

mattnewham commented 7 years ago

Is there a v5 app that you can recommend to get this working?

Does the homeassistant component use the v6 messaging too? I'm wondering how the best way to go about this now is!

-- Matt Newham

On 12 March 2017 at 07:57:36, Chris Blake (notifications@github.com) wrote:

Hey @mattnewham https://github.com/mattnewham, did some digging, and it seems this may be caused due to the new API used by these LEDs. For reference, it seems your apps are using API v6, while my application was designed around API v5, which would explain the issue you are seeing. More info is at http://www.limitlessled.com/dev/

It seems the entire packet structure for v6 is different, so the application may need to be modified to only respond to v5 API requests, which seems it should not be too hard to implement. 😄

Will try to get this done in the next few days, time permitting.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/riptidewave93/RFLED-Server/issues/14#issuecomment-285928750, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMt79AjRoxEhtE3C5ZBiFa9MUHZNdJrks5rk6VwgaJpZM4MX6bD .

riptidewave93 commented 7 years ago

I don't use iOS, but I use RGBLEDContoller on Android without issue. I also don't know what homeassistant uses.

riptidewave93 commented 7 years ago

More digging, seems HomeAssistant should support both versions. https://github.com/home-assistant/home-assistant/pull/5958/files

mattnewham commented 7 years ago

When it searches for a bridge then does your code tell it what version it is and therefore which data to send?

-- Matt Newham

On 12 March 2017 at 13:56:31, Chris Blake (notifications@github.com) wrote:

More digging, seems HomeAssistant should support both versions. https://github.com/home-assistant/home-assistant/pull/5958/files

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/riptidewave93/RFLED-Server/issues/14#issuecomment-285946200, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMt789zjvkhRv3X3A2SuqEQFYRN_Bhwks5rk_mPgaJpZM4MX6bD .

riptidewave93 commented 7 years ago

@mattnewham the API has no real "version" reply, but I am working on a quick patch to ensure this bridge only replies to setup requests from older apps, which should prevent newer protocol apps assuming this supports it.

riptidewave93 commented 7 years ago

For anyone who finds this issue down the line, documentation of the actual v6 api calls can be found at https://github.com/vikstrous/zengge-lightcontrol/blob/master/README.md.

@mattnewham can you please try the following app? Note that discovery should only work for older API requests. rfled-server.zip

mattnewham commented 7 years ago

Hey

Replaced the binary, discovery still seems to work with all the apps I have and also home assistant. Homeassistant then tries to send (I guess) a v6 packet as it exits with the short write error again:

2017/03/13 10:07:38 DEBUG: "Our Info: mac=b827eb033d43 ip=192.168.60.160" 2017/03/13 10:07:38 "rfled-server started!" 2017/03/13 10:08:02 DEBUG: "ADM: message was HF-A11ASSISTHREAD from 192.168.60.50:48899" 2017/03/13 10:10:10 DEBUG: "LED: message was E\x00 from 192.168.60.50:40291" 2017/03/13 10:10:10 short write

Id really like to get this to work with HomeAssistant at least, there are hundreds of users with limitlessLED products using it for home automation and if we could get this working then we have a super reliable platform for controlling these things! On 12 March 2017 at 14:06:23, Chris Blake (notifications@github.com) wrote:

For anyone who finds this issue down the line, documentation of the actual v6 api calls can be found at https://github.com/vikstrous/zengge-lightcontrol/blob/master/README.md.

@mattnewham can you please try the following app? Note that discovery should only work for older API requests. rfled-server.zip

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

riptidewave93 commented 7 years ago

@mattnewham That's really strange to see, I wonder if your app isn't following the protocol correctly, and here's why.

When the command is sent to the "adm" service on port 48899 via broadcast, it should send either "HF-A11ASSISTHREAD" for API v6, or "Link_Wi-Fi" for API v5. On these requests, the server would reply with the IP and mac if it was a valid request.

The reason this is interesting, is your app sends a v6 request, but still sends a LED command even though the server never sent out a reply to it's discovery request. I feel as if what you are seeing may be an issue with the app you are using.

As for "short write", more digging shows this may be a UART configuration issue. I noticed you said you are using a Pi Zero W, but I do not have one to test. I recommend checking making sure you are setting the correct UART port, as the default may be used by the bluetooth/wifi radio, similar to how the Pi 3 does it.

mattnewham commented 7 years ago

Hey man

Sorry I have been away for a while. Just looking back into this.

Both the Homeassistant component and the manufacturer app seem to produce the above results even with your new code, so not sure what is going on there!

I would expect though that I am perhaps running into an issue with the UART connection. Doing some reading it seems that the Pi Zero W does indeed send the UART to bluetooth, so I think I may have to set TTYs0 instead of the AMA0 does that sound about right?

mattnewham commented 7 years ago

I got it working!

I had to enable UART in the boot config.txt - then change to use ttyS0 for rfled-server.

This then worked. Not sure what the weirdness is with the app registration, but its working now with both my ios app and homeassistant!