static void setup_dhcpv4(struct net_if *iface) { NET_INFO("Running dhcpv4 client..."); net_mgmt_init_event_callback(&mgmt_cb, ipv4_addr_add_handler, NET_EVENT_IPV4_ADDR_ADD); net_mgmt_add_event_callback(&mgmt_cb); net_dhcpv4_start(iface); }
static int shell_cmd_scan(int argc, char *argv[]) { struct net_if *iface = net_if_get_default(); u32_t scan_type; int ret; memset(¶ms, 0, sizeof(struct ieee802154_req_params)); net_mgmt_init_event_callback(&scan_cb, scan_result_cb, NET_EVENT_IEEE802154_SCAN_RESULT); if (!strcmp(argv[1], "active")) { scan_type = NET_REQUEST_IEEE802154_ACTIVE_SCAN; } else if (!strcmp(argv[1], "passive")) { scan_type = NET_REQUEST_IEEE802154_PASSIVE_SCAN; } else { return -EINVAL; } if (!strcmp(argv[2], "all")) { params.channel_set = IEEE802154_ALL_CHANNELS; } else { params.channel_set = parse_channel_set(argv[2]); } if (!params.channel_set) { return -EINVAL; } params.duration = atoi(argv[3]); printk("%s Scanning (channel set: 0x%08x, duration %u ms)...", scan_type == NET_REQUEST_IEEE802154_ACTIVE_SCAN ? "Active" : "Passive", params.channel_set, params.duration); if (scan_type == NET_REQUEST_IEEE802154_ACTIVE_SCAN) { ret = net_mgmt(NET_REQUEST_IEEE802154_ACTIVE_SCAN, iface, ¶ms, sizeof(struct ieee802154_req_params)); } else { ret = net_mgmt(NET_REQUEST_IEEE802154_PASSIVE_SCAN, iface, ¶ms, sizeof(struct ieee802154_req_params)); } if (ret) { printk("Could not raise a scan (status: %i)\n", ret); } else { printk("Done\n"); } return 0; }
static inline void init_app(void) { struct net_if *iface; NET_INFO("Run dhcpv4 client"); iface = net_if_get_default(); net_dhcpv4_start(iface); k_sem_init(&quit_lock, 0, UINT_MAX); net_mgmt_init_event_callback(&mgmt_cb, handler, NET_EVENT_IPV4_ADDR_ADD); net_mgmt_add_event_callback(&mgmt_cb); }