@@ -44,9 +44,13 @@ public class Device implements Comparable<Device>, Serializable {
44
44
private String deviceId ;
45
45
private transient OcDeviceInfo deviceInfo ;
46
46
private String ipv6SecureHost ;
47
+ private String ipv6TcpSecureHost ;
47
48
private String ipv6Host ;
49
+ private String ipv6TcpHost ;
48
50
private String ipv4SecureHost ;
51
+ private String ipv4TcpSecureHost ;
49
52
private String ipv4Host ;
53
+ private String ipv4TcpHost ;
50
54
private int permits ;
51
55
52
56
public Device () {}
@@ -61,14 +65,26 @@ public Device(DeviceType type, String deviceId, OcDeviceInfo deviceInfo, OCEndpo
61
65
while (endpoints != null ) {
62
66
String endpointStr = OCEndpointUtil .toString (endpoints );
63
67
64
- if (endpointStr .startsWith ("coaps://" ) && endpointStr .contains ("." )) {
65
- ipv4SecureHost = endpointStr ;
66
- } else if (endpointStr .startsWith ("coaps://" )) {
67
- ipv6SecureHost = endpointStr ;
68
- } else if (endpointStr .startsWith ("coap://" ) && endpointStr .contains ("." )) {
69
- ipv4Host = endpointStr ;
70
- } else if (endpointStr .startsWith ("coap://" )){
71
- ipv6Host = endpointStr ;
68
+ if (endpointStr .contains ("." )) {
69
+ if (endpointStr .startsWith ("coaps://" )) {
70
+ ipv4SecureHost = endpointStr ;
71
+ } else if (endpointStr .startsWith ("coaps+tcp://" )) {
72
+ ipv4TcpSecureHost = endpointStr ;
73
+ } else if (endpointStr .startsWith ("coap://" )) {
74
+ ipv4Host = endpointStr ;
75
+ } else if (endpointStr .startsWith ("coap+tcp://" )) {
76
+ ipv4TcpHost = endpointStr ;
77
+ }
78
+ } else {
79
+ if (endpointStr .startsWith ("coaps://" )) {
80
+ ipv6SecureHost = endpointStr ;
81
+ } else if (endpointStr .startsWith ("coaps+tcp://" )) {
82
+ ipv6TcpSecureHost = endpointStr ;
83
+ } else if (endpointStr .startsWith ("coap://" )) {
84
+ ipv6Host = endpointStr ;
85
+ } else if (endpointStr .startsWith ("coap+tcp://" )) {
86
+ ipv6TcpHost = endpointStr ;
87
+ }
72
88
}
73
89
74
90
endpoints = endpoints .getNext ();
@@ -83,14 +99,26 @@ public Device(DeviceType type, String deviceId, OcDeviceInfo deviceInfo, List<St
83
99
this .permits = permits ;
84
100
85
101
for (String endpoint : endpoints ) {
86
- if (endpoint .startsWith ("coaps://" ) && endpoint .contains ("." )) {
87
- ipv4SecureHost = endpoint ;
88
- } else if (endpoint .startsWith ("coaps://" )) {
89
- ipv6SecureHost = endpoint ;
90
- } else if (endpoint .startsWith ("coap://" ) && endpoint .contains ("." )) {
91
- ipv4Host = endpoint ;
92
- } else if (endpoint .startsWith ("coap://" )) {
93
- ipv6Host = endpoint ;
102
+ if (endpoint .contains ("." )) {
103
+ if (endpoint .startsWith ("coaps://" )) {
104
+ ipv4SecureHost = endpoint ;
105
+ } else if (endpoint .startsWith ("coaps+tcp://" )) {
106
+ ipv4TcpSecureHost = endpoint ;
107
+ } else if (endpoint .startsWith ("coap://" )) {
108
+ ipv4Host = endpoint ;
109
+ } else if (endpoint .startsWith ("coap+tcp://" )) {
110
+ ipv4TcpHost = endpoint ;
111
+ }
112
+ } else {
113
+ if (endpoint .startsWith ("coaps://" )) {
114
+ ipv6SecureHost = endpoint ;
115
+ } else if (endpoint .startsWith ("coaps+tcp://" )) {
116
+ ipv6TcpSecureHost = endpoint ;
117
+ } else if (endpoint .startsWith ("coap://" )) {
118
+ ipv6Host = endpoint ;
119
+ } else if (endpoint .startsWith ("coap+tcp://" )) {
120
+ ipv6TcpHost = endpoint ;
121
+ }
94
122
}
95
123
}
96
124
}
@@ -135,6 +163,14 @@ public void setIpv6Host(String host) {
135
163
this .ipv6Host = host ;
136
164
}
137
165
166
+ public String getIpv6TcpHost () {
167
+ return this .ipv6TcpHost ;
168
+ }
169
+
170
+ public void setIpv6TcpHost (String host ) {
171
+ this .ipv6TcpHost = host ;
172
+ }
173
+
138
174
public String getIpv6SecureHost () {
139
175
return this .ipv6SecureHost ;
140
176
}
@@ -143,6 +179,14 @@ public void setIpv6SecureHost(String host) {
143
179
this .ipv6SecureHost = host ;
144
180
}
145
181
182
+ public String getIpv6TcpSecureHost () {
183
+ return this .ipv6TcpSecureHost ;
184
+ }
185
+
186
+ public void setIpv6TcpSecureHost (String host ) {
187
+ this .ipv6TcpSecureHost = host ;
188
+ }
189
+
146
190
public String getIpv4Host () {
147
191
return this .ipv4Host ;
148
192
}
@@ -151,6 +195,14 @@ public void setIpv4Host(String host) {
151
195
this .ipv4Host = host ;
152
196
}
153
197
198
+ public String getIpv4TcpHost () {
199
+ return this .ipv4TcpHost ;
200
+ }
201
+
202
+ public void setIpv4TcpHost (String host ) {
203
+ this .ipv4TcpHost = host ;
204
+ }
205
+
154
206
public String getIpv4SecureHost () {
155
207
return this .ipv4SecureHost ;
156
208
}
@@ -159,27 +211,55 @@ public void setIpv4SecureHost(String host) {
159
211
this .ipv4SecureHost = host ;
160
212
}
161
213
214
+ public String getIpv4TcpSecureHost () {
215
+ return this .ipv4SecureHost ;
216
+ }
217
+
218
+ public void setIpv4TcpSecureHost (String host ) {
219
+ this .ipv4SecureHost = host ;
220
+ }
221
+
162
222
public boolean equalsHosts (Device device ) {
163
223
if (this .getIpv6Host () != null && device .getIpv6Host () != null
164
224
&& !this .getIpv6Host ().equals (device .getIpv6Host ())) {
165
225
return false ;
166
226
}
167
227
228
+ if (this .getIpv6TcpHost () != null && device .getIpv6TcpHost () != null
229
+ && !this .getIpv6TcpHost ().equals (device .getIpv6TcpHost ())) {
230
+ return false ;
231
+ }
232
+
168
233
if (this .getIpv6SecureHost () != null && device .getIpv6SecureHost () != null
169
234
&& !this .getIpv6SecureHost ().equals (device .getIpv6SecureHost ())) {
170
235
return false ;
171
236
}
172
237
238
+ if (this .getIpv6TcpSecureHost () != null && device .getIpv6TcpSecureHost () != null
239
+ && !this .getIpv6TcpSecureHost ().equals (device .getIpv6TcpSecureHost ())) {
240
+ return false ;
241
+ }
242
+
173
243
if (this .getIpv4Host () != null && device .getIpv4Host () != null
174
244
&& !this .getIpv4Host ().equals (device .getIpv4Host ())) {
175
245
return false ;
176
246
}
177
247
248
+ if (this .getIpv4TcpHost () != null && device .getIpv4TcpHost () != null
249
+ && !this .getIpv4TcpHost ().equals (device .getIpv4TcpHost ())) {
250
+ return false ;
251
+ }
252
+
178
253
if (this .getIpv4SecureHost () != null && device .getIpv4SecureHost () != null
179
254
&& !this .getIpv4SecureHost ().equals (device .getIpv4SecureHost ())) {
180
255
return false ;
181
256
}
182
257
258
+ if (this .getIpv4TcpSecureHost () != null && device .getIpv4TcpSecureHost () != null
259
+ && !this .getIpv4TcpSecureHost ().equals (device .getIpv4TcpSecureHost ())) {
260
+ return false ;
261
+ }
262
+
183
263
return true ;
184
264
}
185
265
0 commit comments