Detect flashair SD cards in network Download latest images and send them to a FTP server
Go to file
Dominique Roux 30f8fab67c Updated README
- Clarified where the log is
2020-08-09 20:08:10 +02:00
flashairup initial push for version 0.0.2 2020-07-16 15:30:51 +02:00
scripts Updated README: 2020-07-16 15:44:31 +02:00
.gitignore initial push for version 0.0.2 2020-07-16 15:30:51 +02:00
README.md Updated README 2020-08-09 20:08:10 +02:00
requirements.txt initial push for version 0.0.2 2020-07-16 15:30:51 +02:00

README.md

flashair uploader

Installation requirements

  • systemd (otherwise the timer have to be changed (crond is not able to operate at 7 second intervals)
  • git
  • python3, python3-pip sudo apt install python3-pip
  • libcurl4-openssl-dev libssl-dev sudo apt install libcurl4-openssl-dev libssl-dev

Setup

Get the code with git clone https://code.ungleich.ch/rouxdo/flashair-uploader.git Move the flashairup directory to the desired place (e.g. /home/<USER>/), referred now as WORKDIR

Install the required python packages:

  cd WORKDIR
  pip install -r requirements.txt

Systemd setup

Change in the WORKDIR the flashairup.systemd file and move the file to /etc/systemd/system/. Move the flashairup.timer file to the same location. The files can be found in the scripts directory.

After move the files to the correct directories, enable the timer with the following statement:

sudo systemctl enable --now flashairup.timer

Configuration and Directory hierarchy

Create the following directory structure inside the WORKDIR:

├── flashairup
│   ├── data
│   │   ├── cam1
│   │   │   ├── last.txt
│   │   │   └── pictures
│   │   └── ...
│   ├── flashairup.conf
│   └── ...
└── ...

where cam1 is only an example for the name of a cam. The last.txt is needed for keeping track of the index of the last synchronised pictures. If the card gets formatted, the counter in this file needs to be reset as well. The flashairup.conf should at least contain the DEFAULT section:

   [DEFAULT]
   ftp_srv = FTP-SERVER
   ftp_path = PATH
   ftp_user = USER
   ftp_pwd = PASSWORD
   db = new
   # Set the logger level (DEBUG, INFO, WARNING, ERROR)
   log_level = DEBUG

Add a cam section to the config file:

   [cam1] # cam name
   ip = CAM-IP
   location = LOCATION-OF-THE-PICTURES-ON-CAM

Example config:

   [DEFAULT]
   ftp_srv = my.ftp.server.org
   ftp_path = media/pictures
   ftp_user = ftpuser
   ftp_pwd = strongpassword1
   # Decide if the pictures are going to be uploaded in the new db or in the old db
   db = new
   # Set the logger level (DEBUG, INFO, WARNING, ERROR)
   log_level = DEBUG

   [cam1]
   ip = 10.0.0.10
   location = DCIM/101NIKON

Troubleshooting

Log

You can examine the log with the following command:

journalctl -lfu flashairup

FlashAir SD-Card is not connecting to the WLAN

First, there may be a configuration error, check the FlashAir Configuration for a correct configuration

Second, the Access Point might run on a channel which is not reachable by the FlashAir card. Ensure that the configured channel is between 1 and 10.

Knowledge Base

The configuration on the Flashair cards was taken from here

Short concept of the python program

Since the Flashair cards create a small webserver on which the pictures are served, one is able to get them via curl. The python program therefore uses curl to download the pictures. With another curl command it is possible to get a list of files on the cam. The program gets this list and compare the number of the last image with the number on the corresponding last.txt. If the number is higher on the Flashair card, the picture gets processed. By processing, it is meant that the curl command for downloading a file is issued, then the file gets uploaded via FTP to the remote server and finally the counter in last.txt gets updated. This is important, because if there were some mistakes in the processing, the counter will stay the same and therefore, the picture is downloaded again in the next run. The job of each python function and object is documented inside the code