Nanostack Border Router is a generic mbed border router implementation that provides the 6LoWPAN ND or Thread border router initialization logic.
Diff: source/thread_br_conn_handler.c
- Revision:
- 4:0a9d1eeaa905
- Parent:
- 0:85f4174a8e29
- Child:
- 20:918e62713e63
--- a/source/thread_br_conn_handler.c Tue Apr 11 12:30:18 2017 +0100 +++ b/source/thread_br_conn_handler.c Tue Apr 25 08:45:18 2017 +0100 @@ -98,12 +98,15 @@ void thread_br_conn_handler_thread_connection_update(bool status) { thread_br_handler.thread_connection_ready = status; + tr_debug("mesh0 connection status: %d", status); + if (status) { - tr_debug("mesh0 connected"); thread_br_conn_handler_border_router_startup_attempt(); } else { // Thread network down. Reset DHCP server back to original state thread_br_handler.dhcp_server_running = false; + // stop mDNS responder as no thread network + thread_border_router_mdns_responder_stop(); if (thread_br_handler.thread_dhcp_shutdown_timer != NULL) { // cancel active shutdown timer eventOS_timeout_cancel(thread_br_handler.thread_dhcp_shutdown_timer); @@ -112,17 +115,17 @@ } } - void thread_br_conn_handler_ethernet_connection_update(bool status) { thread_br_handler.eth_connection_ready = status; + tr_debug("Eth0 connection status: %d", status); + if (status) { - tr_debug("Eth0 connected"); thread_br_conn_handler_border_router_startup_attempt(); } else { // Ethernet connection down, request DHCP server shutdown thread_br_conn_handler_border_router_shutdown_request(); - tr_debug("Eth0 disconnected"); + thread_border_router_mdns_responder_stop(); } } @@ -157,6 +160,7 @@ if (thread_border_router_prefix_add(thread_br_handler.thread_interface_id, thread_br_handler.dhcp_prefix, thread_br_handler.dhcp_prefix_len, &thread_border_router_info) == 0) { thread_border_router_publish(thread_br_handler.thread_interface_id); tr_debug("Updated %s prefix", print_ipv6_prefix(thread_br_handler.dhcp_prefix, thread_br_handler.dhcp_prefix_len)); + thread_border_router_mdns_responder_start(thread_br_handler.thread_interface_id, thread_br_handler.eth_interface_id, "ARM-BR"); return true; } else { tr_error("Failed to enable default_route flag to prefix"); @@ -167,12 +171,12 @@ static void thread_br_conn_handler_dhcp_server_stop_cb(void *arg) { (void)arg; + + tr_debug("DHCP server stop cb"); thread_br_handler.thread_dhcp_shutdown_timer = NULL; thread_br_handler.dhcp_server_running = false; thread_dhcpv6_server_delete(thread_br_handler.thread_interface_id, thread_br_handler.dhcp_prefix); thread_border_router_publish(thread_br_handler.thread_interface_id); - - tr_debug("DHCP server stop cb"); thread_br_handler.dhcp_prefix_len = 0; memset(thread_br_handler.dhcp_prefix, 0, 16); }