コード例 #1
0
ファイル: ping.c プロジェクト: ButKamZ/MBLed
//There is no answer from the PING.
void ping_no_answer(uint8_t* nbNoAnswer, uint8_t interface){
  
  int8_t neighbor = interface_neighbor(interface);

  //There is no neighbor, so it's logical.
  if(neighbor == -1 )
    return;

  //There was someone few seconds ago, so nbNoAnswer increases.
  (*nbNoAnswer)++;

   //When we have no news for a long time, the module is gone.
  if((*nbNoAnswer) == NB_NO_PING){

    //the first interface to have no answer will copy the interfaces.
    if(!awareOfMissingBlock)
      interfaces_copy();

    setInterface(interface, -1, -1);
    //Throwing away the IrDA queues for this UART.
    irda_reset_queues(interface2uart(interface));
    
    //Maybe he has just turned so we check...
    if(!ID_in_interfaces(neighbor)) {
      network_reset(neighbor, interface);
    }

    (*nbNoAnswer) = 0;
  }
   
}
コード例 #2
0
ファイル: radio_network.c プロジェクト: adjih/openlab
void network_init(uint32_t channel, uint32_t discovery_tx_power,
        uint32_t communication_tx_power)
{
    network_reset();

    rn_config.channel = channel;
    rn_config.discovery_tx_power = discovery_tx_power;
    rn_config.communication_tx_power = communication_tx_power;

    mac_csma_init(rn_config.channel, rn_config.communication_tx_power);
}
コード例 #3
0
int network_restart(int timeout)
{
	int dhcp = 0;
	char lan_type[64];
	char lif[16];

	if (first_init_flag) {
		first_init_flag = 0;
		network_task_init();
	}

	if (timeout > 0 )
		network_task.timeout = timeout;
	else
		network_task.timeout = DEFAULT_TIMEOUT_SECS;

	network_task.start_time = time(NULL);

	network_reset();

	securesoho_lif_get(lif);
	securesoho_string_get( "LAN_TYPE", lan_type);

	dhcp = (lan_type[0] == 'd' ? 1 : 0);

	if ( !strcmp(lif, WLAN_PORT) ) {
		printf("network_restart:start wireless thread\n");
		start_wireless_thread(); 
		network_set_state(NETWORK_STATE_WIRELESS_CONNECTING);
	} else {
		if (dhcp) {
			network_ifconf_dhcp(network_task.timeout);
			network_set_state(NETWORK_STATE_REQUESTING_IP);
		} else {
			network_ifconf_static();
			network_set_state(NETWORK_STATE_DONE);
		}

	}

	return dhcp;
}