first commit

This commit is contained in:
David Wernhart
2020-02-16 03:28:55 +01:00
commit 906cec6cc5
80 changed files with 3984 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
//
// HelperTool.swift
// com.davidwernhart.Helper
//
// Created by David Wernhart on 13.02.20.
// Copyright © 2020 David Wernhart. All rights reserved.
//
import Foundation
class HelperTool: NSObject, HelperToolProtocol {
func getVersion(withReply reply: (String) -> Void) {
// let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString" as String) as? String ?? "(unknown version)"
// let build = Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as? String ?? "(unknown build)"
// reply("v\(version) (\(build))")
reply(helperVersion)
}
func setSMCByte(key: String, value: UInt8){
do {
try SMCKit.open()
} catch {
print(error)
exit(EX_UNAVAILABLE)
}
var key = SMCKit.getKey(key, type: DataTypes.UInt8)
let bytes: SMCBytes = (value, UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0),
UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0),
UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0),
UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0),
UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0),
UInt8(0), UInt8(0))
do {
let status = try SMCKit.writeData(key,data: bytes)
} catch {
}
}
func readSMCByte(key: String, withReply reply: @escaping (UInt8) -> Void){
do {
try SMCKit.open()
} catch {
print(error)
exit(EX_UNAVAILABLE)
}
var key = SMCKit.getKey(key, type: DataTypes.UInt8)
do {
let status = try SMCKit.readData(key).0
reply(status)
} catch {
reply(0)
}
}
}