fix(smc): correct IOKit service name + SMCKeyData_t layout (Issue #32) #36

Merged
gronod merged 1 commits from fix/32-smc-service-name into milestone/m6-bugfix-stability 2026-09-08 15:15:10 +01:00
3 changed files with 6 additions and 8 deletions
+3 -1
View File
@@ -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
+3 -3
View File
@@ -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;
}
-4
View File
@@ -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++) {