@hrios10
Connect all the things!
A network of every day objects that exchange data with connected devices.
If you think of the connective device as a tool, how would you use it?
There are frameworks like Artoo, ThingSpeak, and IoT Assistant.
But you can do this all with Rails.
Some considerations:
Websockets
WebsockerRails::EventMap.describe do
subscribe :turn_on, 'api/v1/driveway_sensor#create'
subscribe :check_temperature, 'api/v1/driveway_sensor#check_temperature'
subscribe :change_temperature, 'api/v1/driveway_sensor#change_temperature'
subscribe :turn_off, 'api/v1/driveway_sensor#destroy'
endWebsocket-Rails
class Api::V1::DrivewayController < WebsocketRails::BaseController
def initialize_session
controller_store[:sensors] = DrivewaySensorInterface.new
end
def create
controller_store[:sensors].turn_on
end
def destroy
controller_store[:sensors].turn_off
end
def check_temperature
end
def change_temperature
end
end
Session Controllers
let dispatcher = new WebSocketRails('localhost:9001/websocket'),
task = {
'name': 'Check temperature for driveway',
'completed': false
};
...
$scope.turnSensorsOn = function () {
dispatcher.trigger('turn_on');
};Some Javascript
require 'artoo'
connection :spark, adaptor: :spark,
device_id: '343_GUILTY_SPARK',
access_token: 'xxxThE_TRuffLE_SHUffl3'
device :led, driver: :led, pin: 'D7' # light on spark
work do
every 1.second do
led.toggle
end
endArtoo-Spark
Ruby is great for prototyping, but is a challenge for building out full-fledged IoT applications.