1 #ifndef REMOTE_MCH_DEVICEMANAGER_H
2 #define REMOTE_MCH_DEVICEMANAGER_H
17 namespace remote
{ namespace mch
{
19 typedef std::map
<std::string
, Mote
*> motemap_t
;
21 /** MCH Mote device manager.
23 * The device manager maintains a database of known motes and their
24 * status. The database consists of three mote maps: one containing
25 * newly discovered motes, one with motes that are no longer available,
26 * and a map containing all currently valid and operational motes.
27 * The database can be updated using #refresh().
32 motemap_t motes
; /**< The current valid motes. */
33 motemap_t newMotes
; /**< Motes that were just attached. */
34 motemap_t lostMotes
; /**< Motes that were just detached. */
36 /** Refresh the mote device database.
38 * Update the registered devices to match the existing system using a
39 * "mark and sweep" approach. First all motes are marked invalid
40 * after which the mote device hierarchy is iterated to revalidate all
41 * available mote. Finally, motes that are still invalid are moved to
44 * @param devicePath The path to the mote devices.
46 void refresh(std::string devicePath
);
49 /** Traverse and update all available motes.
51 * Traverses all mote device directories under the given
52 * device path and updates the mote.
54 * @param devicePath The path to the mote devices.
56 void readMoteDevices(std::string devicePath
);
58 /** Update mote information.
60 * If the mote already exists it is validated using
61 * #mch::Mote::validate else a new mote is created
62 * and placed in both #motes and #newMotes.
64 * @param mac The MAC address of the mote.
65 * @param directory The device directory of the mote.
67 void updateMote(std::string mac
, std::string directory
);