nivalxer / MobileDevice

iTunesMobileDevice C# API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BatteryCurrentCapacity issue

sehmee opened this issue · comments

I tried to read the battery status by adding the following code into iOSDevice.cs:

private string BatteryCurrent = string.Empty;

and:

public string BatteryCurrentCapacity { get { if (this.BatteryCurrent.Length == 0) { object deviceValue = this.GetDeviceValue(DeviceInfoKey.BatteryCurrentCapacity); if (deviceValue != null) { this.BatteryCurrent = deviceValue.ToString(); } } return this.BatteryCurrent; } }

Then I tried to read it to my lable with:

lblBatteryStatus.Text = currentiOSDevice.BatteryCurrentCapacity;

But there is no info, nothing. Same as for AppleID, doesn't show anything. Any help?

@semmikabel
I add new funcation GetBatteryCurrentCapacity().
You can use this funcation to get BatteryCurrentCapacity.
Thanks for your feedback.

Cool will give that a try, thankyou for your quick response. Good work :)

It is working, thankyou. What about the CycleCount? Tried to load that in the same way you've done with com.apple.mobile.battery, but always get nothing or -1.

I haven't found any API to get CycleCount at the moment.
I'll keep looking.

There are a few other API's on Github than can get the CycleCount, but they export it to an PLIST and then read out each line. I believe it was MK.MobileDevice or something like that.

Strange it doesn't read anything by just the domain of the battery and the CycleCount key.

Thanks.
MK.MobileDevice use iMobileDevice(C++) to get information.They use diagnostic service.
I'll add diagnostic service and try to get information.

@semmikabel
I add new funcation GetBatteryInfoFormDiagnostics().
You can use this funcation to get FullChargeCapacity,DesignCapacity,CycleCount and Status.

You are amazing! Will give it a try later today, thankyou :).

I tried to find out how to use the GetBatteryInfoFormDiagnostics() function with Dictionary, but I don't get it work yet. Do you have an example on how to call for sample the Cyclecount?

Nevermind, got it working :)

Dictionary<object, object> battInfo = currentiOSDevice.GetBatteryInfoFormDiagnostics(); var cyclecount = battInfo["CycleCount"];

:)

Hello,

I tried to get Battery Cycle Count from Upper Diagnostic code which you provided. But it gives me Error.

System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

this Error Occured in ManagedTypeFromCFType Method in CoreFoundation File. Can you please tell me why it is occuring in my code??

Thanks in Advance