ruby_home 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +4 -4
- data/.gitignore +2 -2
- data/.rubocop.yml +2 -9
- data/.standard.yml +3 -0
- data/CHANGELOG.md +6 -1
- data/Gemfile +2 -2
- data/Rakefile +4 -4
- data/examples/air_purifier.rb +7 -8
- data/examples/air_quality_sensor.rb +8 -9
- data/examples/battery_service.rb +2 -3
- data/examples/carbon_dioxide_sensor.rb +2 -3
- data/examples/carbon_monoxide_sensor.rb +3 -4
- data/examples/contact_sensor.rb +2 -3
- data/examples/door.rb +5 -6
- data/examples/fan.rb +2 -3
- data/examples/fan_v2.rb +2 -3
- data/examples/garage_door_opener.rb +9 -10
- data/examples/heater_cooler.rb +9 -10
- data/examples/humidifier_dehumidifier.rb +9 -10
- data/examples/humidity_sensor.rb +2 -3
- data/examples/leak_sensor.rb +2 -3
- data/examples/light_sensor.rb +2 -3
- data/examples/lightbulb.rb +2 -3
- data/examples/lock_mechanism.rb +6 -7
- data/examples/motion_sensor.rb +2 -3
- data/examples/occupancy_sensor.rb +2 -3
- data/examples/outlet.rb +2 -3
- data/examples/security_system.rb +12 -13
- data/examples/smoke_sensor.rb +2 -3
- data/examples/switch.rb +2 -3
- data/examples/television.rb +8 -13
- data/examples/temperature_sensor.rb +2 -3
- data/examples/thermostat.rb +10 -11
- data/examples/window.rb +5 -6
- data/examples/window_covering.rb +5 -6
- data/lib/ruby_home.rb +21 -21
- data/lib/ruby_home/accessory.rb +1 -1
- data/lib/ruby_home/accessory_collection.rb +6 -6
- data/lib/ruby_home/accessory_info.rb +18 -18
- data/lib/ruby_home/characteristic.rb +8 -8
- data/lib/ruby_home/characteristic_collection.rb +13 -13
- data/lib/ruby_home/config/characteristics.yml +30 -635
- data/lib/ruby_home/config/manual_characteristics.yml +278 -0
- data/lib/ruby_home/config/manual_services.yml +45 -0
- data/lib/ruby_home/config/services.yml +329 -370
- data/lib/ruby_home/configuration.rb +4 -4
- data/lib/ruby_home/device_id.rb +3 -3
- data/lib/ruby_home/dns/service.rb +4 -6
- data/lib/ruby_home/dns/text_record.rb +9 -9
- data/lib/ruby_home/errors.rb +1 -0
- data/lib/ruby_home/factories/characteristic_factory.rb +37 -37
- data/lib/ruby_home/factories/service_factory.rb +72 -72
- data/lib/ruby_home/factories/templates/characteristic_template.rb +5 -5
- data/lib/ruby_home/factories/templates/service_template.rb +11 -10
- data/lib/ruby_home/hap/crypto/chacha20poly1305.rb +2 -2
- data/lib/ruby_home/hap/crypto/hkdf.rb +4 -4
- data/lib/ruby_home/hap/crypto/session_key.rb +7 -7
- data/lib/ruby_home/hap/decrypter.rb +8 -8
- data/lib/ruby_home/hap/encrypter.rb +5 -6
- data/lib/ruby_home/hap/ev_response.rb +17 -17
- data/lib/ruby_home/hap/hap_request.rb +1 -1
- data/lib/ruby_home/hap/server.rb +4 -4
- data/lib/ruby_home/hap/server_handler.rb +8 -10
- data/lib/ruby_home/hap/session.rb +22 -22
- data/lib/ruby_home/hap/values/base_value.rb +3 -3
- data/lib/ruby_home/hap/values/bool_value.rb +4 -4
- data/lib/ruby_home/hap/values/float_value.rb +4 -4
- data/lib/ruby_home/hap/values/identify_value.rb +1 -1
- data/lib/ruby_home/hap/values/int32_value.rb +4 -4
- data/lib/ruby_home/hap/values/null_value.rb +1 -1
- data/lib/ruby_home/hap/values/string_value.rb +11 -11
- data/lib/ruby_home/hap/values/uint32_value.rb +5 -5
- data/lib/ruby_home/hap/values/uint8_value.rb +14 -14
- data/lib/ruby_home/hex_helper.rb +3 -3
- data/lib/ruby_home/http/application.rb +7 -7
- data/lib/ruby_home/http/controllers/accessories_controller.rb +3 -3
- data/lib/ruby_home/http/controllers/application_controller.rb +6 -6
- data/lib/ruby_home/http/controllers/characteristics_controller.rb +29 -29
- data/lib/ruby_home/http/controllers/identify_controller.rb +10 -10
- data/lib/ruby_home/http/controllers/pair_setups_controller.rb +18 -18
- data/lib/ruby_home/http/controllers/pair_verifies_controller.rb +9 -9
- data/lib/ruby_home/http/controllers/pairings_controller.rb +5 -5
- data/lib/ruby_home/http/serializers/accessory_serializer.rb +5 -5
- data/lib/ruby_home/http/serializers/characteristic_serializer.rb +24 -24
- data/lib/ruby_home/http/serializers/characteristic_value_serializer.rb +5 -5
- data/lib/ruby_home/http/serializers/object_serializer.rb +1 -1
- data/lib/ruby_home/http/serializers/service_serializer.rb +9 -9
- data/lib/ruby_home/http/serializers/uuid_helper.rb +2 -2
- data/lib/ruby_home/http/services/session_notifier.rb +8 -8
- data/lib/ruby_home/http/services/start_srp_service.rb +3 -3
- data/lib/ruby_home/http/services/verify_finish_service.rb +22 -22
- data/lib/ruby_home/http/services/verify_srp_service.rb +22 -22
- data/lib/ruby_home/identifier_cache.rb +4 -5
- data/lib/ruby_home/password.rb +14 -14
- data/lib/ruby_home/persistable.rb +22 -7
- data/lib/ruby_home/service.rb +3 -3
- data/lib/ruby_home/service_collection.rb +1 -1
- data/lib/ruby_home/version.rb +1 -1
- data/rubyhome.gemspec +31 -31
- data/sbin/characteristic_generator.rb +22 -24
- data/sbin/service_generator.rb +36 -27
- metadata +25 -8
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "base_value"
|
2
2
|
|
3
3
|
module RubyHome
|
4
4
|
class Uint32Value < BaseValue
|
5
5
|
DEFAULT_VALUES = {
|
6
6
|
color_temperature: 50,
|
7
|
-
lock_management_auto_security_timeout: 0
|
7
|
+
lock_management_auto_security_timeout: 0
|
8
8
|
}.freeze
|
9
9
|
|
10
10
|
def default
|
@@ -13,8 +13,8 @@ module RubyHome
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
def name
|
17
|
+
template.name
|
18
|
+
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "base_value"
|
2
2
|
|
3
3
|
module RubyHome
|
4
4
|
class Uint8Value < BaseValue
|
@@ -8,22 +8,22 @@ module RubyHome
|
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
def first_default_value
|
12
|
+
valid_values.keys.first
|
13
|
+
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
def valid_values
|
16
|
+
defined_values || range_values || raise(UnknownValueError, "Constraint contains an unrecognized list of values: #{template.constraints.inspect}")
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
def defined_values
|
20
|
+
template.constraints.dig("ValidValues")
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
23
|
+
def range_values
|
24
|
+
if (min = template.constraints.dig("MinimumValue"))
|
25
|
+
{min.to_s => min}
|
27
26
|
end
|
27
|
+
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/ruby_home/hex_helper.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
module RubyHome
|
2
2
|
module HexHelper
|
3
3
|
def self.pad(input, pad_length: 24)
|
4
|
-
pack_hex_string(unpack_hex_string(input).rjust(pad_length,
|
4
|
+
pack_hex_string(unpack_hex_string(input).rjust(pad_length, "0"))
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.unpack_hex_string(input)
|
8
|
-
input.to_s.unpack1(
|
8
|
+
input.to_s.unpack1("H*")
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.pack_hex_string(input)
|
12
|
-
[input].pack(
|
12
|
+
[input].pack("H*")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
Dir[File.dirname(__FILE__) +
|
1
|
+
Dir[File.dirname(__FILE__) + "/controllers/*.rb"].each { |file| require file }
|
2
2
|
|
3
3
|
module RubyHome
|
4
4
|
module HTTP
|
5
5
|
class Application
|
6
6
|
def self.rack_builder
|
7
7
|
::Rack::Builder.new do
|
8
|
-
map(
|
9
|
-
map(
|
10
|
-
map(
|
11
|
-
map(
|
12
|
-
map(
|
13
|
-
map(
|
8
|
+
map("/accessories") { run AccessoriesController }
|
9
|
+
map("/characteristics") { run CharacteristicsController }
|
10
|
+
map("/identify") { run IdentifyController }
|
11
|
+
map("/pair-setup") { run PairSetupsController }
|
12
|
+
map("/pair-verify") { run PairVerifiesController }
|
13
|
+
map("/pairings") { run PairingsController }
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "application_controller"
|
2
2
|
|
3
3
|
module RubyHome
|
4
4
|
module HTTP
|
5
5
|
class AccessoriesController < ApplicationController
|
6
|
-
get
|
7
|
-
content_type
|
6
|
+
get "/" do
|
7
|
+
content_type "application/hap+json"
|
8
8
|
|
9
9
|
if session.sufficient_privileges?
|
10
10
|
AccessorySerializer.new(identifier_cache.accessories).serialized_json
|
@@ -1,21 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require "logger"
|
2
2
|
|
3
3
|
module RubyHome
|
4
4
|
module HTTP
|
5
5
|
class ApplicationController < Sinatra::Base
|
6
6
|
disable :protection
|
7
7
|
|
8
|
-
logger = Logger.new(
|
9
|
-
logger.level = case ENV[
|
10
|
-
when
|
8
|
+
logger = Logger.new($stdout)
|
9
|
+
logger.level = case ENV["DEBUG"]
|
10
|
+
when "debug"
|
11
11
|
Logger::DEBUG
|
12
|
-
when
|
12
|
+
when "info"
|
13
13
|
Logger::INFO
|
14
14
|
else
|
15
15
|
Logger::WARN
|
16
16
|
end
|
17
17
|
set :logger, logger
|
18
|
-
enable :logging if ENV[
|
18
|
+
enable :logging if ENV["DEBUG"]
|
19
19
|
|
20
20
|
before do
|
21
21
|
logger.debug "Session"
|
@@ -1,19 +1,19 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "application_controller"
|
2
2
|
|
3
3
|
module RubyHome
|
4
4
|
module HTTP
|
5
5
|
class CharacteristicsController < ApplicationController
|
6
6
|
before do
|
7
|
-
content_type
|
7
|
+
content_type "application/hap+json"
|
8
8
|
require_session
|
9
9
|
end
|
10
10
|
|
11
|
-
get
|
11
|
+
get "/" do
|
12
12
|
CharacteristicValueSerializer.new(find_characteristics).serialized_json
|
13
13
|
end
|
14
14
|
|
15
|
-
put
|
16
|
-
json_body.fetch(
|
15
|
+
put "/" do
|
16
|
+
json_body.fetch("characteristics", []).each do |characteristic_params|
|
17
17
|
if characteristic_params.key?("value")
|
18
18
|
update_characteristics(characteristic_params)
|
19
19
|
elsif characteristic_params.key?("ev")
|
@@ -26,40 +26,40 @@ module RubyHome
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
29
|
+
def find_characteristics
|
30
|
+
params.fetch(:id, "").split(",").flat_map do |characteristic_params|
|
31
|
+
aid, iid = characteristic_params.split(".")
|
32
|
+
find_characteristic(aid: aid, iid: iid)
|
34
33
|
end
|
34
|
+
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
36
|
+
def update_characteristics(characteristic_params)
|
37
|
+
find_characteristic(**characteristic_params.symbolize_keys.slice(:aid, :iid)) do |characteristic|
|
38
|
+
characteristic.value = characteristic_params["value"]
|
40
39
|
end
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
def subscribe_characteristics(characteristic_params)
|
43
|
+
find_characteristic(**characteristic_params.symbolize_keys.slice(:aid, :iid)) do |characteristic|
|
44
|
+
notifier = SessionNotifier.new(session, characteristic)
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
end
|
46
|
+
unless characteristic.listeners.include?(notifier)
|
47
|
+
characteristic.subscribe(notifier)
|
49
48
|
end
|
50
49
|
end
|
50
|
+
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
def find_characteristic(aid:, iid:)
|
53
|
+
characteristic = identifier_cache.find_characteristic(accessory_id: aid.to_i, instance_id: iid.to_i)
|
54
|
+
yield characteristic if block_given?
|
55
|
+
characteristic
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
58
|
+
def require_session
|
59
|
+
unless session.sufficient_privileges?
|
60
|
+
halt 401, JSON.generate({"status" => -70401})
|
62
61
|
end
|
62
|
+
end
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "application_controller"
|
2
2
|
|
3
3
|
module RubyHome
|
4
4
|
module HTTP
|
5
5
|
class IdentifyController < ApplicationController
|
6
|
-
post
|
6
|
+
post "/" do
|
7
7
|
if accessory_info.paired?
|
8
8
|
paired_accessory
|
9
9
|
else
|
@@ -13,15 +13,15 @@ module RubyHome
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def paired_accessory
|
17
|
+
status 400
|
18
|
+
content_type "application/hap+json"
|
19
|
+
JSON.generate({"status" => -70401})
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def unpaired_accessory
|
23
|
+
halt 204
|
24
|
+
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "application_controller"
|
2
2
|
|
3
3
|
module RubyHome
|
4
4
|
module HTTP
|
5
5
|
class PairSetupsController < ApplicationController
|
6
|
-
post
|
7
|
-
content_type
|
6
|
+
post "/" do
|
7
|
+
content_type "application/pairing+tlv8"
|
8
8
|
|
9
9
|
case unpack_request[:state]
|
10
10
|
when 1
|
@@ -37,7 +37,7 @@ module RubyHome
|
|
37
37
|
verify_srp = VerifySRPService.new(
|
38
38
|
device_proof: unpack_request[:proof],
|
39
39
|
srp_session: session.srp_session,
|
40
|
-
public_key: unpack_request[:public_key]
|
40
|
+
public_key: unpack_request[:public_key]
|
41
41
|
).run
|
42
42
|
|
43
43
|
if verify_srp.success?
|
@@ -53,12 +53,12 @@ module RubyHome
|
|
53
53
|
def exchange
|
54
54
|
encrypted_data = unpack_request[:encrypted_data]
|
55
55
|
|
56
|
-
hkdf = HAP::Crypto::HKDF.new(info:
|
56
|
+
hkdf = HAP::Crypto::HKDF.new(info: "Pair-Setup-Encrypt-Info", salt: "Pair-Setup-Encrypt-Salt")
|
57
57
|
key = hkdf.encrypt(session.session_key)
|
58
58
|
|
59
59
|
chacha20poly1305ietf = HAP::Crypto::ChaCha20Poly1305.new(key)
|
60
60
|
|
61
|
-
nonce = HexHelper.pad(
|
61
|
+
nonce = HexHelper.pad("PS-Msg05")
|
62
62
|
decrypted_data = chacha20poly1305ietf.decrypt(nonce, encrypted_data)
|
63
63
|
unpacked_decrypted_data = TLV.decode(decrypted_data)
|
64
64
|
|
@@ -66,36 +66,36 @@ module RubyHome
|
|
66
66
|
iosdevicesignature = unpacked_decrypted_data[:signature]
|
67
67
|
iosdeviceltpk = unpacked_decrypted_data[:public_key]
|
68
68
|
|
69
|
-
hkdf = HAP::Crypto::HKDF.new(info:
|
69
|
+
hkdf = HAP::Crypto::HKDF.new(info: "Pair-Setup-Controller-Sign-Info", salt: "Pair-Setup-Controller-Sign-Salt")
|
70
70
|
iosdevicex = hkdf.encrypt(session.session_key)
|
71
71
|
|
72
72
|
iosdeviceinfo = [
|
73
|
-
iosdevicex.unpack1(
|
74
|
-
iosdevicepairingid.unpack1(
|
75
|
-
iosdeviceltpk.unpack1(
|
73
|
+
iosdevicex.unpack1("H*"),
|
74
|
+
iosdevicepairingid.unpack1("H*"),
|
75
|
+
iosdeviceltpk.unpack1("H*")
|
76
76
|
].join
|
77
77
|
verify_key = RbNaCl::Signatures::Ed25519::VerifyKey.new(iosdeviceltpk)
|
78
78
|
|
79
|
-
if verify_key.verify(iosdevicesignature, [iosdeviceinfo].pack(
|
80
|
-
hkdf = HAP::Crypto::HKDF.new(info:
|
79
|
+
if verify_key.verify(iosdevicesignature, [iosdeviceinfo].pack("H*"))
|
80
|
+
hkdf = HAP::Crypto::HKDF.new(info: "Pair-Setup-Accessory-Sign-Info", salt: "Pair-Setup-Accessory-Sign-Salt")
|
81
81
|
accessory_x = hkdf.encrypt(session.session_key)
|
82
82
|
|
83
83
|
signing_key = accessory_info.signing_key
|
84
84
|
accessoryltpk = signing_key.verify_key.to_bytes
|
85
85
|
accessoryinfo = [
|
86
|
-
accessory_x.unpack1(
|
87
|
-
accessory_info.device_id.unpack1(
|
88
|
-
accessoryltpk.unpack1(
|
86
|
+
accessory_x.unpack1("H*"),
|
87
|
+
accessory_info.device_id.unpack1("H*"),
|
88
|
+
accessoryltpk.unpack1("H*")
|
89
89
|
].join
|
90
90
|
|
91
|
-
accessorysignature = signing_key.sign([accessoryinfo].pack(
|
91
|
+
accessorysignature = signing_key.sign([accessoryinfo].pack("H*"))
|
92
92
|
|
93
93
|
subtlv = tlv(identifier: accessory_info.device_id, public_key: accessoryltpk, signature: accessorysignature)
|
94
94
|
|
95
|
-
nonce = HexHelper.pad(
|
95
|
+
nonce = HexHelper.pad("PS-Msg06")
|
96
96
|
encrypted_data = chacha20poly1305ietf.encrypt(nonce, subtlv)
|
97
97
|
|
98
|
-
pairing_params = {
|
98
|
+
pairing_params = {admin: true, identifier: iosdevicepairingid, public_key: iosdeviceltpk.unpack1("H*")}
|
99
99
|
accessory_info.add_paired_client(**pairing_params)
|
100
100
|
|
101
101
|
tlv state: 6, encrypted_data: encrypted_data
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "application_controller"
|
2
2
|
|
3
3
|
module RubyHome
|
4
4
|
module HTTP
|
5
5
|
class PairVerifiesController < ApplicationController
|
6
|
-
post
|
7
|
-
content_type
|
6
|
+
post "/" do
|
7
|
+
content_type "application/pairing+tlv8"
|
8
8
|
|
9
9
|
verify_accessory_paired
|
10
10
|
|
@@ -26,22 +26,22 @@ module RubyHome
|
|
26
26
|
session.shared_secret = shared_secret
|
27
27
|
|
28
28
|
accessoryinfo = [
|
29
|
-
public_key.unpack1(
|
30
|
-
accessory_info.device_id.unpack1(
|
31
|
-
client_public_key.to_bytes.unpack1(
|
29
|
+
public_key.unpack1("H*"),
|
30
|
+
accessory_info.device_id.unpack1("H*"),
|
31
|
+
client_public_key.to_bytes.unpack1("H*")
|
32
32
|
].join
|
33
33
|
|
34
34
|
signing_key = accessory_info.signing_key
|
35
|
-
accessorysignature = signing_key.sign([accessoryinfo].pack(
|
35
|
+
accessorysignature = signing_key.sign([accessoryinfo].pack("H*"))
|
36
36
|
|
37
37
|
subtlv = tlv(identifier: accessory_info.device_id, signature: accessorysignature)
|
38
38
|
|
39
|
-
hkdf = HAP::Crypto::HKDF.new(info:
|
39
|
+
hkdf = HAP::Crypto::HKDF.new(info: "Pair-Verify-Encrypt-Info", salt: "Pair-Verify-Encrypt-Salt")
|
40
40
|
session_key = hkdf.encrypt(shared_secret)
|
41
41
|
session.session_key = session_key
|
42
42
|
|
43
43
|
chacha20poly1305ietf = HAP::Crypto::ChaCha20Poly1305.new(session_key)
|
44
|
-
nonce = HexHelper.pad(
|
44
|
+
nonce = HexHelper.pad("PV-Msg02")
|
45
45
|
encrypted_data = chacha20poly1305ietf.encrypt(nonce, subtlv)
|
46
46
|
|
47
47
|
tlv state: 2, public_key: public_key, encrypted_data: encrypted_data
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "application_controller"
|
2
2
|
|
3
3
|
module RubyHome
|
4
4
|
module HTTP
|
5
5
|
class PairingsController < ApplicationController
|
6
|
-
post
|
7
|
-
content_type
|
6
|
+
post "/" do
|
7
|
+
content_type "application/pairing+tlv8"
|
8
8
|
|
9
9
|
case unpack_request[:method]
|
10
10
|
when 3
|
@@ -20,7 +20,7 @@ module RubyHome
|
|
20
20
|
pairing_params = {
|
21
21
|
admin: !!unpack_request[:permissions],
|
22
22
|
identifier: unpack_request[:identifier],
|
23
|
-
public_key: unpack_request[:public_key].unpack1(
|
23
|
+
public_key: unpack_request[:public_key].unpack1("H*")
|
24
24
|
}
|
25
25
|
accessory_info.add_paired_client(**pairing_params)
|
26
26
|
|
@@ -30,7 +30,7 @@ module RubyHome
|
|
30
30
|
def remove_pairing
|
31
31
|
accessory_info.remove_paired_client(unpack_request[:identifier])
|
32
32
|
|
33
|
-
response[
|
33
|
+
response["connection"] = "close"
|
34
34
|
tlv state: 2
|
35
35
|
end
|
36
36
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
1
|
+
require_relative "object_serializer"
|
2
|
+
require_relative "service_serializer"
|
3
3
|
|
4
4
|
module RubyHome
|
5
5
|
module HTTP
|
@@ -7,13 +7,13 @@ module RubyHome
|
|
7
7
|
include ObjectSerializer
|
8
8
|
|
9
9
|
def root
|
10
|
-
|
10
|
+
"accessories"
|
11
11
|
end
|
12
12
|
|
13
13
|
def record_hash(accessory)
|
14
14
|
{
|
15
|
-
|
16
|
-
|
15
|
+
"aid" => accessory.id,
|
16
|
+
"services" => ServiceSerializer.new(accessory.services).serializable_hash
|
17
17
|
}
|
18
18
|
end
|
19
19
|
end
|