1 /* 2 * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., 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 #ifndef APP_SMARTCONFIG_H_ 16 #define APP_SMARTCONFIG_H_ 17 18 #include "ble_ip_config.h" // SW configuration 19 20 #if (BLE_APP_SMARTCONFIG) 21 22 #include <stdint.h> // Standard Integer Definition 23 #include "ble_ke_task.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 enum 30 { 31 NO_ERROR = 0, 32 WIFI_ERR, 33 TIME_ERR, 34 }; 35 36 #define INVALID_CONNECTION_INDEX 0xFF 37 38 /// Smartconfig Application Module Environment Structure 39 struct app_smartconfig_env_tag 40 { 41 /// Connection handle 42 uint8_t conidx; 43 uint8_t wifi_state_ntf_en; 44 uint8_t time_state_ntf_en; 45 }; 46 47 #define DATA_BUF_SIZE 32 48 49 struct ble_smartconfig { 50 /// SSID 51 char ssid[DATA_BUF_SIZE]; 52 /// Keyphrase 53 char pwd[DATA_BUF_SIZE]; 54 //current time 55 char time[DATA_BUF_SIZE]; 56 }; 57 58 /// Table of message handlers 59 extern const struct app_subtask_handlers app_smartconfig_handlers; 60 61 typedef void(*app_smartconfig_recv_ap_info_cb)(uint8_t *data, uint32_t length); 62 typedef void(*app_smartconfig_recv_state_info_cb)(uint8_t *data, uint32_t length); 63 64 void app_smartconfig_init(void); 65 66 void app_smartconfig_enable_prf(uint8_t conidx); 67 68 void app_smartconfig_add_smartconfig(void); 69 70 void app_smartconfig_disconnected(void); 71 72 void app_smartconfig_send_rsp(uint8_t* data, uint32_t length); 73 74 void app_smartconfig_register_ap_info_cb(app_smartconfig_recv_ap_info_cb callback); 75 void app_smartconfig_register_state_info_cb(app_smartconfig_recv_state_info_cb callback); 76 77 78 #ifdef __cplusplus 79 } 80 #endif 81 82 #endif //(BLE_APP_SMARTCONFIG) 83 84 #endif // APP_SMARTCONFIG_H_ 85