Restructured Device Discovery example so that it can be used by the
program at a later time.