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

Linux Downloadscript for FlashAir V1 and Airsense 10
#1
Linux Downloadscript for FlashAir V1 and Airsense 10
Hi, unfotunatly i bought an old FlashAir V1. It does not support long filenames and you are only able to download files via webbrowser. So i recommend buying some other card or at least a W-03.

Anyway i wrote a linux shell script to autodownload the session data from the Airsense 10. Unfortunatly it does not work with other machines.

Set your card to stationmode by adding "APPMODE=5" to your /SD_WLAN/CONFIG.

Code:
#!/bin/bash
# IP of your FlashAirCard
flashairip=192.168.1.41
# Folder you want to copy the SD-Files to
destinationdir=/destinationfolder



datadir=DATALOG/
filename=website.txt
filename2=doc.txt
declare -i y
yesterday=$(date -d "yesterday" '+%Y%m%d')
mkdir -p $destinationdir$datadir$yesterday
wget -np -q --output-document $filename http://$flashairip/$datadir$yesterday/
mapfile -t arr < $filename
for i in "${arr[@]}"
do
   if [[ "$i" =~ wlansd\[.*\]=.* ]]; then
    IFS="\"" read -a line <<< $i
    IFS="," read -a line <<< ${line[1]}
    IFS="." read -a ending <<< ${line[1]}              # you could get Time and Date by shifting and masking line 4 and 5. See below.
    wget -np -q --output-document $filename2 http://$flashairip/$datadir$yesterday/${line[1]}
    if [[ ${ending[1]} == "EDF" ]]; then
        ident=$(head -c 25 $filename2 | cut -c 22-)
        filedate=$(head -c 176 $filename2 | cut -c 169-)
        filetime=$(head -c 184 $filename2 | cut -c 177-)
        IFS="." read -a filetime <<< $filetime
        IFS="." read -a filedate <<< $filedate
        y=2000+filedate[2]
        case $ident in
        597B)
            sufix="CSL"
            ;;
        B0A2)
            sufix="EVE"
            ;;
        54DC)
            sufix="BRP"
            ;;
        85B7)
            sufix="PLD"
            ;;
        C580)
            sufix="SAD"
            ;;
        *)
            echo "Error - Could not recognize Datatype"
            ;;
        esac
    fi
    newname=$y${filedate[1]}${filedate[0]}_${filetime[0]}${filetime[1]}${filetime[2]}_$sufix.${ending[1],,}
    mv $filename2 $destinationdir$datadir$yesterday/$newname
   fi
done
wget -np -q --output-document ${destinationdir}STR.edf http://$flashairip/STR.edf
rm $filename

In case want to use the filedate and time:
Code:
     declare -i j y m d h m i s
    j=${line[4]}
    y=$(((($j & 0xfe00 )) >> 9 ))+1980
    m=$(((($j & 0x1e0 )) >> 5 ))
    d=$(((($j & 0x1f ))))
    j=${line[5]}
    h=$(((($j & 0xf800)) >> 11 ))
    mi=$(((($j & 0x7e0 )) >> 5 ))
    s=$(((($j & 0x1f)) << 1))
    printf -v newname "%04d%02d%02d_%02d%02d%02d_%02d.%s" $y $m $d $h $mi $s $k ${ending[1]}
Hope my script is not to dirty (please feel free to improve it).

Best wishes and be safe.
Post Reply Post Reply
#2
RE: Linux Downloadscript for FlashAir V1 and Airsense 10
Nice workaround.  That's one way to make lemonade out of a lemon. Thank you for sharing the code.

Thanks
Crimson Nape
Apnea Board Moderator
Project Manager for OSCAR - Open Source CPAP Analysis Reporter
www.ApneaBoard.com
___________________________________
Useful Links -or- When All Else Fails:
The Guide to Understanding OSCAR
OSCAR Chart Organization
Attaching Images and Files on Apnea Board
Apnea Helpful Tips

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


Possibly Related Threads...
Thread Author Replies Views Last Post
  Toshiba FlashAir SD Card, Mac (M2), OSCAR Setup Help WarDaddy427 1 417 10-02-2024, 01:25 AM
Last Post: donsburg
  Linux Mint 22 grioghair 18 1,036 08-27-2024, 12:44 AM
Last Post: untoutseul05
  Is there a solution to read out the newer versions of the Contect CMS50F under Linux? Mast04 13 2,038 07-22-2024, 01:02 AM
Last Post: Pierelly
  Toshiba FlashAir on Mac Notes mtwomey 12 2,964 06-29-2024, 09:36 AM
Last Post: risherwood
  Oscar 1.5.3 for Linux freezes after clicking on 'CPAP Importer'. Mast04 13 1,115 05-04-2024, 02:11 AM
Last Post: Mast04
  OSCAR v1.5.2 - Linux Versions Crimson Nape 3 584 03-17-2024, 02:35 PM
Last Post: Crimson Nape
  Flashair - Dreamstation -> Airsense 11 Autoset todivefor 14 1,340 02-28-2024, 07:22 PM
Last Post: Crimson Nape


New Posts   Today's Posts


About Apnea Board

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