Files
mowesta/ios-app/app/Arduino/ArduinoConfig.swift
T
Marcus Handte 2c788e3329
LocationBasedServices/mowesta/pipeline/head This commit looks good
Add weather station configuration to ios app.
2022-11-03 16:47:26 +01:00

58 lines
1.4 KiB
Swift

//
// ArduinoConfig.swift
// App
//
// Created by Marcus Handte on 01.11.22.
//
import Foundation
struct ArduinoConfig: Codable {
var ssid: String
var password: String
var token: String
var id: String
var latitude: String
var longitude: String
init(ssid: String, password: String, token: String, id: Int64, latitude: Double, longitude: Double) {
self.ssid = ssid
self.password = password
self.token = token
self.id = "\(id)"
self.latitude = "\(latitude)"
self.longitude = "\(longitude)"
}
enum CodingKeys: String, CodingKey {
case ssid = "ssid"
case password = "password"
case token = "token"
case id = "id"
case latitude = "latitude"
case longitude = "longitude"
}
func toJson() -> Data? {
let encoder = JSONEncoder()
let encoded = try? encoder.encode(self)
if let en = encoded, let string = String(data: en, encoding: .utf8) {
return "\(string)\n".data(using: .utf8)
}
return nil
}
}
enum ArduinoConstants: String {
/// The network name of the weather station.
case ssid = "MoWeSta - WiFi"
/// The network password of the weather station.
case password = "mowesta123456wifi"
/// The ip address of the weather station.
case ip = "192.168.4.1"
/// The port of the weather station.
case port = "8080"
}