Hi,
i found an efficient and easy solution in order to automate the upload process to the Flashair card. This is not a plugin, but can easily be installed via ssh. I am not using WebDAV as i found this very buggy, especially with big files. Instead, im using an upload script i found on github, specifically made for Flashair. My octoprint is installed on raspbian, RASPI 3B.
Working principle:
Example with Logfile aside: Flashair_Octoprint_Example_log.mp4.zip (2.3 MB)
-> Uploading GCODE file via Octoprint interface (regular upload, not SD)
-> new file in /home/pi/.ocoprint/upload is automatically detected
-> New file is being uploaded to SD
-> REST API command refreshes the SD content, so once you see the file pop up in octoprint, you know the process was successfull.
Installation: (supposing your main user linux account is pi. Adjust accordingly if not)
sudo apt install inotify-tools
cd
git clone https://github.com/CrashCash/FlashAirScripts.git
cd ~/FlashAirScripts/
chmod a+x sdls sdrm sdput sdtree
sudo cp flashair.py /usr/lib/python3/dist-packages/
cd
nano OctoFlashairUpload.sh
copy paste the following script, adjust SETUP
#!/bin/bash
######## SETUP ########
OctoApiKey=AAAAAAAAAAAAAAAAAAAAAAA # OctoPie API Key
OctoAddress=http://XXX.XXX.XXX.XXX:5000 # OctoPie URL, IP, Example: http://192.168.1.55:5000
FlashAirAddress=XXX.XXX.XXX.XXX # FlashAir IP Address
#######################
inotifywait -m /home/pi/.octoprint/uploads -e create -e moved_to |
while read path action file; do
echo
echo "$(date) ------------> DETECTION"
echo "The file '$file' appeared in directory '$path' via '$action'"
echo
if [[ $file == *.gcode ]]
then
echo "$(date) ------------> UPLOAD"
/home/pi/FlashAirScripts/sdput -a $FlashAirAddress $path/$file # do something with the file
echo
echo "Refresh SD Files on Octoprint"
curl -k -H "X-Api-Key: $OctoApiKey" -H "Content-Type: application/json" -d '{"command":"refresh"}' -X POST $OctoAddress/api/printer/sd # running command
fi
done
Exit with CTRL + X, Y, Enter
Autostart script
chmod +x /home/pi/OctoFlashairUpload.sh
sudo nano /etc/rc.local
Add this line before exit 0
nohup OctoFlashairUpload.sh > /home/pi/OctoFlashairUploadLog &
Configure Flashair card
In order to make the Flashair Card work with this script, take my configuration as an example. Put the Flashair into a Cardreader and open the hidden CONFIG file located at /YourFlashair/sd_wlan/CONFIG
Please adjust the follwing lines:
APPSSID; APPNETWORKKEY; CID (put your own here, if not, it will fail); VERSION; IP_Address; Subnet_Mask; MASTERCODE (not neccessary but i added it anyway)
[Vendor]
APPMODE=5
APPNAME=Flashair
APPSSID=YourWifi
APPNETWORKKEY=YourWifiPassword
CID=02544d533756194754d09a697a011501
VERSION=F15DBW3BW4.00.00
LOCK=1
PRODUCT=FlashAir
STA_RETRY_CT=0
UPDIR=/
UPLOAD=1
VENDOR=TOSHIBA
WEBDAV=2
IP_Address=XXX.XXX.XXX.XXX
Subnet_Mask=255.255.255.0
MASTERCODE=Anything
Be aware: The Flashair is pretty picky concerning the Wifi Router. Im using an old one, specifically reserved for the flashair. If it is not working, check /home/pi/OctoFlashairUploadLog for failures.
As you can see, im more or less hacking around to make this work. However, for me its fine. Feel free to improve and share ideas.