lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb in imperituroard-0.2.8 vs lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb in imperituroard-0.2.9
- old
+ new
@@ -88,10 +88,11 @@
{:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
end
#2.2.4 Registering a Directly Connected Device (Password Mode) (V2)
def dev_register_passw_code_mode2(app_id, secret, node_id, name_p, description_p, device_type, profile)
+ out_resp = {}
token = get_token(app_id, secret)[:body]["accessToken"]
path = "/iocm/app/reg/v2.0.0/deviceCredentials?appId=" + app_id
url_string = "https://" + platformip + ":" + platformport + path
uri = URI.parse url_string
https = Net::HTTP.new(uri.host, uri.port)
@@ -104,17 +105,20 @@
request['Authorization'] = 'Bearer ' + token
request['app_key'] = app_id
request.body = {deviceInfo: {nodeId: node_id, name: name_p, description: description_p, deviceType: device_type}}.to_json
res = https.request(request)
p res.body.to_s
- {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
+ out_resp = {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
+ p out_resp
+ out_resp
end
#2.2.12 Deleting a Directly Connected Device
def dev_delete(app_id, secret, dev_id)
+ out_resp = {}
token = get_token(app_id, secret)[:body]["accessToken"]
path = "/iocm/app/dm/v1.1.0/devices/" + dev_id + "?app_Id=" + app_id + "&cascade=true"
url_string = "https://" + platformip + ":" + platformport + path
uri = URI.parse url_string
https = Net::HTTP.new(uri.host, uri.port)
@@ -128,13 +132,16 @@
request['app_key'] = app_id
res = https.request(request)
p res.code
p res.body
if res.body != nil
- {:code => res.code, :message => res.message, :body => {:answ => JSON.parse(res.body.to_s)}}
+ out_resp = {:code => res.code, :message => res.message, :body => {:answ => JSON.parse(res.body.to_s)}}
else
- {:code => res.code, :message => res.message, :body => {:answ => "no data"}}
+ out_resp = {:code => res.code, :message => res.message, :body => {:answ => "no data"}}
end
+
+ p out_resp
+ out_resp
end
#2.2.44 Querying the Device ID
\ No newline at end of file