Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options for LED behavior and offline mode #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

acourreges
Copy link

If you're interested, I added a config.h to setup some option at compile time.

  • ledFeedback: define how the LED should behave (always on, always off, only when transmitting IR...).
    I like to be able to disable the LED, to keep the room dark at night.
    Set to LED_VERBOSE to keep the same behavior as the current master branch.
  • useCloudControl: for people who use their device only over the LAN. This disables DNS, device id check, and regular request polling to the cloud servers.
    Set to true to keep the same behavior as the current master branch.

@mash
Copy link
Member

mash commented Feb 4, 2015

I'm sorry but I can't merge this to master.
IRKit uses almost all of our microcontrollers RAM, and I've always tried to use less memory than the previous releases when changing something to reduce testing time.
This change increases RAM usage, and I don't have unlimited time to test this.

But I know you and other people want what this pull request offers.
So I'd like to update the document on https://github.com/irkit/device and add a link to your fork.
How's that?

@acourreges
Copy link
Author

Sure, whatever works best for you.

I have been using this version for 3 weeks and I didn't notice any stability problem.
But indeed the binary is probably slightly bigger due to the extra instructions, so RAM usage slightly increases too.
Maybe by refactoring some code, or switching to pre-processor directives only it's possible to keep the same memory footprint. I'll try to take a look if I have time.

@mash
Copy link
Member

mash commented Feb 4, 2015

OK, take your time.

@acourreges
Copy link
Author

I updated the pull request to decrease SRAM usage.
This version now uses 5 bytes less than master.

I enabled printing memory stats (GSwifi.cpp line 902) and did some measures:

Branch Free Memory
master 0x107
Original pull request 0x106
Updated pull request 0x10C

@mash
Copy link
Member

mash commented Feb 10, 2015

Thanks!
I'll test this for a while.

@remino
Copy link

remino commented Dec 10, 2022

Hi, I’m a regular IRKit user. I have two devices at home.

They suddenly both stopped working. Even after resetting them, although I can connect to their local Wi-Fi networks, I can no longer set my Wi-Fi network on them.

It looks like this may be related to the termination of the IRKit service, which brought me here.

I see the PR is still open. Was this code ever merged with master? I’d like to try to update the firmware on my IRKit devices if I can.

@dk8pn
Copy link

dk8pn commented Dec 11, 2022

Hi, I’m also a regular IRKit user. I have two devices at home.

They stopped working now and are the basis for many devices in my smarthome. Am a Wndows10 user and have no idea how to get a new firmware onto the devices. Can anybody write a guideline for this? Where can the modified firmware be retrieved?

Tested Arduino IDE to upload a new firmware. Now i only need the 5 files changed. How can i download them here? Sorry for such question but am not an expert. Already downloaded the latest firmware 3.0.0.0 from Mash and want to exchange the 5 files now. Will this work out?

@dk8pn
Copy link

dk8pn commented Dec 11, 2022

Hi, I’m a regular IRKit user. I have two devices at home.

They suddenly both stopped working. Even after resetting them, although I can connect to their local Wi-Fi networks, I can no longer set my Wi-Fi network on them.

It looks like this may be related to the termination of the IRKit service, which brought me here.

I see the PR is still open. Was this code ever merged with master? I’d like to try to update the firmware on my IRKit devices if I can.

Am not an expert. Do we really need it merged with master? Downloaded the master from Mash which contains all files. If it would be possible to download the 5 files changed here, it would probably work to upload the modified firmware? Apologize in advance if this is nonsens.

@acourreges
Copy link
Author

acourreges commented Dec 11, 2022

Hi there,

I didn't touch this in a while but my modifications should still work.
The good news is since these devices are open-source, you can easily update them so they don't turn into bricks with the cloud service shutting down. 😃

I wrote a step-by-step guide here:
https://www.adriancourreges.com/blog/2015/02/01/customizing-irkit-firmware-led-and-offline-mode/
This walks you through the process of flashing a custom firmware with the cloud functionality disabled, this is a required step if the cloud servers are down.

Then 2nd step: once the custom firmware is installed, you can configure your IRKit device (joining your home wifi) by following this guide:
http://www.adriancourreges.com/projects/irkit-web-remote/live/public/setup.html

And finally, this is an optional 3rd step but people who relied only on the cloud to send their commands will need some local solution to send commands over LAN now.
Here is a 3rd tutorial to control IRKit from a webpage you can host on your LAN:
https://www.adriancourreges.com/blog/2015/01/31/introducing-irkit-web-remote/

I hope this helps!

@dk8pn
Copy link

dk8pn commented Dec 12, 2022 via email

