Skip to content

Commit

Permalink
debuggin
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouke committed Dec 31, 2022
1 parent 3a04a88 commit e4b3c12
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/HAP/Base/CharacteristicValueType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
import Logging

fileprivate let logger = Logger(label: "hap.adaptive.data")

public protocol CharacteristicValueType: Equatable, JSONValueTypeConvertible {
init?(value: Any)
Expand Down Expand Up @@ -171,14 +174,16 @@ extension Double: CharacteristicValueType {

extension Data: CharacteristicValueType, JSONValueTypeConvertible {
public init?(value: Any) {
logger.error("writing from data field")
switch value {
case let value as String: self = Data(base64Encoded: value)!
default: fatalError("don't now how to decode \(value)")
}
}
static public let format = CharacteristicFormat.data
public var jsonValueType: JSONValueType {
self.base64EncodedString()
logger.error("reading from data field")
return self.base64EncodedString()
}
}

Expand Down

0 comments on commit e4b3c12

Please sign in to comment.