For anyone looking for some help, here is the step-by-step process of getting this to run on the Mozilla Gateway Raspberry Pi image (0.6.1).
1. Get all the supporting software
First, login to your Raspberry Pi via SSH. Make sure the "enable SSH" option is set in the Mozilla Gateway interface (under Settings -> Developer).
Let's get the latest versions of the repositories, so your system knows what all the latest versions are, using this command:
sudo apt-get update
Next, we need to install Rust. It's the programming language in which MySController-rs was written.
sudo curl https://sh.rustup.rs -sSf | sh
Here you will be asked a question during the installation procedure. Choose ‘modify installation’ and select to install the beta version of rust. Keep the rest of the options at their defaults (simply press enter in those cases).
Next, we need to install some things this project relies on.
sudo apt-get install libssl-dev libsqlite3-dev
2. Create a settings file
Let's also create a settings file now. (And you use the same command again later if you want to change the settings). Type:
sudo nano /etc/myscontroller-rs/conf.ini
You are now editing a text file with a program called 'nano', a rudimentary text editor. Depending on that need, copy one of these two texts into it (ctrl-C and ctrl V on windows/linux, CMD-C and CMD-V on mac):
Option A.
If you are using a serial gateway for MySensors (an Arduino connected via USB), use this:
..and as it finally gets to the heart of the matter, the MySController code itself, you may start to see a lot of warnings like:
Compiling myscontroller-rs v0.6.5 (/home/pi/MySController-rs)
warning: cannot find type `table` in this scope
--> <::diesel::macros::table_body macros>:165:33
|
165 | derive ( Debug , Clone , Copy , QueryId ) ] /// The actual table struct
| ^^^^^^^ names from parent modules are not accessible without an explicit import
|
= note: #[warn(proc_macro_derive_resolution_fallback)] on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #50504 <https://github.com/rust-lang/rust/issues/50504>
Don't be alarmed. They are not a problem.
Finally, you will see:
Finished dev [unoptimized + debuginfo] target(s) in 22m 03s
Running `target/debug/myscontroller-rs`
The controller should now be running.
Now, it may well crash now with an error at this point. Something like:
thread 'main' panicked at 'calledResult::unwrap()on anErrvalue:
.. followed by the precise error message.
If so, do a search here and in google to learn more about the issue. You might find tips on how to fix it yourself. If you don't see any reference to the error, create a new issue here, and share in detail how you arrived at the issue. Mention things like the version of the Mozilla Gateway, the hardware you're running, that type of MySensors gateway you use (software or Serial Arduino).
Done!
Keep your terminal window open for now, as it will allow us to see what is going on under the hood.
4. Get the devices into Mozilla Gateway.
Finally open the Mozilla Gateway interface and go to Settings -> Add-ons. Configure the Web Things add-on, and add this url there:
http://127.0.0.1:8888
Now, you can try powering up your MySensors devices one by one. You should see a lot of activity in the terminal window. After finding each device the software should restart itself. Give it a few minutes. Restart your arduino's after they have been found too.
Try clicking the "add things" button in the Mozilla Gateway interface. You should now see the devices.
TROUBLESHOOTING
During the device discovery phase you can 'look under the hood' by opening these url's in your browser:
http://[YOUR CONTROLLER'S IP ADDRESS HERE]:8000/nodes
http://[YOUR CONTROLLER'S IP ADDRESS HERE]:8000/sensors
http://[YOUR CONTROLLER'S IP ADDRESS HERE]:8888
For anyone looking for some help, here is the step-by-step process of getting this to run on the Mozilla Gateway Raspberry Pi image (0.6.1).
1. Get all the supporting software
First, login to your Raspberry Pi via SSH. Make sure the "enable SSH" option is set in the Mozilla Gateway interface (under Settings -> Developer).
Let's get the latest versions of the repositories, so your system knows what all the latest versions are, using this command:
sudo apt-get update
Next, we need to install Rust. It's the programming language in which MySController-rs was written.
sudo curl https://sh.rustup.rs -sSf | sh
Here you will be asked a question during the installation procedure. Choose ‘modify installation’ and select to install the beta version of rust. Keep the rest of the options at their defaults (simply press enter in those cases).
Next, we need to install some things this project relies on.
sudo apt-get install libssl-dev libsqlite3-dev
2. Create a settings file
Let's also create a settings file now. (And you use the same command again later if you want to change the settings). Type:
sudo nano /etc/myscontroller-rs/conf.ini
You are now editing a text file with a program called 'nano', a rudimentary text editor. Depending on that need, copy one of these two texts into it (ctrl-C and ctrl V on windows/linux, CMD-C and CMD-V on mac):
Option A. If you are using a serial gateway for MySensors (an Arduino connected via USB), use this:
Option B. If you are using the ethernet variety, use this:
(and don't forget to also install the MySensors gateway software)
3. Get the code
OK, time to get the code and turn that code into the actual program. Type:
git clone https://github.com/tsathishkumar/MySController-rs.git
then
cd MySController-rs
and then
sudo cargo run
Great, now go make yourself a cup of tea. This should take about 15 minutes.
A lot of things will scroll by in the mean time. It will start with:
..followed by things like this..
..and as it finally gets to the heart of the matter, the MySController code itself, you may start to see a lot of warnings like:
Don't be alarmed. They are not a problem.
Finally, you will see:
The controller should now be running.
Now, it may well crash now with an error at this point. Something like:
thread 'main' panicked at 'called
Result::unwrap()on an
Errvalue:
.. followed by the precise error message.If so, do a search here and in google to learn more about the issue. You might find tips on how to fix it yourself. If you don't see any reference to the error, create a new issue here, and share in detail how you arrived at the issue. Mention things like the version of the Mozilla Gateway, the hardware you're running, that type of MySensors gateway you use (software or Serial Arduino).
Done!
Keep your terminal window open for now, as it will allow us to see what is going on under the hood.
4. Get the devices into Mozilla Gateway.
Finally open the Mozilla Gateway interface and go to Settings -> Add-ons. Configure the Web Things add-on, and add this url there:
http://127.0.0.1:8888
Now, you can try powering up your MySensors devices one by one. You should see a lot of activity in the terminal window. After finding each device the software should restart itself. Give it a few minutes. Restart your arduino's after they have been found too.
Try clicking the "add things" button in the Mozilla Gateway interface. You should now see the devices.
TROUBLESHOOTING
During the device discovery phase you can 'look under the hood' by opening these url's in your browser:
http://[YOUR CONTROLLER'S IP ADDRESS HERE]:8000/nodes http://[YOUR CONTROLLER'S IP ADDRESS HERE]:8000/sensors http://[YOUR CONTROLLER'S IP ADDRESS HERE]:8888
(so for example: http://192.168.1.110:8000/nodes)
They will list all the devices that have been found. If they haven't (yet), then you will only see:
[]