Skip to content

Commit 69ccc54

Browse files
committed
feat: added Remote module that allows remote monitoring of the system (not publicly available since it's in the early stage)
1 parent 75912f5 commit 69ccc54

File tree

11 files changed

+732
-12
lines changed

11 files changed

+732
-12
lines changed

.swiftlint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ identifier_name:
4343
- LineChartHistory
4444
- SpeedPictogramColor
4545
- SensorsWidgetValue
46+
- access_token
47+
- refresh_token
4648

4749
line_length: 200
4850

@@ -52,4 +54,4 @@ type_body_length:
5254

5355
file_length:
5456
- 1400
55-
- 1800
57+
- 1800

Kit/module/reader.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ open class Reader<T: Codable>: NSObject, ReaderInternal_p {
103103
}
104104

105105
public func callback(_ value: T?) {
106+
let moduleKey = "\(self.module.stringValue)@\(self.name)"
106107
self.value = value
107108
if let value {
108109
self.callbackHandler(value)
110+
Remote.shared.send(key: moduleKey, value: value)
109111
if let ts = self.lastDBWrite, let interval = self.interval, Date().timeIntervalSince(ts) > interval * 10 {
110-
DB.shared.insert(key: "\(self.module.stringValue)@\(self.name)", value: value, ts: self.history)
112+
DB.shared.insert(key: moduleKey, value: value, ts: self.history)
111113
self.lastDBWrite = Date()
112114
} else if self.lastDBWrite == nil {
113-
DB.shared.insert(key: "\(self.module.stringValue)@\(self.name)", value: value, ts: self.history)
115+
DB.shared.insert(key: moduleKey, value: value, ts: self.history)
114116
self.lastDBWrite = Date()
115117
}
116118
}

Kit/plugins/DB.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class DB {
7676

7777
public func insert(key: String, value: Codable, ts: Bool = true, force: Bool = false) {
7878
self.values[key] = value
79-
guard let blobData = try? JSONEncoder().encode(value), let str = String(data: blobData, encoding: .utf8)else { return }
79+
guard let blobData = try? JSONEncoder().encode(value), let str = String(data: blobData, encoding: .utf8) else { return }
8080

8181
if ts {
8282
self.lldb?.insert("\(key)@\(Date().currentTimeSeconds())", value: str)

0 commit comments

Comments
 (0)