@remino
Copy link

remino commented Dec 12, 2022

Sounds like it’s our responsibility at this point to make it work, and possibly to write a guide for them.

I’ll try to flash my IRKit devices with the updates from this PR. Never done such a thing before, but I guess it’s a good time to give it a go as any.

@dk8pn
Copy link

dk8pn commented Dec 12, 2022

Sounds like it’s our responsibility at this point to make it work, and possibly to write a guide for them.

I’ll try to flash my IRKit devices with the updates from this PR. Never done such a thing before, but I guess it’s a good time to give it a go as any.

I am on Windows10 and did it also for the first time. Downloaded the complete .zip file using Adrian's link. Installed Arduino IDE 2.0.3 for Win10 64bit. Went along the few steps of Adrian's procedure up the cert.h compiling issue. Saw that cert.h is not part of the 5 files modified within this project. Exchanged the file against the original one and it does the job.

Hope that Adrian finally confirms that this way forward was okay. He is the expert.

@acourreges
Copy link
Author

acourreges commented Dec 12, 2022

@dk8pn The Arduino IDE version you're using (2.0.3) might be too new and the original IRKit codebase probably has some issues compiling against it.
At the time, back in 2015, we were using Arduino IDE 1.0.6, everything should compile fine out-of-the-box with this IDE version.
You can download 1.0.6 from here: https://www.arduino.cc/en/software/OldSoftwareReleases fortunately it seems to still be maintained.

If you really want to use a newer IDE version you'll have to update a bunch of stuff (like the cert.h you did), the changes don't look too hard, see the commit 0829db3
But I don't really recommend using a newer IDE since a new compiler might introduce subtle regressions, for example increased RAM consumption like in #9 (comment)
The safest way to avoid potential issues is to stick to the old Arduino IDE 1.0.6 which has been battle-tested for several years.

@dk8pn
Copy link

dk8pn commented Dec 12, 2022

@dk8pn The Arduino IDE version you're using (2.0.3) might be too new and the original IRKit codebase probably has some issues compiling against it. At the time, back in 2015, we were using Arduino IDE 1.0.6, everything should compile fine out-of-the-box with this IDE version. You can download 1.0.6 from here: https://www.arduino.cc/en/software/OldSoftwareReleases fortunately it seems to still be maintained.

If you really want to use a newer IDE version you'll have to update a bunch of stuff (like the cert.h you did), the changes don't look too hard, see the commit 0829db3 But I don't really recommend using a newer IDE since a new compiler might introduce subtle regressions, for example increased RAM consumption like in #9 (comment) The safest way to avoid potential issues is to stick to the old Arduino IDE 1.0.6 which has been battle-tested for several years.

Followed your advise successfully:

  • Installed Arduino IDE 1.0.6 for Windows
  • Took your original file set from your .zip file download link: https://github.com/acourreges/device/archive/settings-led-cloud.zip
  • Changed config.h and set "useCloudControl=false"
  • Compiled and uploaded the new firmware -> worked out without any issues
  • My WLAN access data, as used for the cloud version earlier, was still available after upload of the modified firmware

So, finally many thanks and kudos for such great support to Adrian @acourreges . Am happy to reuse your work from 8 years ago.

@remino
Copy link

remino commented Dec 13, 2022

Sadly, for me, it didn’t work. I run macOS Ventura on a M1 MacBook and I only have Windows 11 in a Parallels VM.

I have two IRKit devices:

  • One of them, I’ve reset. Light always blinks red now.
  • The other, I have not reset. Light blinks from red, to green, to cyan, then blue, as if it connected to my Wi-Fi, but then goes back to green.

What I tried:

  • On Windows 11 (in Parallels VM on macOS Ventura):
    • Downloaded and installed Arduino 1.0.6.
    • The Arduino Leonardo USB device appears.
    • Followed the instructions on how to update the firmware per the README.
    • Set correct board and serial port.
    • Firmware seems to get compiled and uploaded successfully. Ends with “Done Uploading” message.
    • Both IRKit devices restart then behave like nothing was updated. (I’ve tried each one by one, not at the same time.)
  • On macOS Ventura 13:
    • Downloaded and installed Arduino 1.0.6.
      • Not supported by this version of macOS.
    • Downloaded and installed Arduino 1.6.3.
      • Version for which support was added in 0829db3.
      • Cloned original device repo for the latest from master. Merged acourreges:settings-led-cloud branch.
      • Cannot compile: “Bad CPU type in executable”. (See “Error 1” below. Verbose output was enabled to obtain this error message.)
    • Downloaded and installed Arduino 1.8.18.
      • Several warnings when compiling. Indicates firmware upload is done, but seems to have no effect.
  • On Raspbian GNU/Linux 10 (buster) (Raspberry Pi):
    • Installed default-jdk, downloaded Arduino 1.0.6.
    • X11 display is required. (Which I don’t currently have installed.)

