V0.6.9.a Arroyo Toad
Fixed package visibility
This commit is contained in:
parent
711ad7b5c8
commit
8ae58929b0
@ -64,6 +64,7 @@ public func serializeV1(msg: MessageP) -> Data {
|
||||
|
||||
return serializedData
|
||||
}
|
||||
|
||||
public func signMessage(msgData: Data, signType: SignType, key: P256.Signing.PrivateKey) throws
|
||||
-> [UInt8]
|
||||
{
|
||||
|
||||
@ -5,4 +5,12 @@ public struct Field {
|
||||
public let key: [UInt8]
|
||||
public let value: [UInt8]
|
||||
|
||||
public init(
|
||||
key: [UInt8],
|
||||
value: [UInt8]
|
||||
) {
|
||||
self.key = key
|
||||
self.value = value
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,4 +4,13 @@ public struct Location {
|
||||
public let y: UInt64
|
||||
public let z: UInt64
|
||||
|
||||
public init(
|
||||
x: UInt64,
|
||||
y: UInt64,
|
||||
z: UInt64
|
||||
) {
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,30 @@ public struct Message : MessageP{
|
||||
public let location: Location
|
||||
public let fields: [Field]
|
||||
|
||||
public init(
|
||||
|
||||
version: UInt8,
|
||||
messageType: MessageType,
|
||||
devType: DeviceType,
|
||||
RESERVED: UInt8,
|
||||
signType: SignType,
|
||||
timestamp: Date,
|
||||
devID: UInt128,
|
||||
location: Location,
|
||||
fields: [Field]
|
||||
) {
|
||||
|
||||
self.version = version
|
||||
self.messageType = messageType
|
||||
self.devType = devType
|
||||
self.RESERVED = RESERVED
|
||||
self.signType = signType
|
||||
self.timestamp = timestamp
|
||||
self.devID = devID
|
||||
self.location = location
|
||||
self.fields = fields
|
||||
|
||||
}
|
||||
|
||||
public func toString() -> String {
|
||||
var description = ""
|
||||
@ -24,16 +48,17 @@ public struct Message : MessageP{
|
||||
description += "Signature Type: \t\(self.signType.rawValue)\n"
|
||||
description += "Timestamp: \t\(self.timestamp)\n"
|
||||
description += "Device ID: \t\(self.devID)\n"
|
||||
description += "Location: \tX: \(self.location.x)\tY: \(self.location.y)\tZ: \(self.location.z)\n"
|
||||
description +=
|
||||
"Location: \tX: \(self.location.x)\tY: \(self.location.y)\tZ: \(self.location.z)\n"
|
||||
description += "Fields: \n"
|
||||
for field in self.fields {
|
||||
description += "\t\(String(data: Data(field.key), encoding: .ascii) ?? "UNABLE TO DECODE"): \(String(data: Data(field.value), encoding: .ascii) ?? "UNABLE TO DECODE")\n"
|
||||
description +=
|
||||
"\t\(String(data: Data(field.key), encoding: .ascii) ?? "UNABLE TO DECODE"): \(String(data: Data(field.value), encoding: .ascii) ?? "UNABLE TO DECODE")\n"
|
||||
}
|
||||
|
||||
return description
|
||||
}
|
||||
}
|
||||
|
||||
public struct SignedMessage: MessageP {
|
||||
|
||||
public let version: UInt8
|
||||
@ -48,7 +73,6 @@ public struct SignedMessage : MessageP {
|
||||
public let fields: [Field]
|
||||
public let signature: [UInt8]
|
||||
|
||||
|
||||
public func toString() -> String {
|
||||
var description = ""
|
||||
description += "MESSAGE -------\n"
|
||||
@ -59,10 +83,12 @@ public struct SignedMessage : MessageP {
|
||||
description += "Signature Type: \t\(self.signType.rawValue)\n"
|
||||
description += "Timestamp: \t\(self.timestamp)\n"
|
||||
description += "Device ID: \t\(self.devID)\n"
|
||||
description += "Location: \tX: \(self.location.x)\tY: \(self.location.y)\tZ: \(self.location.z)\n"
|
||||
description +=
|
||||
"Location: \tX: \(self.location.x)\tY: \(self.location.y)\tZ: \(self.location.z)\n"
|
||||
description += "Fields: \n"
|
||||
for field in self.fields {
|
||||
description += "\t\(String(data: Data(field.key), encoding: .ascii) ?? "UNABLE TO DECODE"): \(String(data: Data(field.value), encoding: .ascii) ?? "UNABLE TO DECODE")\n"
|
||||
description +=
|
||||
"\t\(String(data: Data(field.key), encoding: .ascii) ?? "UNABLE TO DECODE"): \(String(data: Data(field.value), encoding: .ascii) ?? "UNABLE TO DECODE")\n"
|
||||
}
|
||||
description += "Signature: \t\(self.signature)\n"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user