Example #1
0
void TICC1100::setup(int32_t userID, int32_t groupID)
{
	try
	{
		_out.printDebug("Debug: CC1100: Setting device permissions");
		setDevicePermission(userID, groupID);
		_out.printDebug("Debug: CC1100: Exporting GPIO");
		exportGPIO(1);
		_out.printDebug("Debug: CC1100: Setting GPIO permissions");
		setGPIOPermission(1, userID, groupID, true);
		_out.printDebug("Debug: CC1100: Setting GPIO direction");
		setGPIODirection(1, GPIODirection::IN);
		_out.printDebug("Debug: CC1100: Settings GPIO edge");
		setGPIOEdge(1, GPIOEdge::BOTH);
	}
    catch(const std::exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
Example #2
0
void TICC1100::initDevice()
{
	try
	{
		openDevice();
		if(!_fileDescriptor || _fileDescriptor->descriptor == -1) return;

		initChip();
		_out.printDebug("Debug: CC1100: Setting GPIO direction");
		setGPIODirection(1, GPIODirection::IN);
		_out.printDebug("Debug: CC1100: Setting GPIO edge");
		setGPIOEdge(1, GPIOEdge::BOTH);
		openGPIO(1, true);
		if(!_gpioDescriptors[1] || _gpioDescriptors[1]->descriptor == -1) throw(BaseLib::Exception("Couldn't listen to rf device, because the gpio pointer is not valid: " + _settings->device));
		if(gpioDefined(2)) //Enable high gain mode
		{
			openGPIO(2, false);
			if(!getGPIO(2)) setGPIO(2, true);
			closeGPIO(2);
		}
	}
    catch(const std::exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}