CoreTempMonitorSwift

main

Free CoreTemp Monitor for iOS devices
CodeNationDev/CoreTempMonitorSwift

CoreTempMonitorSwift

A simple API for read AlCPU CoreTemp data to make your own Monitor App for iOS, macOS, watchOS or tvOS.

Installation

Use Swift Package Manager to add this package to your project.

Definition & Interface

public convenience init(ip: String, port: String , using: NWParameters)
  • ip (String): endpoint of machine where CoreTempServer is running.
  • port (String): the port number where CoreTempServer is publishing the data.
  • using (NWParameters): enumerated that defines the protocol to read data.

Entities

All data info has been strcutured in following objects

//
import Foundation
struct CpuInfo: Codable {
    var uiLoad: [Int]?
    var uiTjMax: [Int]?
    var uiCoreCnt: Int?
    var uiCPUCnt: Int?
    var fTemp: [Int]?
    var fVID: Float?
    var fCPUSpeed: Float?
    var fFSBSpeed: Float?
    var fMultiplier: Int?
    var CPUName: String?
    var ucFahrenheit: Int?
    var ucDeltaToTjMax: Int?
    var ucTdpSupported: Int?
    var ucPowerSupported: Int?
    var uiStructVersion: Int?
    var  uiTdp: [Int]?
    var fPower: [Float]?
    var fMultipliers: [Int]?
}

struct MemoryInfo: Codable {
    var TotalPhys: Int64?
    var FreePhys: Int64?
    var TotalPage: Int64?
    var FreePage: Int64?
    var TotalVirtual: Int64?
    var FreeVirtual: Int64?
    var FreeExtendedVirtual: Int?
    var MemoryLoad: Int?
}

public struct CoreTempObject: Codable {
    var CpuInfo: CpuInfo?
    var MemoryInfo: MemoryInfo?
}

The most relevant info for this objects is:

  • ucFahrenheit, ucDeltaToTjMax, ucTdpSupported and ucPowerSupported represent boolean values. 0 = false, 1 = true.
  • If ucFahrenheit is true, the temperature is reported in Fahrenheit.
  • If ucDeltaToTjMax is true, the temperature reported represents the distance from TjMax.
  • If ucTdpSupported is true, processor TDP information in the uiTdp array is valid.
  • If ucPowerSupported is true, processor power consumption information in the fPower array is valid.

Use each one for design your monitor.

Usage example

Initialize

Object instance runs the socket read. If you want to stop the reading call stop() function directly.

//
import UIKit
import CoreTempMonitorSwift

class ViewController: UIViewController {
    let sManager = SocketManager(ip: "192.168.1.69", port: "5200", using: .tcp)
    override func viewDidLoad() {
        super.viewDidLoad()
        sManager.delegate = self
    }
    @IBAction func stop_tapped(_ sender: Any) {
        sManager.stop()
    }
}

extension ViewController: CoreTempMonitorSwiftDelegate {
    func didReadData(data: CoreTempObject) {
        //do something
    }
}

Meta

David Martin Saiz – @deividmarshalldavms81@gmail.com

Distributed under the MIT license. See LICENSE for more information.

https://github.com/CodeNationDev/

Version History

  • 0.0.1
    • First implementation with main features.

Description

  • Swift Tools 5.0.0

Dependencies

  • None
Last updated: Tue Jan 12 2021 07:26:26 GMT-0500 (GMT-05:00)