Esempio n. 1
0
void nd_tasklet_trace_bootstrap_info()
{
    network_layer_address_s app_nd_address_info;
    link_layer_address_s app_link_address_info;
    uint8_t temp_ipv6[16];
    if (arm_nwk_nd_address_read(tasklet_data_ptr->network_interface_id,
                                &app_nd_address_info) != 0) {
        tr_error("ND Address read fail");
    } else {
        tr_debug("ND Access Point: %s", trace_ipv6(app_nd_address_info.border_router));
        tr_debug("ND Prefix 64: %s", trace_array(app_nd_address_info.prefix, 8));

        if (arm_net_address_get(tasklet_data_ptr->network_interface_id,
                                ADDR_IPV6_GP, temp_ipv6) == 0) {
            tr_debug("GP IPv6: %s", trace_ipv6(temp_ipv6));
        }
    }

    if (arm_nwk_mac_address_read(tasklet_data_ptr->network_interface_id,
                                 &app_link_address_info) != 0) {
        tr_error("MAC Address read fail\n");
    } else {
        uint8_t temp[2];
        common_write_16_bit(app_link_address_info.mac_short,temp);
        tr_debug("MAC 16-bit: %s", trace_array(temp, 2));
        common_write_16_bit(app_link_address_info.PANId, temp);
        tr_debug("PAN ID: %s", trace_array(temp, 2));
        tr_debug("MAC 64-bit: %s", trace_array(app_link_address_info.mac_long, 8));
        tr_debug("IID (Based on MAC 64-bit address): %s", trace_array(app_link_address_info.iid_eui64, 8));
    }

    tr_debug("Channel: %d", arm_net_get_current_channel(tasklet_data_ptr->network_interface_id));
}
char *Nanostack::Interface::get_mac_address(char *buf, nsapi_size_t buflen)
{
    NanostackLockGuard lock;
    link_layer_address_s addr;
    if (buflen >= 24 && arm_nwk_mac_address_read(interface_id, &addr) == 0) {
        snprintf(buf, buflen, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", addr.mac_long[0], addr.mac_long[1], addr.mac_long[2], addr.mac_long[3], addr.mac_long[4], addr.mac_long[5], addr.mac_long[6], addr.mac_long[7]);
        return buf;
    } else {
        return NULL;
    }
}
Esempio n. 3
0
void thread_tasklet_trace_bootstrap_info()
{
    link_layer_address_s app_link_address_info;
    uint8_t temp_ipv6[16];
    if (arm_net_address_get(thread_tasklet_data_ptr->nwk_if_id,
                            ADDR_IPV6_GP, temp_ipv6) == 0) {
        tr_debug("GP IPv6: %s", trace_ipv6(temp_ipv6));
    }

    if (arm_nwk_mac_address_read(thread_tasklet_data_ptr->nwk_if_id,
                                 &app_link_address_info) != 0) {
        tr_error("MAC Address read fail\n");
    } else {
        uint8_t temp[2];
        common_write_16_bit(app_link_address_info.mac_short,temp);
        tr_debug("MAC 16-bit: %s", trace_array(temp, 2));
        common_write_16_bit(app_link_address_info.PANId, temp);
        tr_debug("PAN ID: %s", trace_array(temp, 2));
        tr_debug("MAC 64-bit: %s", trace_array(app_link_address_info.mac_long, 8));
        tr_debug("IID (Based on MAC 64-bit address): %s", trace_array(app_link_address_info.iid_eui64, 8));
    }
}
/**
  * \brief Network state event handler.
  * \param event show network start response or current network state.
  *
  * - ARM_NWK_BOOTSTRAP_READY: Save NVK peristant data to NVM and Net role
  * - ARM_NWK_NWK_SCAN_FAIL: Link Layer Active Scan Fail, Stack is Already at Idle state
  * - ARM_NWK_IP_ADDRESS_ALLOCATION_FAIL: No ND Router at current Channel Stack is Already at Idle state
  * - ARM_NWK_NWK_CONNECTION_DOWN: Connection to Access point is lost wait for Scan Result
  * - ARM_NWK_NWK_PARENT_POLL_FAIL: Host should run net start without any PAN-id filter and all channels
  * - ARM_NWK_AUHTENTICATION_FAIL: Pana Authentication fail, Stack is Already at Idle state
  */
void app_parse_network_event(arm_event_s *event )
{
	arm_nwk_interface_status_type_e status = (arm_nwk_interface_status_type_e)event->event_data;
	switch (status)
	{
		  case ARM_NWK_BOOTSTRAP_READY:
			  /* Network is ready and node is connect to Access Point */
			  if(access_point_status==0)
			  {
				  uint8_t temp_ipv6[16];
				  tr_debug("Network Connection Ready");
				  access_point_status=1;

				  if( arm_nwk_nd_address_read(net_rf_id,&app_nd_address_info) != 0)
				  {
					  tr_debug("ND Address read fail");
				  }
				  else
				  {
					  debug("ND Access Point:");
						printf_ipv6_address(app_nd_address_info.border_router);

						debug("ND Prefix 64:");
						printf_array(app_nd_address_info.prefix, 8);

						if(arm_net_address_get(net_rf_id,ADDR_IPV6_GP,temp_ipv6) == 0)
						{
							debug("GP IPv6:");
							printf_ipv6_address(temp_ipv6);
						}
					}

				  if( arm_nwk_mac_address_read(net_rf_id,&app_link_address_info) != 0)
					{
						tr_debug("MAC Address read fail\n");
					}
					else
					{
						uint8_t temp[2];
						debug("MAC 16-bit:");
						common_write_16_bit(app_link_address_info.PANId,temp);
						debug("PAN ID:");
						printf_array(temp, 2);
						debug("MAC 64-bit:");
						printf_array(app_link_address_info.mac_long, 8);
						debug("IID (Based on MAC 64-bit address):");
						printf_array(app_link_address_info.iid_eui64, 8);
					}

			  }

			  break;
		  case ARM_NWK_NWK_SCAN_FAIL:
			  /* Link Layer Active Scan Fail, Stack is Already at Idle state */
			  tr_debug("Link Layer Scan Fail: No Beacons");
			  access_point_status=0;
			  break;
		  case ARM_NWK_IP_ADDRESS_ALLOCATION_FAIL:
			  /* No ND Router at current Channel Stack is Already at Idle state */
			  tr_debug("ND Scan/ GP REG fail");
			  access_point_status=0;
			  break;
		  case ARM_NWK_NWK_CONNECTION_DOWN:
			  /* Connection to Access point is lost wait for Scan Result */
			  tr_debug("ND/RPL scan new network");
			  access_point_status=0;
			  break;
		  case ARM_NWK_NWK_PARENT_POLL_FAIL:
			  access_point_status=0;
			  break;
		  case ARM_NWK_AUHTENTICATION_FAIL:
			  tr_debug("Network authentication fail");
			  access_point_status=0;
			  break;
		  default:
			  debug_hex(status);
			  debug("Unknow event");
			  break;
	 }

	if(access_point_status == 0)
	{
		//Set Timer for new network scan
		eventOS_event_timer_request(1, ARM_LIB_SYSTEM_TIMER_EVENT,node_main_tasklet_id,5000); // 5 sec timer started
	}
}