The IoT gateway for each room is a Pine64 singleboard computer that runs Armbian OS. It also acts as wifi accesspoint and router/gateway for the IoT devices in the room. This wifi is meant exclusively for the devices in the room though, and not for users.
To install it, you need to take the following steps (elaborated below):
- Flash the sd-card with our own Armbian imageate
- Configure a static IP address in the dhcp server on the smart-classroom production server for each gateway device
- Do the first-run stuff to setup ssh
- Run ansible for the smart classroom production server
- update the group_vars and hosts file for the smart_classroom_gateway devices in ansible
- run ansible for the smart-classroom-gateways
Setting a static IP in the dhcp server
- After flashing the SD cards, boot the devices with an ethernet cable plugged into a switch that is connected to the smart-classroom vlan.
- SSH to smart-classroom.foundationu.com and run
less /var/lib/dhcpd/dhcpd.leases. This should show all the dynamic ip addresses. Including the ones for the Pine64's. Get the hardware-ethernet addresses for them.
- go to your ansible folder. Edit group_vars/smartclassroom_prod
- In the dhcpd_static_hosts list, add an entry at the bottom for each Pine64. Set an ipaddress (just continue counting from the last one), it's ethernet address and name. Don't worry yet about which physical device corresponds to which name in here.
ansible-playbook -i hosts smart_classroom.yml --limit=prodto update the production server with the new config.
- Power cycle the Pine64's. They should now get the new IP addresses.
- After assigining a static ip address, you can login to the devices through ssh. The user is root and the default password is 1234. The first time you log-in you need to change the root password. Just change it to 12345678 as ansible will change it later anyway.
- After you changed the root password, it asks to create a new user. Exit out of this with ctrl-c. You get kicked out now, which is fine.
- Login back through ssh. Now make a folder ~/.ssh (with mkdir) and edit ~/.ssh/authorized_keys (using nano).
- In the file, add your public ssh key
- Log out again.
Updating and applying the smart_classroom_gateway config
- In the ansible folder: open the hosts file. Create an entry for each new device in the form of (without the < and >)
- Make sure the hostname is the same as the hostname you set in the dhcp server config and the IP adress matches as well.
- Create a group for the new devices with [<groupname>:children] for instance like [sc_dorm_4thfloor:children]
- Add all the device names to that group
- Add the group itself to another group, that eventually leads up to smart_classroom_gateway_prod.
- Save and close the hosts file
- Make a file in group_vars for each device, by copying an existing SC_DORM_ file.
- Edit each file with ansible-vault edit <filename> (password is in keepass)
- Change the wifi ssid and room name to the correct room name and wifi name in there. The room name must match the name it is called in the webapplication (case sensitive).
- run ansible with
ansible-playbook -i hosts smart_classroom_gateway.yml --ask-vault-pass --limit=<groupname>
where <groupname> should be replaced with the name of the group you created in the hosts file.
- After this ni