@rentlydev/rently-tuya 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/tuya/Tuya.swift +17 -5
- package/package.json +1 -1
package/ios/tuya/Tuya.swift
CHANGED
|
@@ -199,7 +199,9 @@ class Tuya: NSObject, ObservableObject {
|
|
|
199
199
|
return
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
|
|
202
|
+
let deviceModel = device.deviceModel
|
|
203
|
+
guard let skills = deviceModel.skills,
|
|
204
|
+
let p2pType = skills["p2pType"] else {
|
|
203
205
|
print("Tuya: Device model missing required data, attempting to re-sync device (Retry: \(resyncRetryCount)/\(maxResyncRetries))")
|
|
204
206
|
|
|
205
207
|
guard resyncRetryCount < maxResyncRetries,
|
|
@@ -240,6 +242,8 @@ class Tuya: NSObject, ObservableObject {
|
|
|
240
242
|
|
|
241
243
|
previewLoader = true
|
|
242
244
|
|
|
245
|
+
let deviceId = device.devId
|
|
246
|
+
|
|
243
247
|
device.awake {
|
|
244
248
|
print("Tuya: Device wake success")
|
|
245
249
|
} failure: { error in
|
|
@@ -247,7 +251,7 @@ class Tuya: NSObject, ObservableObject {
|
|
|
247
251
|
}
|
|
248
252
|
|
|
249
253
|
let request = ThingSmartRequest()
|
|
250
|
-
request.request(withApiName: "tuya.m.ipc.config.get", postData: ["devId":
|
|
254
|
+
request.request(withApiName: "tuya.m.ipc.config.get", postData: ["devId": deviceId], version: "2.0") { result in
|
|
251
255
|
guard let configData = result else {
|
|
252
256
|
print("Tuya: Config data missing")
|
|
253
257
|
self.updateStatus(isConnected: false, previewLoader: false)
|
|
@@ -264,14 +268,22 @@ class Tuya: NSObject, ObservableObject {
|
|
|
264
268
|
}
|
|
265
269
|
}
|
|
266
270
|
|
|
267
|
-
// Configure the camera
|
|
268
271
|
private func configureCamera(p2pType: Any, configData: Any) {
|
|
272
|
+
guard let device = self.device else {
|
|
273
|
+
print("Tuya: Camera config creation failed - device is nil")
|
|
274
|
+
self.updateStatus(isConnected: false, previewLoader: false)
|
|
275
|
+
return
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
let deviceModel = device.deviceModel
|
|
279
|
+
let localKey = deviceModel.localKey
|
|
280
|
+
|
|
269
281
|
guard let config = ThingSmartCameraFactory.ipcConfig(
|
|
270
282
|
withUid: ThingSmartUser.sharedInstance().uid,
|
|
271
|
-
localKey:
|
|
283
|
+
localKey: localKey,
|
|
272
284
|
configData: configData as? [AnyHashable: Any]
|
|
273
285
|
) else {
|
|
274
|
-
print("Tuya: Camera config creation failed")
|
|
286
|
+
print("Tuya: Camera config creation failed - config is nil")
|
|
275
287
|
self.updateStatus(isConnected: false, previewLoader: false)
|
|
276
288
|
return
|
|
277
289
|
}
|