#+TITLE:
#+AUTHOR: Bob Mottram
#+EMAIL: bob@freedombone.net
#+KEYWORDS: freedombox, debian, beaglebone, red matrix, email, web server, home server, internet, censorship, surveillance, social network, irc, jabber
#+DESCRIPTION: Turn the Beaglebone Black into a personal communications server
#+OPTIONS: ^:nil toc:nil
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="freedombone.css" />

#+BEGIN_CENTER
[[file:images/logo.png]]
#+END_CENTER

#+begin_export html
<center><h1>Mesh Network: How to use it</h1></center>
#+end_export

 * [[Boot trouble]]
 * [[Set the Date]]
 * [[Check network status]]
 * [[Connecting to the internet]]
 * [[Connecting two meshes over the internet via a VPN tunnel]]
 * [[Mobile devices (phones, etc)]]
 * [[Chat System]]
 * [[Collaborative document editing]]
 * [[Social Network]]
 * [[Sharing Files]]
 * [[Blogging]]

When you first boot from the USB drive the system will create some encryption keys, assign a unique network address to the system and then reboot itself. When that's done you should see a prompt asking for a username. This username just makes it easy for others to initially find you on the mesh and will appear in the list of users.

#+BEGIN_CENTER
[[file:images/mesh_initial_login.jpg]]
#+END_CENTER

After a minute or two if you are within wifi range and there is at least one other user on the network then you should see additional icons appear on the desktop, such as /Other Users/ and /Chat/.

* Boot trouble
If the system doesn't boot and reports an error which includes */dev/mapper/loop0p1* then reboot with *Ctrl-Alt-Del* and when you see the grub menu press *e* and manually change */dev/mapper/loop0p1* to */dev/sdb1*, then press *Ctrl-x*. If that doesn't work then reboot and try */dev/sdc1* instead.

After the system has booted successfully the problem should resolve itself on subsequent reboots.
* Set the Date
On the ordinary internet the date and time of your system would be set automatically via NTP. But this is not the internet and so you will need to manually ensure that your date and time settings are correct. You might need to periodically do this if your clock drifts. It's not essential that the time on your system be highly accurate, but if it drifts too far or goes back to epoch then things could become a little confusing in regard to the order of blog posts.

*Right click on the date* in the top right corner of the screen. Select *preferences*, then click the *Time Settings* button. You can then select the date from the calendar and set the time, then click the *Set System Time* button. Enter the default password, which is /freedombone/.
* Check network status
Unlike with ordinary wifi, on the mesh you don't get a signal strength icon and so it's not simple to see if you have a good connection.

Select the wifi icon on the desktop and enter the password '/freedombone/'. The network configuration will go into a monitoring mode and in the bottom right side of the window you will be able to see signal strength and other parameters. This can help you to locate systems or adjust antennas to get the best wifi performance.


#+BEGIN_CENTER
[[file:images/mesh_signal.jpg]]
#+END_CENTER

When you are finished close the window and then select the /Network Restart/ desktop icon, which will restart the B.A.T.M.A.N. network. You can also use the restart icon if you are within range of the mesh network but the /Chat/ and /Other Users/ icons do not automatically appear after a few minutes.
* Connecting to the internet

#+BEGIN_CENTER
[[file:images/mesh_architecture2.jpg]]
#+END_CENTER

