This folder contains JavaScript implementation of various OCF servers, such as:
- Fan
- CO2 detector
- Motion Sensor
- RGB LED
- LED (on/off)
- Buzzer
- Ambient Light Sensor
- Temperature
- Button
- Switch
- Solar Panel
All the OCF servers in these folders are written in JavaScript and leverage iotivity-node
(IoTivity JavaScript bindings) as well as the MRAA JavaScript bindings to access and control the busses (e.g. I2C, GPIO, Analog, etc.).
- Have the HW hooked up to your board (see table below)
node <ocf-server>.js &
- Et voila...
The connector listed below was derived from the corresponding *.js
files. Please double-check in the code (*.js
) in case of problems as the table may have gone out-of-sync.
[note]: This is a variation of the classical Button
implemenation in that it makes the button act as a toggle between true
and false
(instead of reporting true
when pressed and false
otherwise.
- Mount the Solar Panel and Line Actuator as shown in the following pictures (the Actuator Control Board is not visible in those pictures, refer to point 2 below for more details on how to connect all three components together):
- Connect the Line Actuator to the Actuator Control Board as follows: ![control-to-actuator] (./.pics/control-to-actuator.png)
- Connect the Actuator Control Board to the Intel® Edison Board for Arduino using the
RC
connector as follows: ![control-to-edison] (./.pics/control-to-edison.png) and following the table below:
Actuator | Edison |
---|---|
- | GND |
+ | 5V |
RC | Digital PWM pin 3 |
- Connect the Grove LCD RGB panel to any
I2C
connector on the Grove Base Shield that is installed on your Intel® Edison Board for Arduino as highlighted in the green circle on the following picture. Please make sure that theVcc
power switch (highlighted in red on the picture below) on the Grove Base Shield is set to 5V to ensure proper operation of the Grove LCD RGB panel.
In order to get all components to work correctly, you will also need to make sure the following JavaScript bindings are available:
Peripheral | Node.js module |
---|---|
Solar Panel | mraa |
LCD | jsupm_i2clcd |
Not having those available will disable the corresponding device and switch to simulation mode.
Once you are all set, start the OCF server as follows: node solar.js &
Note that when using the Ostro OS, its firewall will block the IoTivity network traffic by default. A brute-force approach is to disable the firewall altogether as follows:
# systemctl disable iptables
# systemctl disable ip6tables
A better solution would be to open up just the ports that are required. Port 5683 is used by the CoAP protocol during the device discovery phase, 5684 is used for secured traffic (note: this will be used when IoTivity turns on the SECURED
compile-time flag) and other (random) ports are used later to communicate with the device. If you wish to open up just the required ports, you can do so as follows:
# iptables -A INPUT -p udp --dport 5683 -j ACCEPT
# iptables -A INPUT -p udp --dport 5684 -j ACCEPT
To open ports for the IPv6 traffic, do:
# ip6tables -A INPUT -s fe80::/10 -p udp -m udp --dport 5683 -j ACCEPT
# ip6tables -A INPUT -s fe80::/10 -p udp -m udp --dport 5684 -j ACCEPT
A range of ports can also be specified as follows:
# iptables -A INPUT -p udp --dport <start>:<end> -j ACCEPT
# ip6tables -A INPUT -s fe80::/10 -p udp -m udp --dport <start>:<end> -j ACCEPT
For more information on how to make these changes permanent in your own Ostro OS image, please follow the instructions on the Configuring Ostro OS Firewall page.