How can the Pi detect if a host device has been connected, and gather information about that device, when being used as a gadget (such as mass storage). It would be useful if I could detect this within a python script.
As an example, if the Pi is to be used as a mass storage device, and I have a python script that's supposed to set that up, it would be useful if I could trigger certain behaviour when a device is actually connected, but not before. Further, it would be useful if the behaviour could depend on certain information about that device. For instance, if the data needed to be refreshed when a host was connected, or if a certain type of host needed a different set of data than another type of host.