Nicolas Borla / Mbed OS BBR_1Ebene
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers thread_discovery.h Source File

thread_discovery.h

00001 /*
00002  * Copyright (c) 2016-2017, 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 typedef struct discovery_response_list {
00036     uint8_t reserved_opaque[21];
00037     uint8_t network_name[16];
00038     uint8_t steering_data[16];
00039     uint8_t extented_pan_id[8];
00040     uint8_t extented_mac[8];
00041     uint16_t pan_id;
00042     uint16_t joiner_port;
00043     uint16_t commissioner_port;
00044     uint8_t channel;
00045     int8_t dbm;
00046     unsigned version:4;
00047     unsigned steering_data_valid:5;
00048 
00049     ns_list_link_t link;
00050 } discovery_response_list_t;
00051 
00052 
00053 typedef struct {
00054     uint64_t active_timestamp;
00055     uint16_t pan_id;
00056     uint8_t  channel;
00057 } announce_discovery_response_t;
00058 
00059 typedef NS_LIST_HEAD (discovery_response_list_t, link) thread_nwk_discovery_response_list_t;
00060 
00061 typedef struct {
00062     uint8_t *extented_pan_id;
00063     uint8_t *network_name;
00064     uint16_t pan_id;
00065     unsigned version:4;
00066 } discover_server_info_t;
00067 
00068 /**
00069  * Thread network discovery
00070  */
00071 typedef struct {
00072     uint32_t channel_mask;
00073     bool joiner_flag:1;
00074     bool native_commisioner; //Set for native commisioner
00075     uint8_t filter_tlv_length; //Optional Filter data length
00076     uint8_t *filter_tlv_data; //Pointer for filter specific data
00077 } thread_discover_reques_t;
00078 
00079 /**
00080  * Thread network discovery
00081  */
00082 typedef struct {
00083     uint64_t active_timestamp;
00084     uint32_t channel_mask;
00085     uint16_t pan_id;
00086 } thread_announce_discover_reques_t;
00087 
00088 
00089 /**
00090  *  Thread discovery ready callback
00091  *
00092  *
00093  *  \param cur_interface Interface pointer
00094  *  \param discover_response discovery response list (linked list)
00095  */
00096 typedef void (thread_discovery_ready_cb)(struct protocol_interface_info_entry *cur_interface, thread_nwk_discovery_response_list_t *discover_response);
00097 
00098 /**
00099  *  Thread Orphan nwk discovery ready callback
00100  *
00101  *
00102  *  \param cur_interface Interface pointer
00103  *  \param nwk discovery response list (linked list)
00104  */
00105 typedef void (thread_announce_scan_ready_cb)(struct protocol_interface_info_entry *cur_interface, announce_discovery_response_t *discover_response);
00106 
00107 /**
00108  * Init discovery service
00109  */
00110 int thread_discovery_init(int8_t interface_id, struct protocol_interface_info_entry *cur_interface, uint8_t version, bool reedDevice);
00111 
00112 /**
00113  * Reset discovery class state to idle
00114  */
00115 int thread_discovery_reset(int8_t interface_id);
00116 
00117 /**
00118  * Enable thread discovery request response support
00119  */
00120 int thread_discovery_responser_enable(int8_t interface_id, bool enable_service);
00121 
00122 /**
00123  * Start Thread network discovery
00124  */
00125 int thread_discovery_network_scan(int8_t interface_id, thread_discover_reques_t *scan_request, thread_discovery_ready_cb *ready_cb);
00126 
00127 /**
00128  * Start device orphan scan
00129  */
00130 int thread_discovery_announce_network_scan(int8_t interface_id, thread_announce_discover_reques_t *scan_request, thread_announce_scan_ready_cb *ready_cb);
00131 
00132 /**
00133  * Get primary network from discovered list
00134  */
00135 discovery_response_list_t *thread_discovery_network_description_get(int8_t interface_id);
00136 
00137 #if 0
00138 /**
00139  * Free all allocated memory and free class
00140  * Not used API function, flagged away. This should be taken in use when refactoring ifdown - functionality.
00141  */
00142 int thread_discovery_free(int8_t interface_id);
00143 #endif
00144 #endif /* THREAD_DISCOVERY_H_ */