QVariant UPlatform::data(int role) const { switch (role) { case idRole: return id(); case firmwareVersionRole: return firmwareVersion(); case nameRole: return name(); case portRole: return port(); case roomRole: return room(); case enabledRole: return enabled(); case ipRole: return ip(); default: return QVariant(); } }
bool UPlatform::setData(const QVariant& value, int role) { switch (role) { case idRole: id(value.value<QString>()); case firmwareVersionRole: firmwareVersion(value.value<QString>()); case nameRole: name(value.value<QString>()); case portRole: port(value.value<int>()); case roomRole: room(value.value<QString>()); case enabledRole: enabled(value.value<bool>()); case ipRole: ip(value.value<QString>()); default: return false; } return true; }
void LedDeviceAlienFx::requestFirmwareVersion() { emit firmwareVersion("unknown (alienfx)"); emit commandCompleted(true); }
std::unique_ptr<WirelessProtocol> WirelessNode_Impl::determineProtocol() const { Version fwVersion; NodeEepromSettings tempSettings = m_eepromSettings; tempSettings.numRetries = 0; bool success = false; uint8 retryCount = 0; do { //========================================================================= // Determine the firmware version by attempting to use multiple protocols try { //try reading with protocol v1.1 m_protocol = WirelessProtocol::v1_1(); //set the NodeEeprom with the temporary protocol m_eeprom.reset(new NodeEeprom(m_address, m_baseStation, *(m_protocol.get()), tempSettings)); fwVersion = firmwareVersion(); success = true; } catch(Error_Communication&) { //Failed reading with protocol v1.1 - Now try v1.0 //we know this uses the same group read (page download) as the previous protocol, so skip it tempSettings.useGroupRead = false; try { //try reading with protocol v1.0 m_protocol = WirelessProtocol::v1_0(); //set the NodeEeprom with the temporary protocol m_eeprom.reset(new NodeEeprom(m_address, m_baseStation, *(m_protocol.get()), tempSettings)); fwVersion = firmwareVersion(); success = true; } catch(Error_Communication&) { //if this was the last retry if(retryCount >= m_eepromSettings.numRetries) { //we failed to determine the protocol //need to clear out the protocol and eeprom variables m_protocol.reset(); m_eeprom.reset(); //rethrow the exception throw; } } } //========================================================================= } while(!success && (retryCount++ < m_eepromSettings.numRetries)); //get the protocol to use for the node's fw version return WirelessProtocol::chooseNodeProtocol(fwVersion); }