1 (edited by Christian 2013-02-01 03:17:10)

Topic: Using Chumby offline

Hello!

Because I don't have a permanent internet connection everywhere I want to use my chumby, I have done a little hack to use it without network. The goal was:

*) offline-use as alarm clock
*) some sort of "offline-channel" with widgets placed on an usb-device
*) ability to use the mystreams-section for local music
*) an easy way to switch online and use the chumby as designed

In the last time there seems to be a big demand to seperate the chumby from the chumby.com-infrastructure, and so I decided to post my solution for that situation.

Basically I put everything the chumby needs on the local web-server and redirect the chumby to localhost instead of chumby.com.
I wrote a description of what I did and zipped it with some example-files. You can get it here:
http://stud3.tuwien.ac.at/~e9825447/chumby-offline.zip

I hope I haven't forgotten to document something important - I am not a big linux-guru, so be forgiving. Perhaps it's useful for someone.

Greetings from Austria!
Christian

----------- edit ------------
I have done a new version, which doesn't change anything on the chumby itself, so to go online you just need to remove the stick and reboot.

http://stud3.tuwien.ac.at/~e9825447/chu … ne.2.0.zip

The Zip-fie contains everything you need, including the control panel (version 2-8-72, the current stable) and a sample widget. I also included the alarm2cron-scripts mentioned here, because I think they are very handy.

It is developed for a chumby classic, but it may work on other chumby devices, too.

--------- edit again ----------

Just in case anybody stumbles on my old posting again: I was offline wink for a while and the user Zurk was kind enough to pick up my work and care for this topic. I have not tested his version, but i am sure it is more uptodate than mine.
http://forum.chumby.com/viewtopic.php?id=7831

Re: Using Chumby offline

Nice work!

Re: Using Chumby offline

Really cool, thanks for sharing!

Re: Using Chumby offline

Thanks,

This will help me a lot.
My dsl modem (Verizon) drops the connection several times a day, so it's down about as much as it's up.
Verizon support has no clue other than telling me to reboot my pc.
Trying to get "Bob or Jane" in India off the script is pretty much impossible.

Greg

Re: Using Chumby offline

This is very handy, may i suggest that this be stickied?

Re: Using Chumby offline

Madox wrote:

This is very handy, may i suggest that this be stickied?

It would be better if the chumby could do this by default and this hack wouldn't be needed wink In my opinion the control panel should check whether there are xml-files under /mnt/usb/channels or /psp/channels and add them each to a own channel, and those channels should be available in any case whether connected or not.

by the way: I have updated my documentation to work with the current betas. (There have been little changes.)

Re: Using Chumby offline

This worked quite well until I tried to restore my network access.

I added http://localhost/cgi-bin/onoff.sh into streams, but after hitting play it did not restore the network access. Without network access I couldn't manually change the files and I had to restore to factory settings to get it back.

Did I miss something with the application of the onoff.sh script?
One thing I didn't try then was to use http://localhost/cgi-bin/custom/onoff.sh path instead.

Re: Using Chumby offline

bwanless wrote:

I added http://localhost/cgi-bin/onoff.sh into streams, but after hitting play it did not restore the network access. Without network access I couldn't manually change the files and I had to restore to factory settings to get it back.

Very strange. The onoff-script does nothing more than replacing the host-file and restarting the control panel. In my opinion there are only two possible situations after the script: If it worked the original host-file is restored and the chumby should operate as designed, or if it doesn't work the changed hostfile is still in place and the chumby should run in my "offline-mode".

Did the control panel restart after calling the stream?

bwanless wrote:

Did I miss something with the application of the onoff.sh script?
One thing I didn't try then was to use http://localhost/cgi-bin/custom/onoff.sh path instead.

No, the correct url is http://localhost/cgi-bin/onoff.sh as you have used it.

9 (edited by lil_gypsy 2008-04-29 06:49:31)

Re: Using Chumby offline

This broke my chumby, I kept getting "chumby.com is unreachable" message every time I tried to connect to my wireless network, after I tried this.  Even after I removed the flash drive.

I had to reset my chumby to factory defaults in order to fix it.

Re: Using Chumby offline

lil_gypsy wrote:

This broke my chumby, I kept getting "chumby.com is unreachable" message every time I tried to connect to my wireless network, after I tried this.  Even after I removed the flash drive.

Did you restore the hosts-file as mentioned in my instructions? That's the only file that gets changed on the chumby.

Re: Using Chumby offline

I was looking for something like that! I'm going to try it!!

Re: Using Chumby offline

I had had the same problems as lil_gypsy and bwanless
I can't use onoff.sh too, i add it to "my streams" section on music controlpanel, but when I press to "play" it doesn't do anything.

And i couldn't do that part to restore chumby "If you want to undo the changes, all you have to do is restore the original /psp/hosts-file." and my chumby holds on in a loading screen, I had to speak with customer support, I put the solution here: http://forum.chumby.com/viewtopic.php?id=2885

But offline works very well smile If you can explain a bit more how to undo the changes it would be very useful smile
thank you Christian!

Re: Using Chumby offline

Perhaps it's a problem with the new software-version. I was offline the last 3 weeks with my chumby and haven't updated yet. I will install the update today or tomorrow and see what happens.

Re: Using Chumby offline

ok, updated everything. The onoff.sh works for me sometimes, and sometimes not - I think I will need some time to debug this.

For restoring the settings: You should be able to undo th changes by executing following command:

 echo 127.0.0.1 localhost.localdomain localhost >/psp/hosts

If you can't ssh in you can put the line in the debugchumby-file.

Re: Using Chumby offline

theMartix wrote:

I can't use onoff.sh too

That was a nasty problem, but I think I found a possible solution. Add the following lines to the debugchumby-file:

mkfifo /tmp/cmd.fifo
tail -f /tmp/cmd.fifo |/bin/bash &

Change onoff.sh to:

#!/bin/sh

if [ -f /tmp/online_mode ]; then
   cp /mnt/usb/www/hosts.offline /psp/hosts
   rm -f /tmp/online_mode
else
  cp /mnt/usb/www/hosts.online /psp/hosts
  touch /tmp/online_mode
fi
   
echo "/usr/chumby/scripts/stop_control_panel;/usr/chumby/scripts/start_control_panel&" >/tmp/cmd.fifo

Hope that works for everyone.

Re: Using Chumby offline

Christian wrote:
theMartix wrote:

I can't use onoff.sh too

That was a nasty problem, but I think I found a possible solution. Add the following lines to the debugchumby-file:

mkfifo /tmp/cmd.fifo
tail -f /tmp/cmd.fifo |/bin/bash &

Change onoff.sh to:

#!/bin/sh

if [ -f /tmp/online_mode ]; then
   cp /mnt/usb/www/hosts.offline /psp/hosts
   rm -f /tmp/online_mode
else
  cp /mnt/usb/www/hosts.online /psp/hosts
  touch /tmp/online_mode
fi
   
echo "/usr/chumby/scripts/stop_control_panel;/usr/chumby/scripts/start_control_panel&" >/tmp/cmd.fifo

Hope that works for everyone.

Not on the Chumby One :-(

I was able to fix it with the debugchumby to overwrite the /psp/hosts file.

Otherwise, offline mode works on the Chumby One. Offline sleep sounds would be nice. Need to work on that.

--tom

Re: Using Chumby offline

tomtiki wrote:

Not on the Chumby One :-(

I'm sorry if not every thing works on a Chumby One, but since I don't own One I cannot try and find out the differences. Is it just the onoff.sh-script that doesn't work or are there more problems?

Christian

Re: Using Chumby offline

Christian wrote:

I'm sorry if not every thing works on a Chumby One, but since I don't own One I cannot try and find out the differences. Is it just the onoff.sh-script that doesn't work or are there more problems?

Christian,

Following is my test session with your scripts. I had earlier added a line to turn off the wifi in the "debugchumby" script, but removed it.  In retrospect, it's handy to leave the wifi running so I can ssh into the Chumby.

I could try this all again without the removed line, but it's late.

My conclusions would be to eliminate, the on/off script, because it does not appear to successfully reactivate the connection to chumby.com. It didn't for me.

If I wanted to reconnect the chumby to the wifi, I would power off, remove the usb key and restart. Then I am in a known state without the USB key. You will need to make sure that the /psp/hosts file is returned to "normal". I don't know what that is or how to do it. I've only been chumby hacking for 2 days now.

Let me know if you have any questions, or want me to test anything.

Cheers,
Tom



Here we go with the offline test:

booting with usb
- comes up in offline mode
- wifi still running - able to sshd from iMac
- run on/off from MyStreams
-- chumby freezes - no controls function, there is a delay
-- control panel restarts
-- /psp/hosts is back to hosts.online version
-- "New or existing connection?" screen appears
-- choose my connection
-- "connecting to network" screen appears
-- "chumby.com is unreachable" screen appears
   (I can ping out of the chumby, not to chumby.com)
- I power off chumby
- I remove usb key
- I power cycle chumby
- relatively normal boot, but stays at the chumby screen for quite a while
- "checking network status" screen appears
- "choose new or existing connection" screen appears
- I select my wifi
- connection to chumby.com fails

Plug in my USB keyboard
- I can ping localhost
- I can ping my router (192.168.1.254)
- I can ping my mac (192.168.1.67)
- ping chumby.com fails (209.34.82.226)

From my mac, I can ping the chumby (from 192.168.1.67 to 192.168.1.72)

If I try to ping chumby.com on my iMac (209.34.82.226), I get these errors :

macintosh:~ twk$ ping 209.34.82.226
PING 209.34.82.226 (209.34.82.226): 56 data bytes
36 bytes from 209-34-84-170.ood.opsource.net (209.34.84.170): Time to live exceeded
Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
4  5  00 5400 c86c   0 0000  01  01 7f1f 192.168.1.67  209.34.82.226

Not sure what that means.

At this point, I restarted sshd on the chumby :

/usr/chumby/scripts/start_sshd.sh

My little usb keyboard does not have "esc" or "ctl" keys, so I can't run vi.

I can now ssh from my iMac

So I now edit /psp/hosts and remove the line :

209.34.82.226 chumby.com www.chumby.com

I was going to reboot, so I looked for a script. There is a "reboot_normal.sh" script, but there is some code in there I don't understand.

Now I power cycle chumby again....
Delay at "chumby" screen. Stops bobbing up and down
"Checking Network Status" screen appears
"New or Existing Connection" screen appears
I Choose my wifi connection
"Connecting to Network" screen appears
"chumby.com is unreachable"

Now I'll try running the "fix it" script from the "debugchumby" file
-power off
- copy fix script to debugchumby
- plug in USB key
- power on Chumby

Chumby boots
Chumby asks to set the date.
I do this
Chumby asks to set the time
I do this.
Chumby appears back to normal
Pandora is working

I want to boot now without the USB key :

power off
remove usb key
power on

Chumby boots normally to default wifi. No prompts.
go to secret control panel, turn on sshd

/psp/hosts contains :
127.0.0.1 localhost.localdomain localhost

Re: Using Chumby offline

tomtiki wrote:

- ping chumby.com fails (209.34.82.226)

That will be the problem! At some point in the past the IP of chumby.com changed and in my hosts.online-file there is still the old IP.

tomtiki wrote:

So I now edit /psp/hosts and remove the line :

209.34.82.226 chumby.com www.chumby.com

Do the same in the hosts.online file. I think this will fix the problem.

tomtiki wrote:

I was going to reboot, so I looked for a script. There is a "reboot_normal.sh" script, but there is some code in there I don't understand.

It basically flushes all open files and shows the reboot-screen. I use it always without problem.

Christian

Re: Using Chumby offline

Christian wrote:
tomtiki wrote:

- ping chumby.com fails (209.34.82.226)

That will be the problem! At some point in the past the IP of chumby.com changed and in my hosts.online-file there is still the old IP.

tomtiki wrote:

So I now edit /psp/hosts and remove the line :

209.34.82.226 chumby.com www.chumby.com

Do the same in the hosts.online file. I think this will fix the problem.

tomtiki wrote:

I was going to reboot, so I looked for a script. There is a "reboot_normal.sh" script, but there is some code in there I don't understand.

It basically flushes all open files and shows the reboot-screen. I use it always without problem.

Christian

Christian,

If I remove that line from the hosts.online file, then they will look like this :

hosts.online :
127.0.0.1 localhost.localdomain localhost

hosts.offline :
127.0.0.1 localhost.localdomain localhost chumby.com www.chumby.com xml.chumby.com

Is this good enough? I will try the scripts again later today.

--tom

Re: Using Chumby offline

You might need to make sure there's a "crossdomain.xml" present on the local webserver.  Part of the process it uses for determining a connection to the Internet is to try to fetch that file, and it assumes that there's a problem if it can't.  Drop it into /www and see if that helps.

As for rebooting -- with the chumby One we fixed it so "reboot" works like on a standard Linux system, where it switches runlevels and does all of the unmounting and such through init.  I believe reboot_normal.sh will still work, though it is still somewhat Classic-specific, in that it modifies the MSP to ensure it boots back into normal mode (there is no MSP on the One).

Re: Using Chumby offline

ChumbyLurker wrote:

You might need to make sure there's a "crossdomain.xml" present on the local webserver.  Part of the process it uses for determining a connection to the Internet is to try to fetch that file, and it assumes that there's a problem if it can't.  Drop it into /www and see if that helps.

That's right. And for this reason my offline-hack already contains a crossdomain.xml in the root of the webserver smile

Christian

23 (edited by u063096 2010-01-15 09:58:38)

Re: Using Chumby offline

Yippeee smile

I got the offline mode running - thanks, Christian!

I got two wishes, though: a) was it possible to indicate somewhere what mode the device is in - on- or offline? I ended up with a non-networking C1 once as I did not count how often I triggered onoff.sh... No big deal then, as I only had to power up again with the USB and try it once more. But... wink
b) I tried to add a second channel in offline mode, to hold my wake-up animation, that shall be called by the alarm. I added another <profile>...</profile> block in profile.xml with a different ID. The Chumby knows there are two channels then, but when trying to switch channels it detects a loss of network connection and goes to the WLAN screen. Any idea how to accomplish that?

[Edit]One more thing: how to I set the time a widget is to stay on the screen in offline mode? Any parameters in the profile.xml file as well?

Re: Using Chumby offline

u063096 wrote:

I got two wishes, though: a) was it possible to indicate somewhere what mode the device is in - on- or offline? I ended up with a non-networking C1 once as I did not count how often I triggered onoff.sh... No big deal then, as I only had to power up again with the USB and try it once more. But... wink

You can tell whether my modification is in operation by the name of the channel. If you haven't changed it, it should be "offline-mode" as long as you are offline.

u063096 wrote:

b) I tried to add a second channel in offline mode, to hold my wake-up animation, that shall be called by the alarm. I added another <profile>...</profile> block in profile.xml with a different ID. The Chumby knows there are two channels then, but when trying to switch channels it detects a loss of network connection and goes to the WLAN screen. Any idea how to accomplish that?

I'm sorry - I didn't find a way to set up more than one channel.

u063096 wrote:

One more thing: how to I set the time a widget is to stay on the screen in offline mode? Any parameters in the profile.xml file as well?

There is an Example in the Wiki which deals with a similar topic. The parameters mentioned there should work in your case, too.

Re: Using Chumby offline

Christian wrote:

You can tell whether my modification is in operation by the name of the channel. If you haven't changed it, it should be "offline-mode" as long as you are offline.

That is what I thought, but IIRC it stayed "offline-mode" anyway. I will give it a try once more.

Christian wrote:

There is an Example in the Wiki which deals with a similar topic. The parameters mentioned there should work in your case, too.

You mean this: "<mode time="30" mode="timeout"/>"? I'll try as well.

Thanks for your support!