Error 1

Arduino: 1.6.3 (Mac OS X), Board: "Arduino Leonardo"

Build options changed, rebuilding all

/private/var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/AppTranslocation/B915150A-C48F-47DB-BE75-15CDB72B7E96/d/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/private/var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/AppTranslocation/B915150A-C48F-47DB-BE75-15CDB72B7E96/d/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/private/var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/AppTranslocation/B915150A-C48F-47DB-BE75-15CDB72B7E96/d/Arduino.app/Contents/Java/hardware/arduino/avr/variants/leonardo /var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/build1564494105000390711.tmp/IRKitJSONParser.c -o /var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/build1564494105000390711.tmp/IRKitJSONParser.c.o 
Cannot run program "/private/var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/AppTranslocation/B915150A-C48F-47DB-BE75-15CDB72B7E96/d/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-gcc": error=86, Bad CPU type in executable

So I guess I’m SOL.

@dk8pn
Copy link

dk8pn commented Dec 13, 2022

Sadly, for me, it didn’t work. I run macOS Ventura on a M1 MacBook and I only have Windows 11 in a Parallels VM.

I have two IRKit devices:

  • One of them, I’ve reset. Light always blinks red now.
  • The other, I have not reset. Light blinks from red, to green, to cyan, then blue, as if it connected to my Wi-Fi, but then goes back to green.

What I tried:

  • On Windows 11 (in Parallels VM on macOS Ventura):

    • Downloaded and installed Arduino 1.0.6.
    • The Arduino Leonardo USB device appears.
    • Followed the instructions on how to update the firmware per the README.
    • Set correct board and serial port.
    • Firmware seems to get compiled and uploaded successfully. Ends with “Done Uploading” message.
    • Both IRKit devices restart then behave like nothing was updated. (I’ve tried each one by one, not at the same time.)
  • On macOS Ventura 13:

    • Downloaded and installed Arduino 1.0.6.

      • Not supported by this version of macOS.
    • Downloaded and installed Arduino 1.6.3.

      • Version for which support was added in 0829db3.
      • Cloned original device repo for the latest from master. Merged acourreges:settings-led-cloud branch.
      • Cannot compile: “Bad CPU type in executable”. (See “Error 1” below. Verbose output was enabled to obtain this error message.)
    • Downloaded and installed Arduino 1.8.18.

      • Several warnings when compiling. Indicates firmware upload is done, but seems to have no effect.
  • On Raspbian GNU/Linux 10 (buster) (Raspberry Pi):

    • Installed default-jdk, downloaded Arduino 1.0.6.
    • X11 display is required. (Which I don’t currently have installed.)

Error 1

Arduino: 1.6.3 (Mac OS X), Board: "Arduino Leonardo"

Build options changed, rebuilding all

/private/var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/AppTranslocation/B915150A-C48F-47DB-BE75-15CDB72B7E96/d/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/private/var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/AppTranslocation/B915150A-C48F-47DB-BE75-15CDB72B7E96/d/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/private/var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/AppTranslocation/B915150A-C48F-47DB-BE75-15CDB72B7E96/d/Arduino.app/Contents/Java/hardware/arduino/avr/variants/leonardo /var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/build1564494105000390711.tmp/IRKitJSONParser.c -o /var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/build1564494105000390711.tmp/IRKitJSONParser.c.o 
Cannot run program "/private/var/folders/zy/17xcp3xx6vb3q0qnfh06185h0000gn/T/AppTranslocation/B915150A-C48F-47DB-BE75-15CDB72B7E96/d/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-gcc": error=86, Bad CPU type in executable

So I guess I’m SOL.

Your first Windows11 attempt should have done it. Did you follow Adrian's step by step guide: https://www.adriancourreges.com/blog/2015/02/01/customizing-irkit-firmware-led-and-offline-mode/ and change the config.h to useCloudControl=false ?

For the device which you have reset you also need to execute Adrian's second procedure: http://www.adriancourreges.com/projects/irkit-web-remote/live/public/setup.html

@remino
Copy link

remino commented Dec 13, 2022

Oh, okay. My bad. I guess I overlooked that part. Thanks for pointing that out. I’ll try this and get back to you.

I also dug up an old Windows 8 tablet I forgot I had. I’ll use it as a backup if the above doesn’t work.