If you need to be able to access the internet from the mesh then connect one of the peers to an internet router using an ethernet cable (shown as yellow above), then reboot it. Other peers in the mesh, including any attached mobile devices, will then be able to access the internet using the ethernet attached peer as a gateway. [[https://en.wikipedia.org/wiki/Freifunk][Freifunk]] works in a similar way.

After connecting one peer to the internet you may need to reboot other peers in order to update their network configurations.

If for legal reasons you need to connect to the internet via a VPN then openvpn is preinstalled and you can run the command:

#+begin_src bash
sudo openvpn myclient.ovpn
#+end_src

Where /myclient.ovpn/ comes from your VPN provider and with the password "/freedombone/".
* Connecting two meshes over the internet via a VPN tunnel

#+BEGIN_CENTER
[[file:images/mesh_architecture_vpn.jpg]]
#+END_CENTER

Maybe the internet exists, but you don't care about getting any content from it and just want to use it as a way to connect mesh networks from different geographical locations together.

In your home directory on a system connected via ethernet to an internet router you'll find a file called *vpn.tar.gz*. If you want another mesh to be able to connect to yours then send them this file and get them to uncompress it into their home directory also on an internet gateway machine. If they have an external IP address or domain name for your router then they will be able to VPN connect using the *Connect Meshes* icon. They should also forward port 653 from their internet router to the mesh gateway machine.

#+BEGIN_CENTER
[[file:images/mesh_connect.png]]
#+END_CENTER

You should create a new *vpn.tar.gz* file for every other mesh which wants to be able to connect to yours. If you are prompted for a password it is 'freedombone'.

From a deep packet inspection point of view the traffic going over the internet between mesh gateways will just look like any other TLS connection to a server.

* Mobile devices (phones, etc)

#+BEGIN_CENTER
[[file:images/mesh_architecture3.jpg]]
#+END_CENTER

To allow mobile devices to connect to the mesh you will need a second wifi adapter connected to your laptop/netbook/SBC. Plug in a second wifi adapter then reboot the system. The second adaptor will then create a wifi hotspot (the connection shown in green above) which mobile devices can connect to. The hotspot name also contains its local IP address (eg. "/mesh-192.168.1.83/").

On a typical Android device go to *Settings* then *Security* and ensure that *Unknown sources* is enabled. Also within *Wifi* from the *Settings* screen select the mesh hotspot. The password is "/freedombone/". Open a non-Tor browser and navigate to the IP address showing in the hotspot name. You can then download and install mesh apps.

#+BEGIN_CENTER
[[file:images/mesh_mobileapps.jpg]]
#+END_CENTER

On some android devices you may need to move the downloaded APK file from the *Downloads* directory to your *home* directory before you can install it.
* Chat System

Ensure that you're within wifi range of at least one other mesh peer (could be a router or client) and then you should see that the /Chat/ and /Other Users/ icons appear. Select the users icon and you should see a list of users on the mesh.

#+BEGIN_CENTER
[[file:images/mesh_peerslist.png]]
#+END_CENTER

Selecting a user followed by the Ok button will copy their Tox ID to the clipboard.

Now select the /Chat/ icon and once you are connected you should see the status light turn green. If after a few minutes you don't get the green status light then try closing and re-opening the Tox chat application. Select the plus button to add a friend and then paste in a Tox ID.

#+BEGIN_CENTER
[[file:images/mesh_paste_tox_id.jpg]]
#+END_CENTER

The other user can then accept or decline your friend request.

#+BEGIN_CENTER
[[file:images/mesh_friend_request.jpg]]
#+END_CENTER

You can also select an avatar by selecting the grey head and shoulders image.

#+BEGIN_CENTER
[[file:images/mesh_choose_avatar.jpg]]
#+END_CENTER

And by selecting the user from the list on the left hand side the chat can begin.

#+BEGIN_CENTER
[[file:images/mesh_text_chat.jpg]]
#+END_CENTER

One important point is that by default the microphone is turned off. When doing voice chat you can select the microphone volume with the drop down slider in the top right corner of the screen.

At present video doesn't work reliably, but text and voice chat do work well.

* Collaborative document editing
The mesh system includes the ability to collaboratively edit various sorts of documents using CryptPad. CryptPad is an almost peer-to-peer system in that it is designed for a client/server environment but that the server aspect of it is very minimal and limited to orchestrating the connected clients. With CryptPad installed on each mesh peer it effectively enables peer-to-peer collaborative editing. Documents are ephemeral and forgotten unless they're exported or copy-pasted to permanent storage.

#+BEGIN_CENTER
[[file:images/mesh_cryptpad1.jpg]]
#+END_CENTER

To create a document click on the CryptPad icon. Depending upon the specifications of your system it may take a few seconds to load, so don't be too disturned if the browser contents look blank for a while. Select _Rich Text Pad_ and give yourself a username.

#+BEGIN_CENTER
[[file:images/mesh_cryptpad2.jpg]]
#+END_CENTER

If you have the chat system running you can then copy and paste the URL for your pad into the chat, and the other user can then open the link and edit the document with you. You can repeat that for however many other users you wish to be able to edit.

* Social Network

Patchwork is available as a social networking system for the mesh. Like all social network systems it has a stream of posts and you can follow or unfollow other users. You can also send private messages to other users with end-to-end encryption.

Double click on the "Social" icon to open the app, then add your nickname and optionally a description. If you want to choose an avatar image some can be found within the directory */usr/share/freedombone/avatars*. On older systems or systems without a hardware random number generator, Patchwork sometimes takes a long time (a few minutes) to open for the first time after clicking the icon. This is most likely due to the initial generation of encryption keys, so be patient.

#+BEGIN_CENTER
[[file:images/patchwork_setup.jpg]]
#+END_CENTER

Other Patchwork users on the mesh will appear automatically under the *local* list and you can select and follow them if you wish. It's also possible to select the dark theme from *settings* on the drop down menu if you prefer.

#+BEGIN_CENTER
[[file:images/patchwork_public.jpg]]
#+END_CENTER

The Secure Scuttlebutt protocol which Patchwork is based upon is intended to be robust to intermittent network connectivity, so you can write posts when out of range and they will sync once you are back in the network.

* Sharing Files
You can make files publicly available on the network simply by dragging and dropping them into the /Public/ folder on the desktop. To view the files belonging to another user select the desktop icon called /Visit a site/ and enter the username or Tox ID of the other user.

#+BEGIN_CENTER
[[file:images/mesh_share_files.jpg]]
#+END_CENTER

* Blogging
To create a blog post select the /Blog/ icon on the desktop and then select *New blog entry* and *Ok*. Edit the title of the entry and add your text. You can also include photos if you wish - just copy them to the *CreateBlog/content/images* directory and then link to them as shown.

#+BEGIN_CENTER
[[file:images/mesh_blog.png]]
#+END_CENTER

To finish your blog entry just select /Save/ and then close the editor. On older hardware it may take a while to publish the results, and this depends upon the amount of computation needed by IPFS to create file hashes. If you make no changes to the default text then the new blog entry will not be saved.

#+BEGIN_CENTER
[[file:images/mesh_new_blog2.jpg]]
#+END_CENTER

#+BEGIN_CENTER
[[file:images/mesh_view_blog.jpg]]
#+END_CENTER

You can also visit other blogs, edit or delete your previous entry and change your blog theme.

#+BEGIN_CENTER
[[file:images/mesh_select_blog_theme.png]]
#+END_CENTER
