Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
fhss_configuration_interface.c
00001 /* 00002 * Copyright (c) 2016-2018, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 #include "nsconfig.h" 00018 #include <string.h> 00019 #include "ns_types.h" 00020 #include "fhss_api.h " 00021 #include "fhss_config.h " 00022 #include "net_fhss.h" 00023 #include "nsdynmemLIB.h" 00024 #include "Service_Libs/fhss/fhss.h" 00025 #include "Service_Libs/fhss/fhss_common.h" 00026 #include "Service_Libs/fhss/fhss_ws.h" 00027 #include "Service_Libs/fhss/fhss_statistics.h" 00028 #include "ns_trace.h" 00029 00030 #define TRACE_GROUP "fhss" 00031 00032 fhss_api_t *ns_fhss_create(const fhss_configuration_t *fhss_configuration, const fhss_timer_t *fhss_timer, fhss_statistics_t *fhss_statistics) 00033 { 00034 fhss_api_t *this = ns_dyn_mem_alloc(sizeof(fhss_api_t)); 00035 if (!this) { 00036 return NULL; 00037 } 00038 // Create FHSS object 00039 fhss_structure_t *fhss_struct = fhss_enable(this, fhss_configuration, fhss_timer, fhss_statistics); 00040 if (!fhss_struct) { 00041 tr_err("Failed to enable FHSS"); 00042 ns_dyn_mem_free(this); 00043 return NULL; 00044 } 00045 fhss_set_callbacks(fhss_struct); 00046 return this; 00047 } 00048 00049 fhss_api_t *ns_fhss_ws_create(const fhss_ws_configuration_t *fhss_configuration, const fhss_timer_t *fhss_timer) 00050 { 00051 fhss_api_t *this = ns_dyn_mem_alloc(sizeof(fhss_api_t)); 00052 if (!this) { 00053 return NULL; 00054 } 00055 // Create FHSS object 00056 fhss_structure_t *fhss_struct = fhss_ws_enable(this, fhss_configuration, fhss_timer); 00057 if (!fhss_struct) { 00058 tr_err("Failed to enable FHSS"); 00059 ns_dyn_mem_free(this); 00060 return NULL; 00061 } 00062 fhss_ws_set_callbacks(fhss_struct); 00063 return this; 00064 } 00065 00066 int ns_fhss_ws_set_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8], const broadcast_timing_info_t *bc_timing_info, const bool force_synch) 00067 { 00068 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00069 if (!fhss_structure || !eui64 || !bc_timing_info) { 00070 return -1; 00071 } 00072 return fhss_ws_set_parent(fhss_structure, eui64, bc_timing_info, force_synch); 00073 } 00074 00075 int ns_fhss_ws_remove_parent(const fhss_api_t *fhss_api, const uint8_t eui64[8]) 00076 { 00077 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00078 if (!fhss_structure || !eui64) { 00079 return -1; 00080 } 00081 return fhss_ws_remove_parent(fhss_structure, eui64); 00082 } 00083 00084 int ns_fhss_delete(fhss_api_t *fhss_api) 00085 { 00086 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00087 if (!fhss_structure) { 00088 return -1; 00089 } 00090 if (fhss_disable(fhss_structure)) { 00091 return -1; 00092 } 00093 ns_dyn_mem_free(fhss_api); 00094 return 0; 00095 } 00096 00097 int ns_fhss_configuration_set(fhss_api_t *fhss_api, const fhss_synch_configuration_t *fhss_synch_configuration) 00098 { 00099 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00100 if (!fhss_structure) { 00101 return -1; 00102 } 00103 return fhss_set_synch_configuration(fhss_structure, fhss_synch_configuration); 00104 } 00105 00106 int ns_fhss_set_neighbor_info_fp(const fhss_api_t *fhss_api, fhss_get_neighbor_info *get_neighbor_info) 00107 { 00108 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00109 if (!fhss_structure || !fhss_structure->ws) { 00110 return -1; 00111 } 00112 fhss_structure->ws->get_neighbor_info = get_neighbor_info; 00113 return 0; 00114 } 00115 00116 const fhss_ws_configuration_t *ns_fhss_ws_configuration_get(const fhss_api_t *fhss_api) 00117 { 00118 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00119 if (!fhss_structure || !fhss_structure->ws) { 00120 return NULL; 00121 } 00122 return &fhss_structure->ws->fhss_configuration; 00123 } 00124 00125 int ns_fhss_ws_configuration_set(const fhss_api_t *fhss_api, const fhss_ws_configuration_t *fhss_configuration) 00126 { 00127 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00128 if (!fhss_structure || !fhss_structure->ws) { 00129 return -1; 00130 } 00131 return fhss_ws_configuration_set(fhss_structure, fhss_configuration); 00132 } 00133 00134 int ns_fhss_ws_set_hop_count(const fhss_api_t *fhss_api, const uint8_t hop_count) 00135 { 00136 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00137 if (!fhss_structure || !fhss_structure->ws) { 00138 return -1; 00139 } 00140 return fhss_ws_set_hop_count(fhss_structure, hop_count); 00141 } 00142 00143 int ns_fhss_statistics_start(const fhss_api_t *fhss_api, fhss_statistics_t *fhss_statistics) 00144 { 00145 fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api); 00146 if (!fhss_structure) { 00147 return -1; 00148 } 00149 return fhss_statistics_start(fhss_structure, fhss_statistics); 00150 }
Generated on Tue Jul 12 2022 13:54:21 by