@remino
Copy link

remino commented Dec 13, 2022

Well, there you go. That was it.

Thanks, @dk8pn, for reminding me of the steps I forgot to take, and @acourreges for this nice 7-year-old PR. Not only this saves me from buying hundreds dollars in new gadgets to replace what already worked, I can also finally take the piece of tape off the LED lights, which I also thought were too bright.

One minor thing, the IRKit Setup Guide would not submit the Wi-Fi settings because of security, saying XMLHttpRequest cannot load http://192.168.1.1/wifi due to access control checks.. What I did then, I added a breakpoint in the dev tools just before the data is sent, then output it, and used it in cURL instead:

curl -H 'X-Requested-With: curl' -d "8/xxxxxxxxxxxxxxxx/yyyyyyyyyyyyyyyyyyyy//2//////zz" http://192.168.1.1/wifi

(Hashed home Wi-Fi network details above redacted.)

Within minutes, my IRKit devices are usable again. Thanks a lot!

@acourreges
Copy link
Author

About the XMLHttpRequest control check issue with the IRKit setup guide, my webpage used to work in 2015 but it's now hosted on a SSL website and Chrome won't let you send an HTTP request to IRKit from an HTTPS page for security reasons.
One workaround is to access the plain HTTP address:
http://www.adriancourreges.com/projects/irkit-web-remote/live/public/setup.html , this should work.
(Be careful Chrome tends to auto-switch back to HTTPS silently, but my website supports both HTTP and HTTPS)

Another safer option is to do Ctrl+S on the page, save it locally and open it with Chrome from your hard-drive. It won't enforce control checks with local HTML files and the HTTP request should work.
(You could also download the IRKit Web-Remote repository and open the local file public/setup.html with a browser)

Or your way of calling curl manually works as well of course. 😃

@remino
Copy link

remino commented Dec 13, 2022

Right. I know security around HTTPS has changed drastically in the past few years and I had my fair share of related issues to deal with.

Now back at this PR at hand, the devices work after flashing them with the changed firmware. But, I frequently have to restart them as they stop responding about 30 minutes after I start them. I haven't found any pattern yet so I currently can't pinpoint the problem.

@remino
Copy link

remino commented Dec 15, 2022

Still having the issue I mentioned. Only minutes after I start the devices, they stop responding and I have to restart them again. When they stop responding, I can no longer ping them and any HTTP request will time out.

I'm not sure how to debug those devices. I wonder if it's because I copied version.template to version.c and left __VERSION__ as it is, consuming a few more bytes of space on the board. I doubt it.

@dk8pn
Copy link

dk8pn commented Dec 15, 2022

Still having the issue I mentioned. Only minutes after I start the devices, they stop responding and I have to restart them again. When they stop responding, I can no longer ping them and any HTTP request will time out.

I'm not sure how to debug those devices. I wonder if it's because I copied version.template to version.c and left VERSION as it is, consuming a few more bytes of space on the board. I doubt it.

My two devices work stable. So let us compare the following things:

  • Did you take the file set from the PR or from Adrian's download link? I applied the .zip file from the downlaod link.
  • Renamed version.template to version.c
  • Modified config.h

Have not done more. I do not have the file "VERSION" which you mention. Maybe this makes a difference?

@remino
Copy link

remino commented Dec 16, 2022

Alright. Let's compare.

  • Did you take the file set from the PR or from Adrian's download link? I applied the .zip file from the downlaod link.

Yes, but I'll try again tonight to be sure.

  • Renamed version.template to version.c

Yes.

And by VERSION, I mean the __VERSION__ string in version.c. I've left it as it is. Thus, when doing requests to the IRKit, in the headers of the response, I get IRKit/__VERSION__ instead of a proper version number.

  • Modified config.h

Yes. In mine, I set ledFeedback to LED_SETUP_ONLY and useCloudControl to false.

@acourreges
Copy link
Author

I'm afraid I won't be of much help on this one. I did see my IRKit sometimes stop responding and needing a reset but that was something pretty rare, it's usually able to run weeks or months without needing a reset...

@dk8pn
Copy link

dk8pn commented Dec 16, 2022

@remino and @acourreges
Seems like we have no difference in setup. My devices are running now since 5 days without an issue. Am a bit out of ideas. Can WLAN standard be an issue? Remember that i had to set my Fritzbox years ago to n+b+g because the IR-Kit uses the oldest WLAN standard.

@remino
Copy link

remino commented Dec 16, 2022

I wonder if Homebridge is pinging the IRKits too often? No idea. I’ll have to check.

@hakataminamiWS
Copy link

