コード例 #1
0
int _tmain(int argc, _TCHAR* argv[])
{
	ChooseFile();
	ChooseAddress();
	CopyFileBegin();
	return 0;
}
コード例 #2
0
ファイル: MeshBase.cpp プロジェクト: robomotic/ArduinoMesh
void MeshBase::Update()
{
	// Periodic sends
	if (millis() - last_broadcast_time > PEER_DISCOVERY_TIME)
	{
    		if (!IsReady())
			ChooseAddress();
		SendPeerDiscovery();
	}

	// Recieve
	uint8_t pipe_num;
	if (radio.available(&pipe_num))
	{
		bool done = false;
		do {
			uint8_t len = radio.getDynamicPayloadSize();
			uint8_t buff[40];
			done = radio.read(buff, min(len, sizeof(buff)));
			if (pipe_num == 0)
			{
				HandleMessage(0, buff, len);
			} else if (pipe_num == 1) {
				HandlePeerDiscovery(buff, len);
			}
		} while (!done);
	}
	
	// Update peers
	if (millis() - last_peer_check_time > PEER_CHECK_TIME)
	{
		LinkedList<Peer>::Node* current = peers.first;
		while(current != NULL)
		{
			current->item->time += 1;
			if (current->item->time >= PEER_TIMEOUT)
			{
				Serial.print("Lost Peer: ");
				Serial.println(current->item->address, DEC);
				current = peers.Remove(current);
			} else {
				current = current->next;
			}
		}
		last_peer_check_time = millis();
	}
}