1 /* 2 * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @file wm_params.h 18 * 19 * @brief param manager Module 20 * 21 * @author winnermicro 22 * 23 * Copyright (c) 2015 Winner Microelectronics Co., Ltd. 24 */ 25 #ifndef TLS_PARAMS_H 26 #define TLS_PARAMS_H 27 28 #include "wm_type_def.h" 29 30 /*************************************************************************************** 31 ID | Data Type 32 *************************************************************************************** 33 TLS_PARAM_ID_SSID | struct tls_param_ssid ssid 34 TLS_PARAM_ID_ENCRY | u8 encry 35 TLS_PARAM_ID_KEY | struct tls_param_key key 36 TLS_PARAM_ID_IP | struct tls_param_ip ipcfg 37 TLS_PARAM_ID_AUTOMODE | u8 auto_mode 38 TLS_PARAM_ID_DEFSOCKET | N/A 39 TLS_PARAM_ID_BSSID | struct tls_param_bssid bssid 40 TLS_PARAM_ID_CHANNEL | u8 channel 41 TLS_PARAM_ID_CHANNEL_EN | u8 channel_enable 42 TLS_PARAM_ID_COUNTRY_REGION | u8 wireless_region 43 TLS_PARAM_ID_WPROTOCOL | u8 wireless_protocol 44 TLS_PARAM_ID_ADHOC_AUTOCREATE | N/A 45 TLS_PARAM_ID_ROAMING | u8 auto_roam 46 TLS_PARAM_ID_AUTO_RETRY_CNT | N/A 47 TLS_PARAM_ID_WBGR | struct tls_param_bgr wbgr 48 TLS_PARAM_ID_USRINTF | N/A 49 TLS_PARAM_ID_AUTO_TRIGGER_LENGTH | N/A 50 TLS_PARAM_ID_DEBUG_MODE | N/A 51 TLS_PARAM_ID_HARDVERSION | struct tls_param_hardware_version hardware_v 52 TLS_PARAM_ID_BRDSSID | u8 ssid_broadcast_enable 53 TLS_PARAM_ID_DNSNAME | u8 local_dnsname[32] 54 TLS_PARAM_ID_DEVNAME | u8 local_device_name[32] 55 TLS_PARAM_ID_PSM | u8 auto_powersave 56 TLS_PARAM_ID_ORAY_CLIENT | N/A 57 TLS_PARAM_ID_UPNP | N/A 58 TLS_PARAM_ID_UART | struct tls_param_uart uart_cfg 59 TLS_PARAM_ID_WPS | struct tls_param_wps wps 60 TLS_PARAM_ID_AUTO_TRIGGER_PERIOD | N/A 61 TLS_PARAM_ID_ESCAPE_CHAR | N/A 62 TLS_PARAM_ID_ESCAPE_PERIOD | N/A 63 TLS_PARAM_ID_IO_MODE | N/A 64 TLS_PARAM_ID_CMD_MODE | N/A 65 TLS_PARAM_ID_PASSWORD | u8 PassWord[6] 66 TLS_PARAM_ID_CHANNEL_LIST | u16 channellist 67 TLS_PARAM_ID_WEBS_CONFIG | struct tls_webs_cfg WebsCfg 68 TLS_PARAM_ID_ONESHOT_CFG | u8 oneshotflag 69 TLS_PARAM_ID_SHA1 | N/A 70 TLS_PARAM_ID_ORIGIN_KEY | N/A 71 TLS_PARAM_ID_ORIGIN_SSID | N/A 72 TLS_PARAM_ID_AUTO_RECONNECT | u8 auto_reconnect 73 ***************************************************************************************/ 74 75 #define TLS_PARAM_STATUS_OK (0) 76 #define TLS_PARAM_STATUS_EINVALID (1) 77 #define TLS_PARAM_STATUS_EMEM (2) 78 #define TLS_PARAM_STATUS_EIO (3) 79 #define TLS_PARAM_STATUS_EPERM (4) 80 #define TLS_PARAM_STATUS_EINVALIDID (5) 81 82 /** MACRO of Magic number initial value */ 83 #define TLS_PARAM_INIT_MAGIC (0xffffffff) 84 /** MACRO of Magic number valid value */ 85 #define TLS_PARAM_MAGIC (0x4947414d) 86 87 /** MACRO of parameter partition number */ 88 #define TLS_PARAM_PARTITION_NUM (2) 89 90 /** MACRO of parameter identity */ 91 #define TLS_PARAM_ID_ALL (-1) 92 #define TLS_PARAM_ID_SSID (0) 93 #define TLS_PARAM_ID_ENCRY (1) 94 #define TLS_PARAM_ID_KEY (2) 95 #define TLS_PARAM_ID_IP (3) 96 #define TLS_PARAM_ID_AUTOMODE (4) 97 #define TLS_PARAM_ID_DEFSOCKET (5) 98 #define TLS_PARAM_ID_BSSID (6) 99 #define TLS_PARAM_ID_CHANNEL (7) 100 #define TLS_PARAM_ID_CHANNEL_EN (8) 101 #define TLS_PARAM_ID_COUNTRY_REGION (9) 102 #define TLS_PARAM_ID_WPROTOCOL (10) 103 #define TLS_PARAM_ID_ADHOC_AUTOCREATE (11) 104 #define TLS_PARAM_ID_ROAMING (12) 105 #define TLS_PARAM_ID_AUTO_RETRY_CNT (13) 106 #define TLS_PARAM_ID_WBGR (14) 107 #define TLS_PARAM_ID_USRINTF (15) 108 #define TLS_PARAM_ID_AUTO_TRIGGER_LENGTH (16) 109 #define TLS_PARAM_ID_DEBUG_MODE (17) 110 #define TLS_PARAM_ID_HARDVERSION (18) 111 #define TLS_PARAM_ID_BRDSSID (19) 112 #define TLS_PARAM_ID_DNSNAME (20) 113 #define TLS_PARAM_ID_DEVNAME (21) 114 #define TLS_PARAM_ID_PSM (22) 115 #define TLS_PARAM_ID_ORAY_CLIENT (23) 116 #define TLS_PARAM_ID_UPNP (24) 117 #define TLS_PARAM_ID_UART (26) 118 #define TLS_PARAM_ID_WPS (27) 119 #define TLS_PARAM_ID_AUTO_TRIGGER_PERIOD (28) 120 #define TLS_PARAM_ID_ESCAPE_CHAR (29) 121 #define TLS_PARAM_ID_ESCAPE_PERIOD (30) 122 #define TLS_PARAM_ID_IO_MODE (31) 123 #define TLS_PARAM_ID_CMD_MODE (32) 124 #define TLS_PARAM_ID_PASSWORD (33) 125 #define TLS_PARAM_ID_CHANNEL_LIST (34) 126 #define TLS_PARAM_ID_WEBS_CONFIG (35) 127 #define TLS_PARAM_ID_ONESHOT_CFG (36) 128 #define TLS_PARAM_ID_SHA1 (37) 129 #define TLS_PARAM_ID_ORIGIN_KEY (38) 130 #define TLS_PARAM_ID_ORIGIN_SSID (39) 131 #define TLS_PARAM_ID_AUTO_RECONNECT (40) 132 #define TLS_PARAM_ID_QUICK_CONNECT (41) 133 #define TLS_PARAM_ID_KEY_CHANGE (42) 134 #define TLS_PARAM_ID_SSID_CHANGE (43) 135 #define TLS_PARAM_ID_SOFTAP_SSID (44) 136 #define TLS_PARAM_ID_SOFTAP_PSK (45) 137 #define TLS_PARAM_ID_SOFTAP_ENCRY (46) 138 #define TLS_PARAM_ID_SOFTAP_KEY (47) 139 #define TLS_PARAM_ID_SOFTAP_IP (48) 140 #define TLS_PARAM_ID_SOFTAP_CHANNEL (49) 141 #define TLS_PARAM_ID_SOFTAP_WBGR (50) 142 143 #define TLS_PARAM_ID_SNTP_SERVER1 (51) 144 #define TLS_PARAM_ID_SNTP_SERVER2 (52) 145 #define TLS_PARAM_ID_SNTP_SERVER3 (53) 146 #define TLS_PARAM_ID_TEM_OFFSET (54) 147 148 /** BT&BLE param */ 149 #define TLS_PARAM_ID_BT_ADAPTER (55) 150 #define TLS_PARAM_ID_BT_REMOTE_DEVICE_1 (56) 151 #define TLS_PARAM_ID_BT_REMOTE_DEVICE_2 (57) 152 #define TLS_PARAM_ID_BT_REMOTE_DEVICE_3 (58) 153 154 #define TLS_PARAM_ID_BT_REMOTE_DEVICE_4 (59) 155 #define TLS_PARAM_ID_BT_REMOTE_DEVICE_5 (60) 156 #define TLS_PARAM_ID_BT_REMOTE_DEVICE_6 (61) 157 #define TLS_PARAM_ID_BT_REMOTE_DEVICE_7 (62) 158 #define TLS_PARAM_ID_BT_REMOTE_DEVICE_8 (63) 159 #define TLS_PARAM_ID_BT_REMOTE_DEVICE_9 (64) 160 #define TLS_PARAM_ID_BT_REMOTE_DEVICE_10 (65) 161 162 #define TLS_PARAM_ID_MAX (66) 163 164 /** MACRO of Physical moe of Ieee802.11 */ 165 #define TLS_PARAM_PHY_11BG_MIXED (0) 166 #define TLS_PARAM_PHY_11B (1) 167 #define TLS_PARAM_PHY_11BGN_MIXED (2) 168 /** MACRO of Ieee802.11 Tx Rate for parameter set */ 169 #define TLS_PARAM_TX_RATEIDX_1M (0) 170 #define TLS_PARAM_TX_RATEIDX_2M (1) 171 #define TLS_PARAM_TX_RATEIDX_5_5M (2) 172 #define TLS_PARAM_TX_RATEIDX_11M (3) 173 #define TLS_PARAM_TX_RATEIDX_6M (4) 174 #define TLS_PARAM_TX_RATEIDX_9M (5) 175 #define TLS_PARAM_TX_RATEIDX_12M (6) 176 #define TLS_PARAM_TX_RATEIDX_18M (7) 177 #define TLS_PARAM_TX_RATEIDX_24M (8) 178 #define TLS_PARAM_TX_RATEIDX_36M (9) 179 #define TLS_PARAM_TX_RATEIDX_48M (10) 180 #define TLS_PARAM_TX_RATEIDX_54M (11) 181 #define TLS_PARAM_TX_RATEIDX_MCS0 (12) 182 #define TLS_PARAM_TX_RATEIDX_MCS1 (13) 183 #define TLS_PARAM_TX_RATEIDX_MCS2 (14) 184 #define TLS_PARAM_TX_RATEIDX_MCS3 (15) 185 #define TLS_PARAM_TX_RATEIDX_MCS4 (16) 186 #define TLS_PARAM_TX_RATEIDX_MCS5 (17) 187 #define TLS_PARAM_TX_RATEIDX_MCS6 (18) 188 #define TLS_PARAM_TX_RATEIDX_MCS7 (19) 189 #define TLS_PARAM_TX_RATEIDX_MCS8 (20) 190 #define TLS_PARAM_TX_RATEIDX_MCS9 (21) 191 #define TLS_PARAM_TX_RATEIDX_MCS10 (22) 192 #define TLS_PARAM_TX_RATEIDX_MCS11 (23) 193 #define TLS_PARAM_TX_RATEIDX_MCS12 (24) 194 #define TLS_PARAM_TX_RATEIDX_MCS13 (25) 195 #define TLS_PARAM_TX_RATEIDX_MCS14 (26) 196 #define TLS_PARAM_TX_RATEIDX_MCS15 (27) 197 #define TLS_PARAM_TX_RATEIDX_MCS32 (28) 198 199 /** MACRO of SSID Broadcast */ 200 #define TLS_PARAM_SSIDBRD_DISABLE (0) 201 #define TLS_PARAM_SSIDBRD_ENABLE (1) 202 203 #define TLS_PARAM_ROAM_DISABLE (0) 204 #define TLS_PARAM_ROAM_ENABLE (1) 205 206 /** MACRO of Power Saving Mode */ 207 #define TLS_PARAM_PSM_DISABLE (0) 208 #define TLS_PARAM_PSM_ENABLE (1) 209 210 #define TLS_PARAM_DDNS_DISABLE (0) 211 #define TLS_PARAM_DDNS_ENABLE (1) 212 213 #define TLS_PARAM_AUTO_CREATE_ADHOC_DISABLE (0) 214 #define TLS_PARAM_AUTO_CREATE_ADHOC_ENABLE (1) 215 216 #define TLS_PARAM_WPS_DISABLE (0) 217 #define TLS_PARAM_WPS_ENABLE (1) 218 #define TLS_PARAM_WPS_MODE_PIN (0) 219 #define TLS_PARAM_WPS_MODE_PBC (1) 220 #define TLS_PARAM_WPS_FLAG_NEGOTIATED (1 << 0) 221 222 #define TLS_PARAM_UPNP_DISABLE (0) 223 #define TLS_PARAM_UPNP_ENABLE (1) 224 225 /** MACRO of IEEE802.11 Work MODE */ 226 #define TLS_PARAM_IEEE80211_INFRA (1) 227 #define TLS_PARAM_IEEE80211_ADHOC (2) 228 #define TLS_PARAM_IEEE80211_SOFTAP (4) 229 230 /** MACRO of Command or Transparent Mode */ 231 #define TLS_PARAM_MANUAL_MODE (0) 232 #define TLS_PARAM_AUTO_MODE (1) 233 234 #define TLS_PARAM_ALWAYS_ONLINE_ENABLE (1) 235 #define TLS_PARAM_ALWAYS_ONLINE_DISABLE (0) 236 237 /** MACRO of DHCP ENABLE or DISABLE */ 238 #define TLS_PARAM_DHCP_ENABLE (1) 239 #define TLS_PARAM_DHCP_DISABLE (0) 240 241 /** MACRO of COUNTRY CODE for channel number */ 242 #define TLS_PARAM_REGION_0_BG_BAND (0) /* 1-11 */ 243 #define TLS_PARAM_REGION_1_BG_BAND (1) /* 1-13 */ 244 #define TLS_PARAM_REGION_2_BG_BAND (2) /* 10-11 */ 245 #define TLS_PARAM_REGION_3_BG_BAND (3) /* 10-13 */ 246 #define TLS_PARAM_REGION_4_BG_BAND (4) /* 14 */ 247 #define TLS_PARAM_REGION_5_BG_BAND (5) /* 1-14 */ 248 #define TLS_PARAM_REGION_6_BG_BAND (6) /* 3-9 */ 249 #define TLS_PARAM_REGION_7_BG_BAND (7) /* 5-13 */ 250 #define TLS_PARAM_REGION_MAXIMUM_BG_BAND TLS_PARAM_REGION_7_BG_BAND 251 252 /** MACRO of ENCRYPT TYPE */ 253 #define TLS_PARAM_ENCRY_OPEN (0) 254 #define TLS_PARAM_ENCRY_WEP64 (1) 255 #define TLS_PARAM_ENCRY_WEP128 (2) 256 #define TLS_PARAM_ENCRY_WPA_PSK_TKIP (3) 257 #define TLS_PARAM_ENCRY_WPA_PSK_AES (4) 258 #define TLS_PARAM_ENCRY_WPA2_PSK_TKIP (5) 259 #define TLS_PARAM_ENCRY_WPA2_PSK_AES (6) 260 261 /** MACRO of USER INTERFACE TYPE */ 262 #define TLS_PARAM_USR_INTF_LUART (0) 263 #define TLS_PARAM_USR_INTF_HUART (1) 264 #define TLS_PARAM_USR_INTF_HSPI (2) 265 #define TLS_PARAM_USR_INTF_HSDIO (3) 266 267 /** MACRO of UART BAUDRATE */ 268 #define TLS_PARAM_UART_BAUDRATE_B600 (600) 269 #define TLS_PARAM_UART_BAUDRATE_B1200 (1200) 270 #define TLS_PARAM_UART_BAUDRATE_B1800 (1800) 271 #define TLS_PARAM_UART_BAUDRATE_B2400 (2400) 272 #define TLS_PARAM_UART_BAUDRATE_B4800 (4800) 273 #define TLS_PARAM_UART_BAUDRATE_B9600 (9600) 274 #define TLS_PARAM_UART_BAUDRATE_B19200 (19200) 275 #define TLS_PARAM_UART_BAUDRATE_B38400 (38400) 276 #define TLS_PARAM_UART_BAUDRATE_B57600 (57600) 277 #define TLS_PARAM_UART_BAUDRATE_B115200 (115200) 278 #define TLS_PARAM_HUART_BAUDRATE_B230400 (230400) 279 #define TLS_PARAM_HUART_BAUDRATE_B460800 (460800) 280 #define TLS_PARAM_HUART_BAUDRATE_B921600 (921600) 281 #define TLS_PARAM_HUART_BAUDRATE_B1000000 (1000000) 282 #define TLS_PARAM_HUART_BAUDRATE_B1250000 (1250000) 283 #define TLS_PARAM_HUART_BAUDRATE_B1500000 (1500000) 284 #define TLS_PARAM_HUART_BAUDRATE_B2000000 (2000000) 285 286 /** MACRO of UART PARITY */ 287 #define TLS_PARAM_UART_PARITY_NONE (0) 288 #define TLS_PARAM_UART_PARITY_EVEN (1) 289 #define TLS_PARAM_UART_PARITY_ODD (2) 290 #define TLS_PARAM_UART_PARITY_MARK (3) 291 #define TLS_PARAM_UART_PARITY_SPACE (4) 292 293 /** MACRO of UART STOP BITS */ 294 #define TLS_PARAM_UART_STOPBITS_1BITS (0) 295 #define TLS_PARAM_UART_STOPBITS_2BITS (1) 296 297 /** MACRO of UART FLOW CONTROL */ 298 #define TLS_PARAM_UART_FLOW_DISABLE (0) 299 #define TLS_PARAM_UART_FLOW_ENABLE (1) 300 #define TLS_PARAM_HSPI_MAX_SCLK (33000000) 301 /** MACRO of SOCKET PARAMETER */ 302 #define TLS_PARAM_SOCKET_TCP (0) 303 #define TLS_PARAM_SOCKET_UDP (1) 304 #define TLS_PARAM_SOCKET_CLIENT (0) 305 #define TLS_PARAM_SOCKET_SERVER (1) 306 #define TLS_PARAM_SOCKET_DEFAULT_PORT (60000) 307 308 /** Structure of hardware parameter */ 309 struct tls_param_hardware_version { 310 u8 mark; 311 u8 main; 312 u8 sub; 313 u8 material; 314 u8 year; 315 u8 week; 316 u8 res[2]; 317 }; 318 319 /** Structure of specified BSSID parameter */ 320 struct tls_param_bssid { 321 u8 bssid_enable; 322 u8 res; 323 u8 bssid[6]; 324 }; 325 326 /** Structure of SSID parameter */ 327 struct tls_param_ssid { 328 u8 ssid[32]; 329 u32 ssid_len; 330 }; 331 332 /** Structure of TEM parameter */ 333 struct tls_param_tem_offset { 334 u8 offset_len; 335 s32 offset; 336 }; 337 338 /** Structure of KEY parameter */ 339 struct tls_param_key { 340 u8 psk[64]; 341 u8 key_length; 342 u8 key_index; 343 u8 key_format; 344 u8 res; 345 }; 346 347 /** Structure of original KEY parameter */ 348 struct tls_param_original_key { 349 u8 psk[64]; 350 u32 key_length; 351 }; 352 353 /** Structure of SHA1 KEY parameter */ 354 struct tls_param_sha1 { 355 u8 psk_set; 356 u8 psk[32]; 357 }; 358 359 /** Structure of 802.11 bgn rate parameter */ 360 struct tls_param_bgr { 361 u8 bg; 362 u8 max_rate; 363 u8 res[2]; 364 }; 365 366 /** Structure of IP parameter */ 367 struct tls_param_ip { 368 u8 dhcp_enable; 369 u8 res[3]; 370 u8 ip[4]; 371 u8 netmask[4]; 372 u8 gateway[4]; 373 u8 dns1[4]; 374 u8 dns2[4]; 375 }; 376 377 /** Structure of uart parameter */ 378 struct tls_param_uart { 379 u32 baudrate; 380 u8 stop_bits; 381 u8 parity; 382 u8 flow; 383 u8 charsize; 384 }; 385 386 /** Structure of socket parameter */ 387 struct tls_param_socket { 388 u8 protocol; 389 u8 client_or_server; 390 u16 port_num; 391 u8 host[32]; 392 }; 393 394 struct tls_param_wps { 395 u8 wps_enable; 396 u8 mode; 397 u8 flag; 398 u8 res; 399 u8 pin[8]; 400 }; 401 402 /** Structure of oray client */ 403 struct tls_param_oray_client { 404 u32 oray_client_enable; 405 u8 oray_client_user[32]; 406 u8 oray_client_pass[32]; 407 }; 408 409 /** Structure of web server parameter */ 410 struct tls_webs_cfg { 411 u8 AutoRun; 412 u8 Reserved; 413 u16 PortNum; 414 }; 415 416 /** Structure of user default parameter */ 417 typedef struct tls_user_param { 418 u8 wireless_protocol; 419 u8 auto_mode; 420 u8 dhcp_enable; 421 u8 user_port_mode; 422 423 u8 ip[4]; 424 u8 netmask[4]; 425 u8 gateway[4]; 426 u8 dns[4]; 427 428 u32 baudrate; 429 430 u8 socket_protocol; 431 u8 socket_client_or_server; 432 u16 socket_port_num; 433 u8 socket_host[32]; 434 u8 auto_powersave; 435 u8 PassWord[6]; 436 }ST_Wm_User_Param; 437 typedef struct { 438 u32 valid_tag; /* 0xdeadbeaf means valid */ 439 u32 valid_bit; 440 u8 bd_addr[6]; /* Local Address */ 441 uint8_t name_len; 442 u8 name[16]; /* Local Name */ 443 u32 class_of_device; /* Class of Device */ 444 u8 io_cap; 445 u8 discoverable; 446 u8 connectable; 447 u8 bt_auth_req; 448 u8 mode; /* Adv, Initiator, ...... */ 449 u8 ble_auth_req; 450 u8 ir[16]; 451 u8 irk[16]; 452 u8 dhk[16]; 453 u8 er[16]; 454 } bt_adapter_t; 455 456 typedef struct { 457 u32 valid_tag; /* 0xdeadbeaf means valid */ 458 u8 in_use; 459 u32 valid_bit; 460 u8 bd_addr[6]; 461 u8 name[16]; 462 u8 name_len; 463 u32 class_of_device; 464 u32 available_service; 465 u8 link_key[16]; 466 u8 key_type; 467 u8 io_cap; 468 u8 pin_length; 469 u8 device_type; 470 u8 reconnect_needed; 471 u8 ble_addr_type; 472 /* KEY_PENC */ 473 u8 key_penc[28]; 474 /* KEY_PID */ 475 u8 key_pid[23]; 476 /* KEY_PID */ 477 u8 key_lid[23]; 478 /* KEY_PCSRK */ 479 u8 key_pcsrk[24]; 480 /* KEY_LCSRK */ 481 u8 key_lcsrk[24]; 482 /* KEY_LENC */ 483 u8 key_lenc[20]; 484 u32 manufacturer; 485 u32 lmpver; 486 u32 lmpsubver; 487 } bt_remote_device_t; 488 489 /** 490 * @defgroup System_APIs System APIs 491 * @brief System APIs 492 */ 493 494 /** 495 * @addtogroup System_APIs 496 * @{ 497 */ 498 499 /** 500 * @defgroup Param_APIs Param APIs 501 * @brief Param manager APIs 502 */ 503 504 /** 505 * @addtogroup Param_APIs 506 * @{ 507 */ 508 509 /** 510 * @brief This function is used to initialize parameter's manage module 511 * 512 * @param[in] None 513 * 514 * @retval TLS_PARAM_STATUS_OK init success 515 * @retval TLS_PARAM_STATUS_EMEM memory error 516 * @retval TLS_PARAM_STATUS_EIO io error 517 * @retval TLS_PARAM_STATUS_EPERM magic number error 518 * 519 * @note None 520 */ 521 int tls_param_init(void); 522 523 /** 524 * @brief This function is used to load the system's default 525 parameters 526 * 527 * @param[in] None 528 * 529 * @return None 530 * 531 * @note This function read user defined parameters first, 532 if wrong, all the parameters restore factory settings 533 */ 534 void tls_param_load_factory_default(void); 535 536 /** 537 * @brief This function is used to set one system parameter by its id 538 * 539 * @param[in] id param id,from TLS_PARAM_ID_SSID 540 to (TLS_PARAM_ID_MAX - 1) 541 * @param[in] *argv store parameters 542 * @param[in] to_flash whether the parameter is written to flash, 543 1:write to flash,0:only write memory 544 * 545 * @retval TLS_PARAM_STATUS_OK set success 546 * @retval TLS_PARAM_STATUS_EINVALID invalid param 547 * 548 * @note None 549 */ 550 int tls_param_set(int id, void *argv, bool to_flash); 551 552 /** 553 * @brief This function is used to get one system parameter by its id. 554 * 555 * @param[in] id param id,from TLS_PARAM_ID_SSID 556 to (TLS_PARAM_ID_MAX - 1) 557 * @param[in] *argv store parameters 558 * @param[in] from_flash whether the parameter is readed from flash, 559 1 read from flash,0 read from memory 560 * 561 * @retval TLS_PARAM_STATUS_OK success 562 * @retval TLS_PARAM_STATUS_EINVALID invalid param 563 * 564 * @note None 565 */ 566 int tls_param_get(int id, void *argv, bool from_flash); 567 568 /** 569 * @brief This function is used to write parameter into flash 570 * 571 * @param[in] id param id,from TLS_PARAM_ID_ALL 572 to (TLS_PARAM_ID_MAX - 1) 573 * 574 * @retval TLS_PARAM_STATUS_OK success 575 * @retval TLS_PARAM_STATUS_EINVALID invalid param 576 * @retval TLS_PARAM_STATUS_EIO read or write flash error 577 * 578 * @note None 579 */ 580 int tls_param_to_flash(int id); 581 582 /** 583 * @brief This function is used to recovery the parameters from 584 the backup area to the parameter area,and load them into ram 585 * 586 * @param[in] None 587 * 588 * @return None 589 * 590 * @note None 591 */ 592 void tls_restore_param_from_backup(void); 593 594 /** 595 * @brief This function is used to load default parametes into ram 596 597 * 598 * @param[in] None 599 * 600 * @retval TLS_PARAM_STATUS_OK set success 601 * @retval TLS_PARAM_STATUS_EINVALID parameter wrong 602 * @retval TLS_PARAM_STATUS_EIO read or write falsh error 603 * 604 * @note This function read user defined parameters first, 605 if wrong, all the parameters restore factory settings 606 */ 607 int tls_param_to_default(void); 608 609 /** 610 * @brief This function is used to write user's parameters into the 611 flash 612 * 613 * @param[in] None 614 * 615 * @retval TLS_PARAM_STATUS_OK success 616 * @retval other failed 617 * 618 * @note None 619 */ 620 int tls_param_save_user_default(void); 621 622 /** 623 * @brief This function is used to modify user's default parameters, 624 then write them into flash 625 * 626 * @param[in] *user_param 627 * 628 * @retval TLS_PARAM_STATUS_OK success 629 * @retval other failed 630 * 631 * @note None 632 */ 633 int tls_param_save_user(struct tls_user_param *user_param); 634 635 /** 636 * @brief This function is used to get updp mode.(updp:update user 637 default parameters) 638 * 639 * @param[in] None 640 * 641 * @retval update mode 642 * 643 * @note None 644 */ 645 u8 tls_param_get_updp_mode(void); 646 647 /** 648 * @brief This function is used to set updp mode 649 * 650 * @param[in] mode 651 * 652 * @return None 653 * 654 * @note None 655 */ 656 void tls_param_set_updp_mode(u8 mode); 657 658 /** 659 * @brief This function is used to get program param 660 * 661 * @param[in] *pBase pointer to save base address 662 * 663 * @retval 0 success 664 * @retval other failed 665 * 666 * @note None 667 */ 668 int tls_param_get_program_param(u32 *pBase); 669 670 /** 671 * @brief This function is used to set program base,image len,and 672 checksum 673 * 674 * @param[in] base base address 675 * @param[in] totallen total length of the image 676 * @param[in] checksum checksum value of the image 677 * 678 * @retval 0 success 679 * @retval other failed 680 * 681 * @note None 682 */ 683 int tls_param_set_program_param(u32 base, u32 totallen, u32 checksum); 684 685 /** 686 * @} 687 */ 688 689 /** 690 * @} 691 */ 692 693 #endif /* WM_PARAM_H */