Пример #1
0
bool TestModule::TerminalCommandHandler(string commandName, vector<string> commandArgs)
{
	//Must be called to allow the module to get and set the config
	Module::TerminalCommandHandler(commandName, commandArgs);

	if (commandName == "TESTSAVE")
	{
		char buffer[70];
		Logger::getInstance().convertBufferToHexString((u8*) &configuration, sizeof(TestModuleConfiguration), buffer);

		configuration.rebootTimeMs = 12 * 1000;

		logt("TEST", "Saving config %s (%d)", buffer, sizeof(TestModuleConfiguration));

		SaveModuleConfiguration();

		return true;

	}
	else if (commandName == "TESTLOAD")
	{

		LoadModuleConfiguration();

		return true;

	}
	else if (commandName == "LEDS")
	{
		//Check if user wants to set all LEDs on or off and send that as a broadcast packet to all
		//mesh nodes
		bool state = (commandArgs.size() > 0 && commandArgs[0] == "on") ? true : false;

		connPacketModuleRequest packet;

		packet.header.messageType = MESSAGE_TYPE_MODULE_TRIGGER_ACTION;
		packet.header.sender = node->persistentConfig.nodeId;
		packet.header.receiver = NODE_ID_BROADCAST;

		packet.moduleId = moduleId;
		packet.data[0] = TestModuleMessages::LED_MESSAGE;
		packet.data[1] = state;

		cm->SendMessageOverConnections(NULL, (u8*)&packet, SIZEOF_CONN_PACKET_MODULE_REQUEST+2, true);


		return true;

	}
	else
	{
		return false;
	}

}
Пример #2
0
AdvertisingModule::AdvertisingModule(u8 moduleId, Node* node, ConnectionManager* cm, const char* name, u16 storageSlot)
	: Module(moduleId, node, cm, name, storageSlot)
{
	//Register callbacks n' stuff

	//Save configuration to base class variables
	//sizeof configuration must be a multiple of 4 bytes
	configurationPointer = &configuration;
	configurationLength = sizeof(AdvertisingModuleConfiguration);

	//Start module configuration loading
	LoadModuleConfiguration();
}
Пример #3
0
PingModule::PingModule(u16 moduleId, Node* node, ConnectionManager* cm, const char* name, u16 storageSlot)
	: Module(moduleId, node, cm, name, storageSlot)
{
	//Register callbacks n' stuff
	Logger::getInstance().enableTag("PINGMOD");

	//Save configuration to base class variables
	//sizeof configuration must be a multiple of 4 bytes
	configurationPointer = &configuration;
	configurationLength = sizeof(PingModuleConfiguration);

	//Start module configuration loading
	LoadModuleConfiguration();
}
Пример #4
0
PingModule::PingModule(u16 moduleId, Node* node, ConnectionManager* cm, const char* name, u16 storageSlot)
	: Module(moduleId, node, cm, name, storageSlot)
{
	//Register callbacks n' stuff
	Logger::getInstance().enableTag("PINGMOD");

	//Save configuration to base class variables
	//sizeof configuration must be a multiple of 4 bytes
	configurationPointer = &configuration;
	configurationLength = sizeof(PingModuleConfiguration);
	//Start module configuration loading
	LoadModuleConfiguration();
        configuration.moduleActive = true; 	
        nrf_gpio_cfg_output(18); 
        nrf_gpio_pin_set(18); 
       LedBlue = new LedWrapper(BSP_LED_2, false);

}
Пример #5
0
ScanningModule::ScanningModule(u16 moduleId, Node* node, ConnectionManager* cm, const char* name, u16 storageSlot) :
		Module(moduleId, node, cm, name, storageSlot)
{
	//Register callbacks n' stuff
	//Logger::getInstance().enableTag("SCANMOD");

	//Save configuration to base class variables
	//sizeof configuration must be a multiple of 4 bytes
	configurationPointer = &configuration;
	configurationLength = sizeof(ScanningModuleConfiguration);

	//Initialize scanFilters as empty
	for (int i = 0; i < SCAN_FILTER_NUMBER; i++)
	{
		scanFilters[i].active = 0;
	}

	//Start module configuration loading
	LoadModuleConfiguration();
}