物聯網服務租賃專家
Category IoT, TRRAK

Setup Docker Cloud Account

Let us get started. Please go to Docker Cloud  https://cloud.docker.com , and login with your own account.

Remember that we have Cloud provider available, and one Node cluster available. If you have not setup yet, please check step 2 videos.

Let us go to Service, and search images, keyword, owntracks… and choose the image under howardweng/*

Then we can give shorter service name for better recognition.
Then we move to port section. First port is MQTT server, and we would recommend to use static port 1883.
Second port is for recorder URL, and we use static port 8083.
Then that is it.

You can see the status become \"Running\".

Then we move the Service End point section, and we need to keep this information in the note, because we will use it a lot later.
Let me open up notepad , and keep these two URLs.

Let me open up the second URL, that will be the web site that we will see current and history locations. If you see this web site display like this, that means it is correctly installed.

Then we test our MQTT broker, we will use the first URL.

If we look at the first URL, front part would be the host name or broker service. 1883 is the port number.

Then we move to user credentials, we have not created any account yet, so we keep this blank for now.

Let us try to connect it, if you see green light, congratulations, your server is running correctly. but we can not do anything at this moment, because no users are authorized yet.

Next, we will need to add users to account. Let us create howard, and crystal two user name for parents, and kids just share the same user name, we use device name and other way to recognize them.

We will need to do commands next, this tutorials are designed for non-programmers like me, so I would assume that you are not used to command lines, and I will explain what I would do, and go slowly on this to make sure you would follow up with no problem.

 

Configure Mosquitto.acl on Docker

And we expect to publish GPS location on owntracks/howard/devicename, or owntracks/crystal/device name, but we expect to see all points visible on owntrack.

And the user information will be in the file name called Mosquitto.acl, it is under root directory folder owntracks, and there will be a folder mosquitto in owntracks, and the file is in folder of mosquitto.

We will use few commands.
dir :  that we will use to display files under this directory.
cd  :  is to change directory.
nano :  is the text editor I build, so we can use this command to edit the file.
inside nano text editor, we will use control +O +enter to save the changes.
then control + X to quite the text editor.

 

Edit ACL ( Access Control List)

When we open up this file, we will see the content like this.

Black is the original texts, and we will need to add RED texts in the file.

Let us come back to Docker Cloud to do this.

Go to service, then we will going to container inside the service. Go to container section, then enter to container.

Inside the container, go to tap of terminal. Let us do commands as I explained.

After users are added, then we test with MQTT.FX again.

We publish with topic owntracks/howard/iphone.  Subscribe on owntracks/#

If we can see the message like this, then that means, we are done correctly.

That is it, we will come back to this later.

mosquitto.acl        text

# This affects access control for clients with no username.
topic read $SYS/#
topic read owntracks/#

# This only affects clients with username "roger".
user roger
topic foo/bar

user jane
topic owntracks/jjolie/phone

# This affects all clients.
pattern write $SYS/broker/connection/%c/state

user howard
topic owntracks/#

user crystal
topic owntracks/#