std::string registerInNetwork( std::string const & _key )
{
	CKeyID keyId;

	CNodeAddress nodeAddress(_key);

	if ( !nodeAddress.GetKeyID( keyId ) )
		return "monitor with specified number not present";

	common::CValidNodeInfo validNodeInfo;
	if ( !CTrackerNodesManager::getInstance()->getNodeInfo( keyId, validNodeInfo ) )
		return "monitor with specified number not present";

	common::CActionHandler::getInstance()->executeAction( new CRegisterAction( validNodeInfo.m_publicKey ) );
	return "registration in progress";
}
Ejemplo n.º 2
0
    uint16 WirelessNode_Impl::getNumDatalogSessions()
    {
        if(features().datalogDownloadVersion() == 1)
        {
            return m_eepromHelper->read_numDatalogSessions();
        }
        else
        {
            //datalog v2+ doesn't support the num datalog sessions eeprom

            //use the getDatalogSessionInfo command to obtain this information
            DatalogSessionInfoResult info;
            if(!m_baseStation.node_getDatalogSessionInfo(protocol(), m_address, info))
            {
                throw Error_NodeCommunication(nodeAddress(), "Failed to get the Datalogging Session Info");
            }

            return info.sessionCount;
        }
    }
Ejemplo n.º 3
0
	std::string WirelessNode::name() const
	{
		return deviceName(nodeAddress());
	}
Ejemplo n.º 4
0
    AutoBalanceResult WirelessNode_Impl::autoBalance(const ChannelMask& mask, float targetPercent)
    {
        Utils::checkBounds_min(targetPercent, 0.0f);
        Utils::checkBounds_max(targetPercent, 100.0f);

        //attempt a few pings first 
        //(legacy (v1) autobalance doesn't have a response packet, so need to check communication)
        uint8 retryCounter = 0;
        bool pingSuccess = false;
        while(!pingSuccess && retryCounter < 3)
        {
            pingSuccess = ping().success();
            retryCounter++;
        }

        if(!pingSuccess)
        {
            throw Error_NodeCommunication(nodeAddress());
        }

        //find the eeprom location that the autobalance will adjust
        //Note: this also verifies that it is supported for this mask
        const EepromLocation& eepromLoc = features().findEeprom(WirelessTypes::chSetting_autoBalance, mask);

        //currently, autobalance is always per channel, so get the channel from the mask
        uint8 channelNumber = mask.lastChEnabled();

        AutoBalanceResult result;

        //perform the autobalance command with the parent base station
        m_baseStation.node_autoBalance(protocol(), m_address, channelNumber, targetPercent, result);

        //clear the cache of the hardware offset eeprom location we adjusted
        eeprom().clearCacheLocation(eepromLoc.location());

        Utils::threadSleep(200);

        //if we used the legacy command, we don't get result info, need to do more work to get it
        if(result.m_errorCode == WirelessTypes::autobalance_legacyNone)
        {
            result.m_errorCode = WirelessTypes::autobalance_maybeInvalid;

            //force the read eeprom retries to a minimum of 3
            uint8 startRetries = m_eepromSettings.numRetries;

            //when this goes out of scope, it will change back the original retries value
            ScopeHelper writebackRetries(std::bind(&WirelessNode_Impl::setReadWriteRetries, this, startRetries));

            //if there are less than 10 retries
            if(startRetries < 10)
            {
                //we want to retry at least a few times
                setReadWriteRetries(10);
            }
            else
            {
                //don't need to write back the retries since we didn't make a change
                writebackRetries.cancel();
            }

            //read the updated hardware offset from the node
            result.m_hardwareOffset = readEeprom(eepromLoc).as_uint16();

            bool readSensorSuccess = false;

            uint8 readSensorTry = 0;
            do
            {
                //perform the read single sensor command
                uint16 sensorVal = 0;
                readSensorSuccess = m_baseStation.node_readSingleSensor(m_address, channelNumber, sensorVal);

                if(readSensorSuccess)
                {
                    //find the max bits value of the node
                    uint32 maxBitsVal = 0;
                    switch(model())
                    {
                        case WirelessModels::node_vLink:
                        case WirelessModels::node_sgLink_rgd:
                        case WirelessModels::node_shmLink:
                            maxBitsVal = 65536;
                            break;

                        default:
                            maxBitsVal = 4096;
                            break;
                    }

                    //calculate and store the percent achieved
                    result.m_percentAchieved = static_cast<float>(sensorVal) / static_cast<float>(maxBitsVal) * 100.0f;
                }

                readSensorTry++;
            }
            while(!readSensorSuccess && readSensorTry <= 3);

            if(readSensorSuccess)
            {
                //mark as questionable if not close enough to the target percentage
                if(std::abs(result.m_percentAchieved - targetPercent) > 5.0)
                {
                    result.m_errorCode = WirelessTypes::autobalance_maybeInvalid;
                }
                else
                {
                    result.m_errorCode = WirelessTypes::autobalance_success;
                }
            }
        }

        return result;
    }