Skip to content

Commit

Permalink
commissioner updates. (ARMmbed#1812)
Browse files Browse the repository at this point in the history
commissioner module dependency on thread interface removed.
  • Loading branch information
deepakvenugopal authored Sep 14, 2018
1 parent 40b2eec commit 7c13c3c
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 68 deletions.
14 changes: 14 additions & 0 deletions nanostack/thread_commissioning_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ void *thread_commission_device_get_next(void *ptr, int8_t interface_id, bool *sh

typedef struct thread_commissioning_link_configuration {
uint8_t name[16]; /**< Name of the Thread network. utf8 string nul terminated if shorter than 16. */
uint8_t destination_address[16]; /**<Border router destination address*/
uint8_t extented_pan_id[8]; /**< Extended PAN ID. */
uint16_t panId; /**< Network ID. */
uint16_t destination_port; /**<destination port for commissioning*/
uint8_t Protocol_id; /**< Current protocol ID. */
uint8_t version; /**< Current protocol version. */
uint8_t rfChannel; /**< Current RF channel. */
Expand Down Expand Up @@ -271,6 +273,18 @@ int thread_commissioning_native_commissioner_get_connection_info(int8_t interfac
*/
int8_t thread_commissioning_get_management_id(int8_t interface_id);

/**
* \brief Attach native commissioner to destination address and port.
*
* \param interface_id Network interface ID.
* \param destination_address Destination address pointer.
* \param destination_port Commissioning port.
*
* \return 0 attach OK.
* \return < 0 fail.
*/
int thread_commissioning_attach(int8_t interface_id, uint8_t *destination_address, uint16_t destination_port);

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions source/6LoWPAN/Thread/thread_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,10 @@ void thread_discover_native_commissioner_response(protocol_interface_info_entry_
config_ptr[n].rfChannel = cur_class->channel;
memcpy(config_ptr[n].name, cur_class->network_name, 16);
memcpy(config_ptr[n].extented_pan_id, cur_class->extented_pan_id, 8);
memcpy(config_ptr[n].destination_address, ADDR_LINK_LOCAL_PREFIX, 8);
memcpy(&config_ptr[n].destination_address[8], cur_class->extented_mac, 8);
config_ptr[n].destination_address[8] ^= 2;
config_ptr[n].destination_port = cur_class->commissioner_port;
n++;
}

Expand Down
265 changes: 219 additions & 46 deletions source/6LoWPAN/Thread/thread_commissioning_api.c

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion source/6LoWPAN/Thread/thread_leader_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ static int thread_leader_service_commissioner_register(int8_t interface_id, uint
protocol_interface_info_entry_t *cur;
link_configuration_s *linkConfiguration;

tr_debug("Register interface %d commissioner: %s", interface_id, trace_ipv6(border_router_address));

linkConfiguration = thread_joiner_application_get_config(interface_id);
if (!linkConfiguration) {
Expand Down Expand Up @@ -341,6 +340,13 @@ static int thread_leader_service_commissioner_register(int8_t interface_id, uint
*session_id = cur->thread_info->registered_commissioner.session_id;
}

if (memcmp(border_router_address, linkConfiguration->mesh_local_ula_prefix, 8) == 0 &&
memcmp(border_router_address + 8, ADDR_SHORT_ADR_SUFFIC, 6) == 0 &&
border_router_address[14] == 0xfc) {
// source address is ALOC
common_write_16_bit(cur->thread_info->routerShortAddress, &border_router_address[14]);
}
tr_debug("Register interface %d commissioner: %s", interface_id, trace_ipv6(border_router_address));
//SET Border Router Locator
memcpy(cur->thread_info->registered_commissioner.border_router_address, border_router_address, 16);
cur->thread_info->registered_commissioner.commissioner_valid = true;
Expand Down
6 changes: 1 addition & 5 deletions source/6LoWPAN/Thread/thread_management_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,7 @@ int thread_management_register(int8_t interface_id)
this->interface_id = interface_id;
this->set_response_cb_ptr = NULL;
this->get_response_cb_ptr = NULL;

if (thread_management_get_remote_addr(this)) {
ns_dyn_mem_free(this);
return -1;
}
thread_management_get_remote_addr(this);

ns_list_add_to_start(&instance_list, this);
if(this->native_interface) {
Expand Down
2 changes: 1 addition & 1 deletion test/nanostack/unittest/stub/thread_meshcop_lib_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ thread_meshcop_lib_stub_def thread_meshcop_lib_stub;

uint8_t *thread_meshcop_tlv_data_write(uint8_t *ptr, uint8_t type, uint16_t length, const uint8_t *data)
{
return NULL;
return ptr;
}

uint8_t *thread_meshcop_tlv_data_write_header(uint8_t *ptr, uint8_t type, uint16_t length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ TEST_SRC_FILES = \
../../stub/protocol_core_stub.c \
../../stub/protocol_6lowpan_stub.c \
../../stub/thread_common_stub.c \
../../stub/address_stub.c \
../../stub/randLIB_stub.c \
../../stub/thread_meshcop_lib_stub.c \


include ../../MakefileWorker.mk

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,11 @@ TEST(thread_commissioning_api, test_commissioning_device_add_and_remove)
TEST(thread_commissioning_api, test_commissioning_device_add)
{
CHECK(test_commissioning_device_add());
}
}

TEST(thread_commissioning_api, test_commissioning_device_delete)
{
CHECK(test_commissioning_device_delete());
}

TEST(thread_commissioning_api, test_commissioning_register_twice)
{
CHECK(test_commissioning_register_twice());
}

TEST(thread_commissioning_api, test_thread_commissioning_petition_start)
Expand All @@ -69,11 +64,6 @@ TEST(thread_commissioning_api, test_thread_commissioning_application_provision_c
CHECK(test_thread_commissioning_application_provision_cb());
}

TEST(thread_commissioning_api, test_thread_commissioning_finalisation_req_recv_cb)
{
CHECK(test_thread_commissioning_finalisation_req_recv_cb());
}

TEST(thread_commissioning_api, test_thread_commissioning_rx_receive_cb)
{
CHECK(test_thread_commissioning_rx_receive_cb());
Expand All @@ -82,10 +72,6 @@ TEST(thread_commissioning_api, test_thread_commissioning_native_commissioner_sta
{
CHECK(test_thread_commissioning_native_commissioner_start());
}
TEST(thread_commissioning_api, test_thread_commissioning_native_commissioner_connect)
{
CHECK(test_thread_commissioning_native_commissioner_connect());
}



Expand Down

0 comments on commit 7c13c3c

Please sign in to comment.