Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Is anyone around here, working with the IOKit library?
I'm following this : http://iphonedevwiki.net/index.php/AppleISL29003
And it keeps crashing and crashing.

With this code underneath, I'm able to read out the 'PrimaryUsage and the PrimaryUsagePage', and also the backlight level and more.
But this issnt exactly what I'm looking for. Backlight level I already read out by brightness, thats just basicly the same but only works if I lock the screen, block the sensors and open back up the app.
Code:
CFMutableDictionaryRef matching , properties = NULL;
    io_registry_entry_t entry = 0;
    matching = IOServiceMatching( "AppleEmbeddedI2CLightSensor" );
    //matching = IOServiceNameMatching( "AppleSmartBattery" );
    entry = IOServiceGetMatchingService( kIOMasterPortDefault , matching );
    IORegistryEntryCreateCFProperties( entry , &properties , NULL , 0 );
    NSLog( @"%@" , properties );
    
    
    [logs setText: [NSString stringWithFormat: @"%@", properties]];
    CFRelease( properties );
    IOObjectRelease( entry );

I would like to read out the lux level itself from the sensor. But I cant find any way to acomplish this.

BTW I'm doing the [logs setText:, because the app will crash once I'm calling the IOKit Library, so I cant log from xcode itself, thats just a bit of weird...

I hope someone can help me out
 
Last edited:

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Even with only this part it crashes out
>> IOHIDEventSystemRef system = IOHIDEventSystemCreate(NULL); <<
Code:
    IOHIDEventSystemRef system = IOHIDEventSystemCreate(NULL);
//    IOHIDEventSystemOpen(system, handle_event, NULL, NULL, NULL);
//    IOHIDEventSystemClose(system, NULL);
    CFRelease(system);



void handle_event (void* target, void* refcon, IOHIDServiceRef service, IOHIDEventRef event) {
    tempLogs = [NSString stringWithFormat: @"%@\nReceived event of type %2d from service %p.\n", tempLogs, IOHIDEventGetType(event), service];
}
 

ianray

macrumors 6502
Jun 22, 2010
452
0
@
Code:
    IOHIDEventSystemRef system = IOHIDEventSystemCreate(NULL);
//    IOHIDEventSystemOpen(system, handle_event, NULL, NULL, NULL);
//    IOHIDEventSystemClose(system, NULL);
    CFRelease(system);

Is system NULL?

What version of iOS?

Where did you get the headers?

What are you linking against? (Or what are you dlopen'ing?)
 

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Is system NULL?

What version of iOS?

Where did you get the headers?

What are you linking against? (Or what are you dlopen'ing?)

I'm working on iOS7, and I'm using the IOKit libraries.
These are correct ones as I can gather raw battery information and stuff with it.

I'm building an functional test app for iphones for the company.
For now I wrote an cheap work around by getting the background brightness, but the 'testers' must lock the device, cover the sensor, and unlock the device and get back in the app and uncover the sensor again and watch the brightness slider move back to original state.

I would like to have an 'live' result of the sensor itself. But after few weeks of playing around it just wont work.

I had loads examples, also one from this forum but they are not working. This one came as close as possible. I can't find the webpage anymore about this example.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.