LivoxProto1: Document UDP demuxer purpose & use cases
Also fix bug in transient resource transfer from continuation to Device object.
This commit is contained in:
@@ -90,18 +90,6 @@ public:
|
||||
uint8_t smoSubnetNbits;
|
||||
uint16_t dataPort, cmdPort, imuPort;
|
||||
|
||||
// Static collection for devices being constructed (not yet in DeviceManager)
|
||||
// Maps device IP to list of command-specific UDP handlers for that device
|
||||
struct CommandHandler {
|
||||
uint8_t cmd_set;
|
||||
uint8_t cmd_id;
|
||||
std::function<void(
|
||||
const uint8_t* data, ssize_t bytesReceived,
|
||||
const struct sockaddr_in& senderAddr)> handler;
|
||||
};
|
||||
static std::unordered_map<std::string, std::vector<CommandHandler>>
|
||||
devicesUnderConstruction;
|
||||
|
||||
private:
|
||||
// Heartbeat mechanism
|
||||
void startHeartbeat();
|
||||
@@ -182,12 +170,47 @@ private:
|
||||
// Point cloud data setup
|
||||
void cleanupPcloudDataSocket();
|
||||
|
||||
/** EXPLANATION:
|
||||
* This is the "straightforward" map of command set and command id to
|
||||
* handlers. This is useful for any commands which are guaranteed to be
|
||||
* issued to the device *AFTER* the device has successfully been added
|
||||
* to the DeviceManager's list of devices.
|
||||
*
|
||||
* I.e: it cannot be used for commands which are issued to the device before
|
||||
* getOrCreateDevice() has added the device to the DeviceManager's list of
|
||||
* devices.
|
||||
*/
|
||||
// Command handler map
|
||||
std::unordered_map<
|
||||
std::pair<uint8_t, uint8_t>,
|
||||
std::function<void(
|
||||
const uint8_t* data, ssize_t bytesReceived,
|
||||
const struct sockaddr_in& senderAddr)>> udpCommandHandlers;
|
||||
|
||||
public:
|
||||
/** EXPLANATION:
|
||||
* This is the "temporary" map of command set and command id to
|
||||
* handlers. This is useful for any commands which are issued to the device
|
||||
* while it is being constructed.
|
||||
*
|
||||
* I.e: it shouldn't be used for cmds which are issued to the device after
|
||||
* getOrCreateDevice() has added the device to the DeviceManager's list of
|
||||
* devices. It will work for such commands, but we'd kind of prefer to use
|
||||
* the "straightforward" map above for such commands.
|
||||
*
|
||||
* NOTE:
|
||||
* There's a strong argument to be made for just getting rid of the
|
||||
* "straightforward" map above and just using this one, tho.
|
||||
*/
|
||||
struct CommandHandler {
|
||||
uint8_t cmd_set;
|
||||
uint8_t cmd_id;
|
||||
std::function<void(
|
||||
const uint8_t* data, ssize_t bytesReceived,
|
||||
const struct sockaddr_in& senderAddr)> handler;
|
||||
};
|
||||
static std::unordered_map<std::string, std::vector<CommandHandler>>
|
||||
devicesUnderConstruction;
|
||||
};
|
||||
|
||||
} // namespace livoxProto1
|
||||
|
||||
Reference in New Issue
Block a user