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
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
  Is there a solution to read out the newer versions of the Contect CMS50F under Linux? Mast04 10 969 03-25-2024, 08:46 PM
Last Post: Pierelly
  OSCAR v1.5.2 - Linux Versions Crimson Nape 3 269 03-17-2024, 02:35 PM
Last Post: Crimson Nape
  Flashair - Dreamstation -> Airsense 11 Autoset todivefor 14 738 02-28-2024, 07:22 PM
Last Post: Crimson Nape
  [split] FYSETC SD Wifi - Possible FlashAir Replacement Psikic 131 21,664 01-12-2024, 11:59 AM
Last Post: scowell
  What version of Linux for my Chromebook? bluetangle127 1 459 10-26-2023, 10:54 AM
Last Post: Crimson Nape
  FlashPAP - FlashAir WiFi SD card utility TiredToo 296 95,494 10-05-2023, 06:54 AM
Last Post: olddog27
  F12/Take Screenshot Not Saving Screenshot under Linux? DigitalMan43 4 701 09-30-2023, 05:04 PM
Last Post: DigitalMan43


New Posts   Today's Posts


About Apnea Board

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