Class: Solar::Simulator::Network
- Inherits:
-
Object
- Object
- Solar::Simulator::Network
- Defined in:
- lib/solar/simulator/network.rb
Class Method Summary collapse
Class Method Details
.send_payload(data, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/solar/simulator/network.rb', line 9 def self.send_payload(data, = {}) payload = { p: { se: [:serial], ts: data[:timestamp], ty: "gr", cfg: [:type].to_i || 0, d: data[:values] } } uri = URI.parse([:uri]) req = Net::HTTP::Post.new(uri.request_uri) req["content-type"] = "application/json" req.body = payload.to_json Net::HTTP.start(uri.host, uri.port) { |http|http.request(req) } end |