Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getting notification for device matching



Hi.  I've setup notifications for device matching:

kr = IOServiceAddMatchingNotification(gNotifyPort, // notifyPort
kIOMatchedNotification, // notificationType
matchingDict, // matching
DeviceAdded, // callback
NULL, // refCon
&gAddedIter); // notification


//Iterate over set of matching devices to access already-present devices
//and to arm the notification
DeviceAdded(NULL,gAddedIter);


    //Notification of termination:
    kr = IOServiceAddMatchingNotification(gNotifyPort,
                                        kIOTerminatedNotification,
                                        matchingDict,
                                        DeviceRemoved,
                                        NULL,
                                        &gRemovedIter);
    //Iterate over set of matching devices to release each one and to
    //arm the notification
    DeviceRemoved(NULL, gRemovedIter);

When my device is connected, DeviceAdded() is called. When it is disconnected, DeviceRemoved() is called. If I re-attach the device, DeviceAdded() is not called, but when I re-connect, DeviceAdded() is not called.... although when I disconnect is, DeviceRemoved() is called again.

Here is the code in DeviceRemoved():

void DeviceRemoved(void *refCon, io_iterator_t iterator)
{
    printf("DeviceRemoved called\n");
    kern_return_t   kr;
    io_service_t    object;
    while (object = IOIteratorNext(iterator))
    {
        kr = IOObjectRelease(object);
        if (kr != kIOReturnSuccess)
        {
            printf("Couldn’t release device object: %08x\n", kr);
            continue;
        }
    }
}

Anything obvious?

Thanks,
Eric Smith _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.