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






Donate to Apnea Board  
#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
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
  [split] FYSETC SD Wifi - Possible FlashAir Replacement Psikic 99 7,024 Yesterday, 08:56 AM
Last Post: Crimson Nape
  Flashair W-04 32GB doesn't works anymore Filippods 9 150 07-25-2022, 08:36 AM
Last Post: Filippods
  OSCAR not working with my new AirSense 11 (worked with my old AirSense 11) Chris33022 26 868 06-20-2022, 08:32 PM
Last Post: Chris33022
  OSCAR (Linux vs Win64) graph discrepancies Gideon 14 399 03-21-2022, 05:24 PM
Last Post: Aldebaran
  FlashAir W-02 Dafod 5 332 03-21-2022, 02:47 AM
Last Post: Dafod
  Spo2 Assistant / Smart device Assistant on Linux J Francois 2 312 02-25-2022, 12:31 PM
Last Post: Cornelius
Sad OSCAR 1.3.1 on Linux not showing new data? Gooserider 21 678 02-03-2022, 12:07 AM
Last Post: Gooserider


New Posts   Today's Posts






About Apnea Board

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