Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers thread_discovery.h Source File

thread_discovery.h

00001 /*
00002  * Copyright (c) 2016-2018, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: BSD-3-Clause
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the copyright holder nor the
00014  *    names of its contributors may be used to endorse or promote products
00015  *    derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef THREAD_DISCOVERY_H_
00031 #define THREAD_DISCOVERY_H_
00032 
00033 struct protocol_interface_info_entry;
00034 
00035 /* Structure that discovery_response_list_t */
00036 typedef struct discovery_additional_info {
00037     uint8_t domain_name[16];
00038     uint16_t ae_port;
00039     uint16_t nmk_port;
00040     bool ccm_supported: 1;
00041 } discovery_additional_info_t;
00042 
00043 typedef struct discovery_response_list {
00044     discovery_additional_info_t ccm_info;
00045     uint8_t network_name[16];
00046     uint8_t steering_data[16];
00047     uint8_t extented_pan_id[8];
00048     uint8_t extented_mac[8];
00049     uint16_t pan_id;
00050     uint16_t joiner_port;
00051     uint16_t commissioner_port;
00052     uint8_t channel;
00053     int8_t dbm;
00054     unsigned version: 4;
00055     unsigned steering_data_valid: 5;
00056 
00057     ns_list_link_t link;
00058 } discovery_response_list_t;
00059 
00060 
00061 typedef struct {
00062     uint64_t active_timestamp;
00063     uint16_t pan_id;
00064     uint8_t  channel;
00065 } announce_discovery_response_t;
00066 
00067 typedef NS_LIST_HEAD (discovery_response_list_t, link) thread_nwk_discovery_response_list_t;
00068 
00069 typedef struct {
00070     uint8_t *extented_pan_id;
00071     uint8_t *network_name;
00072     uint16_t pan_id;
00073     unsigned version: 4;
00074 } discover_server_info_t;
00075 
00076 /**
00077  * Thread network discovery
00078  */
00079 typedef struct {
00080     uint32_t channel_mask;
00081     bool joiner_flag: 1;
00082     bool native_commisioner; //Set for native commisioner
00083     uint8_t filter_tlv_length; //Optional Filter data length
00084     uint8_t *filter_tlv_data; //Pointer for filter specific data
00085 } thread_discover_reques_t;
00086 
00087 /**
00088  * Thread network discovery
00089  */
00090 typedef struct {
00091     uint64_t active_timestamp;
00092     uint32_t channel_mask;
00093     uint16_t pan_id;
00094 } thread_announce_discover_reques_t;
00095 
00096 
00097 /**
00098  *  Thread discovery ready callback
00099  *
00100  *
00101  *  \param cur_interface Interface pointer
00102  *  \param discover_response discovery response list (linked list)
00103  */
00104 typedef void (thread_discovery_ready_cb)(struct protocol_interface_info_entry *cur_interface, thread_nwk_discovery_response_list_t *discover_response);
00105 
00106 /**
00107  *  Thread Orphan nwk discovery ready callback
00108  *
00109  *
00110  *  \param cur_interface Interface pointer
00111  *  \param nwk discovery response list (linked list)
00112  */
00113 typedef void (thread_announce_scan_ready_cb)(struct protocol_interface_info_entry *cur_interface, announce_discovery_response_t *discover_response);
00114 
00115 /**
00116  * Init discovery service
00117  */
00118 int thread_discovery_init(int8_t interface_id, struct protocol_interface_info_entry *cur_interface, uint8_t version, bool reedDevice);
00119 
00120 /**
00121  * Reset discovery class state to idle
00122  */
00123 int thread_discovery_reset(int8_t interface_id);
00124 
00125 /**
00126  * Enable thread discovery request response support
00127  */
00128 int thread_discovery_responser_enable(int8_t interface_id, bool enable_service);
00129 
00130 /**
00131  * Start Thread network discovery
00132  */
00133 int thread_discovery_network_scan(struct protocol_interface_info_entry *cur_interface, thread_discover_reques_t *scan_request, thread_discovery_ready_cb *ready_cb);
00134 
00135 /**
00136  * Start device orphan scan
00137  */
00138 int thread_discovery_announce_network_scan(int8_t interface_id, thread_announce_discover_reques_t *scan_request, thread_announce_scan_ready_cb *ready_cb);
00139 
00140 /**
00141  * Get primary network from discovered list
00142  */
00143 discovery_response_list_t *thread_discovery_network_description_get(int8_t interface_id);
00144 
00145 #if 0
00146 /**
00147  * Free all allocated memory and free class
00148  * Not used API function, flagged away. This should be taken in use when refactoring ifdown - functionality.
00149  */
00150 int thread_discovery_free(int8_t interface_id);
00151 #endif
00152 #endif /* THREAD_DISCOVERY_H_ */