# Installation du Cashless sur pi VMA405 ou RC522
## 1 - Cloner le projet

## 2 - Créer une image
- PI OS Lite LEGACY
- Utilisateur = sysop
- Wifi
- SSH   
Attention, penser à mettre votre clef publique sur le pi (ssh-copy)

## 3 - Ansible(hôte) inventaire des pi
```
sudo nano /etc/ansible/hosts
```
```
[rpiDsi]
pi1 ansible_host=192.168.1.11 hostname=pi1 token=xxxxxxxxxxxx password=xxxxxxxxxxxx frontType=FPI serveur=nom_de_domain(+port si besoin) protocole=http(ou https)
pi2 ansible_host=192.168.1.6 hostname=pi2 token=xxxxxxxxxxxx password=xxxxxxxxxxxx frontType=FPI serveur=nom_de_domain(+port si besoin) protocole=http(ou https)
```
## 4 - Ansible(hôte) installation
- A la racine du projet
```
ansible-playbook install_1024x600_vma405_chromium.yml -K
```

# Informations

## Pin raspberry pi 3 b+ 
<table>
  <tbody>
    <tr>
      <td>côté usb</td><td>39</td><td>37</td><td>35</td><td>33</td><td>31</td><td>29</td><td>27</td><td>25</td><td>23</td><td>21</td><td>19</td><td>17</td><td>15</td><td>13</td><td>11</td><td>9</td><td>7</td><td>5</td><td>3</td><td>1</td><td>côté sdcar</td>
    </tr>
    <tr>
      <td>reseau</td><td>40</td><td>38</td><td>36</td><td>34</td><td>32</td><td>30</td><td>28</td><td>26</td><td>24</td><td>22</td><td>20</td><td>18</td><td>16</td><td>14</td><td>12</td><td>10</td><td>8</td><td>6</td><td>4</td><td>2</td> 
    </tr>
  </tbody>
</table>

## Cablage VMA405 ou RC522
<table>
  <tbody>
    <tr>
      <td>côté usb</td><td>39</td><td>37</td><td>35</td><td>33</td><td>31</td><td>29</td><td>27</td><td>25</td><td>SCK</td><td>MISO</td><td>MOSI</td><td>17</td><td>15</td><td>13</td><td>11</td><td>GND</td><td>7</td><td>5</td><td>3</td><td>vcc</td> 
    </tr>
    <tr>
      <td>reseau</td><td>40</td><td>38</td><td>36</td><td>34</td><td>32</td><td>30</td><td>28</td><td>26</td><td>NSS</td><td>RST</td><td>20</td><td>18</td><td>16</td><td>14</td><td>12</td><td>10</td><td>8</td><td>6</td><td>4</td><td>2</td>
    </tr>
  </tbody>
</table>


<table>
  <thead>
    <tr>
      <th>RC522 / VMA405</th><th>PI 3 B+</th><th>Couleur cable</th>
    </tr>
  </thead>
  <tbody>
    <tr><td>3.3v / VCC</td><td>1</td><td>rouge</td></tr>
    <tr><td>RST</td><td>22</td><td>marron</td></tr>
    <tr><td>GND</td><td>9</td><td>noir</td></tr>
    <tr><td>IRQ</td><td>pas utilisé</td><td></td></tr>
    <tr><td>MISO</td><td>21</td><td>jaune</td></tr>
    <tr><td>MOSI</td><td>19</td><td>vert</td></tr>
    <tr><td>SCK</td><td>23</td><td>bleu</td></tr>
    <tr><td>SDA</td><td>24</td><td>violet</td></tr>
  <tbody>
</table>

## splash screen (écran de boot)
```
sudo cp splash.png /usr/share/plymouth/themes/pix/splash.png
sudo cp splash.png /usr/share/plymouth/themes/pix/splash.png
```

- sudo nano /boot/config.txt   
disable splash=1

- sudo nano /boot/cmdline.txt   
consoleblank=0 loglevel=1 quiet logo.nologo


-Pour afficher l'image   
sudo apt install fbi

- Créer un service   
sudo nano /etc/systemd/system/splashscreen.service
```
[Unit]
Description=Splash screen
DefaultDependencies=no
After=local-fs.target
[Service]
ExecStart=/usr/bin/fbi -d /dev/fb0 --noverbose -a /home/sysop/splash.png
StandardInput=tty
StandardOutput=tty
[Install]
WantedBy=sysinit.target
```
- active le service   
sudo systemctl enable splashscreen.service 
sudo systemctl start  splashscreen.service

## /ext/xdg/openbox/autostart
```
#/etc/xdg/openbox/
DISPLAY=:0 xdotool getactivewindow key F5

# stop veille/économie dénergie
xset dpms 0 0 0 && xset s noblank  && xset s off

#Touches pour sortir du serveur X =>  CTRL-ATL-Backspace
setxkbmap -option terminate:ctrl_alt_bksp

sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/Default/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences

# vidage du cache chromium
rm -fr /home/sysop/.cache/chromium
rm -fr /home/sysop/.config/chromium/Default/

# orientation de l'écran
xrandr --output DSI-1 --rotate right

# lance chromium avec un user agent spécifique hostname,password,periph,ip (provenant en partie de .chromium_env)
cd /home/sysop/serveurNfcNodeJs/
node serveur_nfc.js

```

## /home/sysop/.bashrc (ajouter)
```
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor
```