fix(smc): correct IOKit service name + SMCKeyData_t layout (Issue #32) #36
@@ -705,7 +705,9 @@ public final class SystemTelemetryStore {
|
||||
: 0
|
||||
)
|
||||
}
|
||||
context.batteryLevel = self.power.batteryLevel
|
||||
context.batteryLevel = self.batteryHealth.maxCapacity > 0
|
||||
? Double(self.batteryHealth.currentCapacity) / Double(self.batteryHealth.maxCapacity) * 100.0
|
||||
: self.power.batteryLevel
|
||||
context.hasBattery = self.batteryHealth.hasBattery
|
||||
context.onExternalPower = self.batteryHealth.externalConnected
|
||||
context.isCharging = self.batteryHealth.isCharging || self.power.isCharging
|
||||
|
||||
@@ -57,13 +57,13 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
CFMutableDictionaryRef matching = IOServiceMatching("AppleSMCClient");
|
||||
CFMutableDictionaryRef matching = IOServiceMatching("AppleSMC");
|
||||
if (!matching) {
|
||||
os_unfair_lock_unlock(&_lock);
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:@"com.i3omb.MacMonitor.SMC"
|
||||
code:-1
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"Failed to create AppleSMCClient matching dictionary"}];
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"Failed to create AppleSMC matching dictionary"}];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
@@ -74,7 +74,7 @@
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:@"com.i3omb.MacMonitor.SMC"
|
||||
code:-2
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"AppleSMCClient service not found (running on non-Mac or unsupported VM)"}];
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"AppleSMC service not found (running on non-Mac or unsupported VM)"}];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
#define kSMCGetKeyFromIndex 8
|
||||
#define kSMCGetKeyInfo 9
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct {
|
||||
unsigned char major;
|
||||
unsigned char minor;
|
||||
@@ -58,8 +56,6 @@ typedef struct {
|
||||
UInt8 bytes[32];
|
||||
} SMCVal_t;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
static inline UInt32 MMSMCToFourCharCode(const char * _Nonnull str) {
|
||||
UInt32 code = 0;
|
||||
for (int i = 0; i < 4 && str[i] != '\0'; i++) {
|
||||
|
||||
Reference in New Issue
Block a user