@remino
I am also experiencing the same issue. Have you found any solution or workaround?

@remino
Copy link

remino commented Jan 11, 2023

@hakataminamiWS Sadly, no solution yet. I didn’t have time to investigate much. What I think I’ll end up doing for a workaround is have the IRKit devices plugged to IoT power outlets, and then a daemon on my Raspberry Pi will ping the IRKit devices, then turn off the outlets and turn them back on if the IRKits aren’t responding. It’s a really messy, stupid workaround, but I can’t think of anything better yet.

@dk8pn
Copy link

dk8pn commented Jan 11, 2023

@remino and @hakataminamiWS ,
My 2 IRKits are running now since my initial setup without any reboot. We already compared the setup procedure of the new firmware, and i have unfortunately no idea, how i could help you further.

@hakataminamiWS
Copy link

hakataminamiWS commented Jan 11, 2023

@dk8pn ,
Thank you for the comment. I also think that there is not much difference between the firmware of our IRKit.
Just for reference, here is what I have tried on Windows 11:
In case of connection not interrupted or reconnected:

  • Sending a ping (Test-Connection) to IRKit every 1 minute, the connection was not interrupted
  • After the connection was disconnected, the connection was re-established by unplugging and replugging the USB cable

In case of connection interrupted and not reconnected:

  • Sending a ping (Test-Connection) to IRKit every 20 minutes, the connection was interrupted
  • After the connection was disconnected, executing pnputil /restart-device 'USB\VID_***' did not reconnect the connection

@dk8pn
Copy link

dk8pn commented Jan 15, 2023

I have connected the IRKit to openHAB. It might be, that openHAB does the ping job because it checks weather a thing is "online" or not? This would explain your "1 minute" observation.

@remino
Copy link

remino commented Jan 31, 2023

I just dropped by to say that the workaround proposed by @hakataminamiWS works for me. I’ve reset and reconfigured both my IRKit devices. I also set up cron jobs one of my servers to ping them every minute. I can’t explain why that works, but since then, I never had to restart by IRKit devices again.

@healthcareguy
Copy link

I just got my IRKIT out of storage and used the instructions from here.

For some reason, everytime I point a remote and hit a button, it is resetting.

The Arduino shows the following log

<
c> AT+DNSLOOKUP=deviceapi.getirkit.com

ERROR
c< ERROR
!E11
!E30
!E25
c> AT+NCLOSEALL

  1. Does anyone have any clue as to what may be the issue?
  2. Also, is there some file merge (between here and acourreges repo that needs to take place in the repo? Can someone list the files?

@healthcareguy
Copy link

I didnt have the time to do a deep dive but I got mine to work.

If it helps anyone, use these instructions but disable line 256 in firmware\src\IRKit\IRKit.ino:

Basically this

int8_t cid = irkit_httpclient_post_messages();`

in to something like

// int8_t cid = irkit_httpclient_post_messages();
 int8_t cid = 1;

I havent done a lot of testing so the jury on stability is still out.

IRKIT was very nicely implemented - too bad it isnt available anymore.

@yak1ex
Copy link

yak1ex commented May 14, 2023

Probably, this is different from others' experiences. However, there may still be IRKit users here, so I wrote down.

There is unintentional RAM overwrite caused by long SSID and password, which may lead reset, hold or anything else.

AT command(10) + comma(1) + SSID + password is written to a buffer.
https://github.com/irkit/device/blob/master/firmware/src/IRKit/GSwifi.cpp#L1052
But the buffer has 48 byte length.
https://github.com/irkit/device/blob/master/firmware/src/IRKit/pgmStrToRAM.c#L20
So, long SSID and password causes unintentional RAM overwrite.
For my case, successive RAM is Serial and reset or hold occurs when new IR is received.

@remino
Copy link

remino commented Jun 12, 2023

@yak1ex I’m slow at replying since my IRKit devices are still working with the ping trick for the moment.

But I wanted to add, my SSID is 8-character long and the password is 10. It doesn’t sound like they are too long, but are they?

@yak1ex
Copy link

yak1ex commented Jun 13, 2023

@remino 8-character SSID and 10-character password should be safe. I have, probably, longer password length than ordinary one but it is not maximum, which should be 32 characters for SSID and 63 charcters for password.

eiryu added a commit to eiryu/device that referenced this pull request Aug 12, 2023
@eiryu
Copy link

eiryu commented Sep 25, 2023

There are two problems with this PR. However, a PR has been submitted to the original repository to correct them. cc: @acourreges

The above has not been merged yet, but if you want to use the fixed version immediately, please use this branch. cc: @remino @healthcareguy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants