Hello Guest, Welcome to Apnea Board !
As a guest, you are limited to certain areas of the board and there are some features you can't use.
To post a message, you must create a free account using a valid email address.

or Create an Account


New Posts   Today's Posts

[How to] Linux tutorial for Flashair SD cards
#1
Preliminaries

Before rushing off to buy a Toshiba Flashair SD+wifi card to use in your PAP machine you should read the other threads here about using a Flashair card, in particular this one:

http://www.apneaboard.com/forums/Thread-...rd-in-PAPs

Let me also say that I have a Resmed S9 Autoset, hence that is the only machine I have tried. Other machines probably store data on the SD card differently, so my script (later, below) will have to be modified. If you do so and get the script working with a different machine, please post back here how you did it for the benefit of others.

I should also point out that Apnea Board member Jack_Russell_fan has written a Windows utility that makes it simple. He has recently released a new version that will run under WINE. But I don't want to install a massive thing like WINE just to use one small app. Therefore I decided to figure out how to do it natively.

Changing configurations

Before connecting you will want to make some changes to the default settings on the card. Settings are found in the file /SD_WLAN/CONFIG on the card, which you can access only if the card is mounted on your computer, so start by inserting the card into the SD card reader on your laptop or your USB card reader if your laptop doesn't have a card reader. This file is plain text, so open it in your favorite text editor (Gedit, Kate, etc.). Consider making the following changes:

APPAUTOTIME=0
#setting to zero disables the timeout, which I find preferable. You can also set it in milliseconds, to a maximum of 4294967294.

APPSSID= #enter here the name you want it to have on your network. The default on mine was flashair_123456789ap, which looks silly.

APPNETWORKKEY= #enter here the password to connect to the card. The default is 12345678. If you leave it blank the wifi will be open and anyone can connect to it. I left mine blank. Take note NSA: Send someone out to my house and you can download my CPAP data!

If you browse on "flashair" you can find the Toshiba Developers Forum, where these and other settings in the config file are explained.

Connecting

While the card is still mounted on your computer you need to make sure you can connect to it. Here I am assuming you are using a laptop and that you are connecting at home to a wireless router. I am also assuming you are using network manager and that you have a network icon somewhere in your panel. (If you are using wicd instead of network manager you can translate this paragraph to its options.) Click on the network icon (right-click on some desktops) and you will see a list of available wireless networks, and you will see that you are currently connected to your wireless router. You should also see the Flashair; if not, open a terminal and do sudo "ifconfig wlan0 down," followed by "sudo ifconfig wlan0 up." If you get an error message that it can't find wlan0 enter just "ifconfig" to see what your network device is. Repeat using the correct device name instead of wlan0.

If you select the Flashair your wireless chip will automatically disconnect from your wireless router and then connect to the Flashair.

[Side comment: If you are connected via ethernet you will have to disconnect it before you can connect to the Flashair.]

The stupid part

Assuming things went according to plan you should now be connected to the Flashair. Unfortunately, Toshiba made the lame decision to present all files in html instead of using a simple FTP server. So to see what is on the card open a browser tab and put 192.168.0.1 in the URL bar. You should see a lovely display of the files on the card. Before going further use your browser's "view source" option. This will show how the filenames are scattered all over the html code. Close the source window; I only wanted you to see what a mess Toshiba made of things by deciding to use html to present the files. Oh, and if that wasn't bad enough, Toshiba also hardwired the card to be 192.168.0.1 and you can't change it. That was the address of my home router so I had to change my home router's address before I could continue.

Using the Flashair in your CPAP machine

You are now ready to put the Flashair in your CPAP machine, but be prepared for more stupidity, this time thanks to the manufacturer of your machine. As I expected, when I put the Flashair into my S9 Autoset the machine immediately asked me if I wanted to "erase" the card. Don't worry, it won't wipe out the wireless capability, so let it go ahead. It erases the card, plus it adds the folder DATALOG, and also adds some files so that it will recognize it in the future. Unfortunately, my S9 Autoset is so lame that if I take the card out of the machine and put it back in again the machine will still insist that it needs to "erase" the card. This will wipe out previous data, so once the machine is happy with the card, don't ever take it out again.

You should take a moment at this point and go to your computer to make sure it can still see the card. The official range is 10m, but mine is about 15m away with a floor in between, and I can still connect to it. although the connection is a bit slow.

Now you have to spend a night so the machine will record some data on the card.

Retrieving the data

The next morning just get up as usual, but leave the card in the machine. Go to your computer where you are going to create a shell script. Open a new blank text document and paste in the following:

Code:
#!/bin/bash
wget -qO - http://192.168.0.1/DATALOG | grep 'DATALOG.*fname' | sed -e "s/^.*fname\"\:\"//" -e "s/\", \"fsize.*//" | while read line; do cd /home/jjj/CPAP/Resmed/DATALOG; wget -nc "http://192.168.0.1/DATALOG/$line";done

Comments:
I created the folder CPAP/Resmed/DATALOG on my computer. The S9 Autoset saves eight files every day to the DATALOG folder that it created on the card, and that is where SleepyHead will expect to find them. Make the folder anywhere you want on your computer, but be sure to make a DATALOG folder inside it, and then change the script above to reflect your folder.

Save the script somewhere, calling it "Flashair script" or whatever you want to call it. With your file browser right click on it and select Properties, then the Permissions tab, and set it to Executable. (Or do it from the command line if you prefer.) Now you are ready for the big moment. Open a file browser with a view of the DATALOG folder on your computer. Execute the script. You should see eight files appear in the folder. And now point SleepyHead at the folder (the Resmed folder if you used my folder format, not the DATALOG folder).

Did it work? In the interests of improving this tutorial, please report back with problems and how you solved them. Other comments are welcome as well. Smile
Post Reply Post Reply
#2
JJJ, I fixed your post so the bit that had the "link" to the datalog bit was enclosed in the "code" call. That way it was easier for everyone to copy. Or anyone clicking on it. Rolleyes
PaulaO2
Apnea Board Moderator
www.ApneaBoard.com


Breathe deeply and count to zen.

INFORMATION ON APNEA BOARD FORUMS OR ON APNEABOARD.COM SHOULD NOT BE CONSIDERED AS MEDICAL ADVICE. ALWAYS SEEK THE ADVICE OF A PHYSICIAN BEFORE SEEKING TREATMENT FOR MEDICAL CONDITIONS, INCLUDING SLEEP APNEA. INFORMATION POSTED ON THE APNEA BOARD WEB SITE AND FORUMS ARE PERSONAL OPINION ONLY AND NOT NECESSARILY A STATEMENT OF FACT.




Post Reply Post Reply
#3
Oh, and you should make a wiki page for this. You and the other guy who did the FlashAir card thing.
PaulaO2
Apnea Board Moderator
www.ApneaBoard.com


Breathe deeply and count to zen.

INFORMATION ON APNEA BOARD FORUMS OR ON APNEABOARD.COM SHOULD NOT BE CONSIDERED AS MEDICAL ADVICE. ALWAYS SEEK THE ADVICE OF A PHYSICIAN BEFORE SEEKING TREATMENT FOR MEDICAL CONDITIONS, INCLUDING SLEEP APNEA. INFORMATION POSTED ON THE APNEA BOARD WEB SITE AND FORUMS ARE PERSONAL OPINION ONLY AND NOT NECESSARILY A STATEMENT OF FACT.




Post Reply Post Reply


#4
(11-26-2014, 03:44 PM)JJJ Wrote:
Code:
#!/bin/bash
wget -qO - [...]";done

Did it work? In the interests of improving this tutorial, please report back with problems and how you solved them. Other comments are welcome as well. Smile

This will probably work for users of your CPAP machine, but would not work with my PRS1. Also, I find the need (with this approach and with the Windows program) to switch Wifi networks to be unnecessary; the card has a perfectly decent client/STA mode.

Here is my proposed solution, tested on my Mac. Yes, it redownloads everything every time, I'll fix it when it becomes a problem. It should work an all different CPAP machines. What do you think?



Attached Files
.txt   get_files.pl.txt (Size: 1.25 KB / Downloads: 156)
Post Reply Post Reply
#5
(01-31-2015, 06:12 AM)sleepy tinkerer Wrote: This will probably work for users of your CPAP machine, but would not work with my PRS1. Also, I find the need (with this approach and with the Windows program) to switch Wifi networks to be unnecessary; the card has a perfectly decent client/STA mode.

Here is my proposed solution, tested on my Mac. Yes, it redownloads everything every time, I'll fix it when it becomes a problem. It should work an all different CPAP machines. What do you think?

Yes, I am sure the PRS1, as well as most other machines other than my S9 Autoset, will require changes because other machines save the data in different files.

As an update, I finally gave up on the Flashair as more trouble than it was worth. I have no Mac or Windows computers, but I do have an Android phone, so I used that to change the SSID and remove the password (using the Toshiba Flashair app). This would work for several days, and then suddenly the Flashair would revert to the factory settings for the name and password. I could not figure out what the trigger was because it happened all by itself even when I did not access it.

I could have just changes the script so it would connect to the factory name and password, but it annoyed me that the device would just suddenly change on its own. More importantly, I was having a terrible time connecting to it because I was stretching the advertised distance - my bedroom is about 10m from the computer with a wall and a floor in between. Downloading files would sometimes take 15-20 minutes because the connection was not terribly stable.

There was also a continual problem with the S9 Autoset. The machine is so stupid that if I ever removed and reinserted the card the machine would insist that the card needed to be reformatted, even though it had already done so. And I did need to reinsert the card occasionally because about once a week the card would just disappear. I could sit right next to the CPAP machine with my phone and the card would not appear. The first time this happened I had data on the card that I didn't want the S9 to wipe out, so I unplugged the S9 and plugged it back in instead of pulling the card. Afterwards the card became visible again, but in later attempts the S9 insisted on reformatting it when I plugged the machine back in again.

The Flashair is a good idea, but badly designed. I'll wait until someone comes out with one that has a simple FTP server so we won't need scripts to fish the files out of the proprietary html mess that Toshiba created, and better range.
Post Reply Post Reply
#6
Has any one tried and played with some of the other WiFi cards out on the market , I saw eyefi there has been some Linux work on a fetching damon but I also saw reported that the card it self has a need for a lot of proprietary windows software to be used just to set it up.
Post Reply Post Reply


#7
(01-31-2015, 09:03 PM)Simon Wrote: Has any one tried and played with some of the other WiFi cards out on the market , I saw eyefi there has been some Linux work on a fetching damon but I also saw reported that the card it self has a need for a lot of proprietary windows software to be used just to set it up.

I know that Resmed's machines write to a bog standard FAT32 partition on the SD card. Every linux system installed on an Intel type machine can read FAT32 partitions so that shouldn't be a problem.

The data for each day resides in a folder in standard FAT32 files. The format I have not been able to discover - they are not .CSV files or MySQL databases.
Ed Seedhouse
VA7SDH

Your brain is not the boss.

Post Reply Post Reply
#8
(01-31-2015, 09:03 PM)Simon Wrote: Has any one tried and played with some of the other WiFi cards out on the market , I saw eyefi there has been some Linux work on a fetching damon but I also saw reported that the card it self has a need for a lot of proprietary windows software to be used just to set it up.

I looked into some of the others and they were even worse than the Flashair. Some were hard wired to accept only image files. (Why?) And they're all full of proprietary junk whose only purpose is to promote and protect the corporate image of the vendor.

It is interesting that Toshiba's web site suggests that medical devices is one possible use for the Flashair, yet their code makes such use difficult or impossible.
Post Reply Post Reply
#9
(01-31-2015, 12:54 PM)JJJ Wrote: The Flashair is a good idea, but badly designed. I'll wait until someone comes out with one that has a simple FTP server so we won't need scripts to fish the files out of the proprietary html mess that Toshiba created, and better range.

I have to quibble with you on a few points here --
There is actually a reasonable CGI interface to the FlashAir to retrieve the file list without parsing their awful HTML

Code:
$ curl "hxxp://cpap.lan/command.cgi?op=100&DIR=/P-Series" # had to munge link due to forum software, sorry
WLANSD_FILELIST
/P-Series,P04880217B098,0,16,17980,11544
/P-Series,last.txt,13,32,17985,3890

... but yes, you still need to write a script to parse that, and then grab the individual files over HTTP. I claim to have written that script generically to work with any conceivable CPAP machine (and would love to be proven wrong). Smile

An FTP server would be nice... the irony is that the firmware has an FTP *client* built into it, but no server code. They've actually crammed a lot of stuff into half a megabyte of firmware, I'm mildly impressed.

As far as range goes -- there's only so much range you can get out of a tiny antenna ... you might be able to solder a wire on there somewhere to get slightly better range, if you had the inclination. Otherwise, I don't think any other manufacturer will be able to do much better.

Maybe I'm still in the honeymoon phase with this card, but it's the cheapest thing out there (of any similar device) and it seems like it does what we want it to do, when it works. If it goes flaky like you describe, all bets are off -- how do you even debug it? I can see that quickly becoming frustrating and taking more time than you save in simply swapping the SD cards around.

Post Reply Post Reply


#10
(01-31-2015, 09:22 PM)eseedhouse Wrote:
(01-31-2015, 09:03 PM)Simon Wrote: Has any one tried and played with some of the other WiFi cards out on the market , I saw eyefi there has been some Linux work on a fetching damon but I also saw reported that the card it self has a need for a lot of proprietary windows software to be used just to set it up.

I know that Resmed's machines write to a bog standard FAT32 partition on the SD card. Every linux system installed on an Intel type machine can read FAT32 partitions so that shouldn't be a problem.

The data for each day resides in a folder in standard FAT32 files. The format I have not been able to discover - they are not .CSV files or MySQL databases.

If you're curious, the format is "documented" in the SleepyHead source code. I can't post clickable links yet, but it's hxxps://sourceforge.net/p/sleepyhead/code/ci/master/tree/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp

As far as the filesystem goes -- yes, the card shows up as a normal FAT32-formatted SD card. You need one special text file on the card -- /SD_WLAN/CONFIG -- but that's easily creatable by hand.

On the network side, there's a (slightly clunky but functional) way to download the entire contents of the SD card, whatever they happen to be. And it's $30. What's not to love? Smile

(As an alternate approach, I bought the PRS1 Bluetooth adapter to try with their SleepMapper iOS app. Waste of $50, all it does is give you 3 numbers -- Mask Fit %, Therapy hours, nightly AHI. And that's on a good day, after you end up having to re-pair it 3 times ... not clear how they even released a product this flakey.)

Post Reply Post Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  [CPAP] FlashAir III w/ PR System 1 A-Flex markn62 11 556 07-09-2017, 06:55 PM
Last Post: markn62
  Flashair Card Overheating jsielke 11 550 04-11-2017, 09:44 AM
Last Post: jsielke
Question Cannot map network drive for Toshiba FlashAir SD card mumug 13 1,078 02-06-2017, 05:56 AM
Last Post: pupcamper
  Flashair SD poor connection to router after power failure Roy289 5 534 08-06-2016, 12:54 PM
Last Post: Crimson Nape
  Easiest way to connect to FlashAir SD card using a static IP in Windows shawn42 13 3,024 07-20-2016, 01:58 PM
Last Post: AlanE
  Info guide to use flashair sd card? IDRIck 6 992 06-09-2016, 11:49 PM
Last Post: chill
Idea Wifi SD Cards waydavis 14 3,441 08-19-2015, 12:02 AM
Last Post: waydavis

Forum Jump:

New Posts   Today's Posts




About Apnea Board

Apnea Board is an educational web site designed to empower Sleep Apnea patients.

For any more information, please use our contact form.