-1

I tried this code:

battery_info_t **pointer=NULL;
battery_get_info(pointer);
return battery_info_get_time_to_empty(*pointer); // needs simple pointer (*pointer)

My question is: how can i convert **pointer to *pointer

Charles
  • 50,943
  • 13
  • 104
  • 142
rosu alin
  • 5,674
  • 11
  • 69
  • 150

2 Answers2

1

In this usage the battery_info_... function calls take a pointer to a battery_info_t type, so you would declare pointer as that and use it as the argument to those calls. To set pointer to the correct value you pass a pointer to it to battery_get_info(). You must also free the memory allocated to pointer when you are done:

battery_info_t    *pointer = NULL;
battery_get_info(&pointer);
int t = battery_info_get_time_to_empty(pointer);
battery_free_info(&pointer);
return t;
Richard
  • 8,920
  • 2
  • 18
  • 24
  • works, but returns the same thing 65535, thanks for the code, i guess it returns that because its on an emulator. – rosu alin Nov 15 '12 at 14:13
  • Have you used the simulator controller to adjust the charge level of the battery? However, even with that there are some things that it just doesn't make sense to simulate. – Richard Nov 16 '12 at 03:05
  • yes, i tried moving the charge level from that controller, but still the same value – rosu alin Nov 16 '12 at 13:47
  • There are two possibilities: 1) as I mention above, they may not have found any way to simulate 'time to empty' that makes sense; 2) the API has been stubbed out to does not actually have the code in place yet. If I have time I'll try this on my Dev Alpha and let you know what I get. – Richard Nov 16 '12 at 18:13
0

This works:

battery_info_t *pointer=NULL;     
battery_get_info(&pointer);    
return battery_info_get_time_to_empty(pointer);  

But returns 65535, on an emulator, so i can't tell if it works or not, because i don have an BB10...

relaxxx
  • 7,566
  • 8
  • 37
  • 64
rosu alin
  • 5,674
  • 11
  • 69
  • 150