mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Basic introspection for device supported networks
This commit is contained in:
@@ -203,6 +203,9 @@ bool Device::goOffline() {
|
||||
}
|
||||
|
||||
bool Device::transmit(std::shared_ptr<Message> message) {
|
||||
if(!isSupportedTXNetwork(message->network))
|
||||
return false;
|
||||
|
||||
std::vector<uint8_t> packet;
|
||||
if(!com->encoder->encode(packet, message))
|
||||
return false;
|
||||
@@ -218,6 +221,27 @@ bool Device::transmit(std::vector<std::shared_ptr<Message>> messages) {
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t Device::getNetworkCountByType(Network::Type type) const {
|
||||
size_t count = 0;
|
||||
for(const auto& net : getSupportedRXNetworks())
|
||||
if(net.getType() == type)
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
// Indexed starting at one
|
||||
Network Device::getNetworkByNumber(Network::Type type, size_t index) const {
|
||||
size_t count = 0;
|
||||
for(const auto& net : getSupportedRXNetworks()) {
|
||||
if(net.getType() == type) {
|
||||
count++;
|
||||
if(count == index)
|
||||
return net;
|
||||
}
|
||||
}
|
||||
return Network::NetID::Invalid;
|
||||
}
|
||||
|
||||
void Device::handleInternalMessage(std::shared_ptr<Message> message) {
|
||||
switch(message->network.getNetID()) {
|
||||
case Network::NetID::Reset_Status:
|
||||
|
||||
Reference in New Issue
Block a user