mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
函数名改为驼峰式-1
This commit is contained in:
@@ -46,7 +46,7 @@ static bool is_http_init;
|
||||
static bool is_handlers_registered;
|
||||
struct httpd_wsgi_call g_app_handlers[];
|
||||
|
||||
static int http_get_index_page(httpd_request_t *req)
|
||||
static int HttpGetIndexPage(httpd_request_t *req)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
|
||||
@@ -60,7 +60,7 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int http_get_tc1_status(httpd_request_t *req)
|
||||
static int HttpGetTc1Status(httpd_request_t *req)
|
||||
{
|
||||
const unsigned char* sockets = get_socket_status();
|
||||
char* ap_name = "TC1-AP";
|
||||
@@ -81,7 +81,7 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int http_set_socket_status(httpd_request_t *req)
|
||||
static int HttpSetSocketStatus(httpd_request_t *req)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
|
||||
@@ -100,7 +100,7 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int http_get_wifi_config(httpd_request_t *req)
|
||||
static int HttpGetWifiConfig(httpd_request_t *req)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
const unsigned char* status = get_socket_status();
|
||||
@@ -109,7 +109,7 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int http_set_wifi_config(httpd_request_t *req)
|
||||
static int HttpSetWifiConfig(httpd_request_t *req)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
|
||||
@@ -123,7 +123,7 @@ static int http_set_wifi_config(httpd_request_t *req)
|
||||
|
||||
sscanf(buf, "%s %s", wifi_ssid, wifi_key);
|
||||
|
||||
wifi_connect(wifi_ssid, wifi_key);
|
||||
WifiConnect(wifi_ssid, wifi_key);
|
||||
|
||||
send_http("OK", 2, exit, &err);
|
||||
|
||||
@@ -134,7 +134,7 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int http_get_wifi_scan(httpd_request_t *req)
|
||||
static int HttpGetWifiScan(httpd_request_t *req)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
if (scaned)
|
||||
@@ -152,7 +152,7 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int http_set_wifi_scan(httpd_request_t *req)
|
||||
static int HttpSetWifiScan(httpd_request_t *req)
|
||||
{
|
||||
micoWlanStartScanAdv();
|
||||
OSStatus err = kNoErr;
|
||||
@@ -162,16 +162,16 @@ exit:
|
||||
}
|
||||
|
||||
struct httpd_wsgi_call g_app_handlers[] = {
|
||||
{"/", HTTPD_HDR_DEFORT, 0, http_get_index_page, NULL, NULL, NULL},
|
||||
{"/socket", HTTPD_HDR_DEFORT, 0, NULL, http_set_socket_status, NULL, NULL},
|
||||
{"/status", HTTPD_HDR_DEFORT, 0, http_get_tc1_status, NULL, NULL, NULL},
|
||||
{"/wifi/config", HTTPD_HDR_DEFORT, 0, http_get_wifi_config, http_set_wifi_config, NULL, NULL},
|
||||
{"/wifi/scan", HTTPD_HDR_DEFORT, 0, http_get_wifi_scan, http_set_wifi_scan, NULL, NULL},
|
||||
{"/", HTTPD_HDR_DEFORT, 0, HttpGetIndexPage, NULL, NULL, NULL},
|
||||
{"/socket", HTTPD_HDR_DEFORT, 0, NULL, HttpSetSocketStatus, NULL, NULL},
|
||||
{"/status", HTTPD_HDR_DEFORT, 0, HttpGetTc1Status, NULL, NULL, NULL},
|
||||
{"/wifi/config", HTTPD_HDR_DEFORT, 0, HttpGetWifiConfig, HttpSetWifiConfig, NULL, NULL},
|
||||
{"/wifi/scan", HTTPD_HDR_DEFORT, 0, HttpGetWifiScan, HttpSetWifiScan, NULL, NULL},
|
||||
};
|
||||
|
||||
static int g_app_handlers_no = sizeof(g_app_handlers)/sizeof(struct httpd_wsgi_call);
|
||||
|
||||
static void app_http_register_handlers()
|
||||
static void AppHttpRegisterHandlers()
|
||||
{
|
||||
int rc;
|
||||
rc = httpd_register_wsgi_handlers(g_app_handlers, g_app_handlers_no);
|
||||
@@ -180,7 +180,7 @@ static void app_http_register_handlers()
|
||||
}
|
||||
}
|
||||
|
||||
static int _app_httpd_start()
|
||||
static int _AppHttpdStart()
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
app_httpd_log("initializing web-services");
|
||||
@@ -202,15 +202,15 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
int app_httpd_start(void)
|
||||
int AppHttpdStart(void)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
|
||||
err = _app_httpd_start();
|
||||
err = _AppHttpdStart();
|
||||
require_noerr(err, exit);
|
||||
|
||||
if (is_handlers_registered == false) {
|
||||
app_http_register_handlers();
|
||||
AppHttpRegisterHandlers();
|
||||
is_handlers_registered = true;
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
int app_httpd_stop()
|
||||
int AppHttpdStop()
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@
|
||||
'gateway':'%s'\
|
||||
}"
|
||||
|
||||
int app_httpd_start(void);
|
||||
|
||||
int app_httpd_stop();
|
||||
int AppHttpdStart(void);
|
||||
int AppHttpdStop();
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ int application_start(void)
|
||||
if (!MicoGpioInputGet(Button))
|
||||
{ //开机时按钮状态
|
||||
os_log("press ap_init");
|
||||
ap_init();
|
||||
ApInit();
|
||||
}
|
||||
|
||||
MicoGpioInitialize((mico_gpio_t) Led, OUTPUT_PUSH_PULL);
|
||||
@@ -146,14 +146,14 @@ int application_start(void)
|
||||
// }
|
||||
// }
|
||||
|
||||
wifi_init();
|
||||
StationInit();
|
||||
if (sys_config->micoSystemConfig.reserved != NOTIFY_STATION_UP)
|
||||
{
|
||||
ap_init();
|
||||
ApInit();
|
||||
}
|
||||
else
|
||||
{
|
||||
wifi_connect(sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key);
|
||||
WifiConnect(sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key);
|
||||
}
|
||||
user_udp_init();
|
||||
key_init();
|
||||
|
||||
@@ -12,28 +12,8 @@ char wifi_status = WIFI_STATE_NOCONNECT;
|
||||
|
||||
mico_timer_t wifi_led_timer;
|
||||
|
||||
/*
|
||||
static void wifi_connect_sys_config(void)
|
||||
{
|
||||
if (strlen(sys_config->micoSystemConfig.ssid) > 0)
|
||||
{
|
||||
os_log("connect ssid:%s key:%s",sys_config->micoSystemConfig.ssid,sys_config->micoSystemConfig.user_key);
|
||||
network_InitTypeDef_st wNetConfig;
|
||||
memset(&wNetConfig, 0, sizeof(network_InitTypeDef_st));
|
||||
strcpy(wNetConfig.wifi_ssid, sys_config->micoSystemConfig.ssid);
|
||||
strcpy(wNetConfig.wifi_key, sys_config->micoSystemConfig.user_key);
|
||||
wNetConfig.wifi_mode = Station;
|
||||
wNetConfig.dhcpMode = DHCP_Client;
|
||||
wNetConfig.wifi_retry_interval = 6000;
|
||||
micoWlanStart(&wNetConfig);
|
||||
wifi_status = WIFI_STATE_CONNECTING;
|
||||
} else
|
||||
wifi_status = WIFI_STATE_FAIL;
|
||||
}
|
||||
*/
|
||||
|
||||
//wifi已连接获取到IP地址回调
|
||||
static void wifi_get_ip_callback(IPStatusTypedef *pnet, void * arg)
|
||||
static void WifiGetIpCallback(IPStatusTypedef *pnet, void * arg)
|
||||
{
|
||||
os_log("got IP:%s", pnet->ip);
|
||||
wifi_status = WIFI_STATE_CONNECTED;
|
||||
@@ -41,7 +21,7 @@ static void wifi_get_ip_callback(IPStatusTypedef *pnet, void * arg)
|
||||
}
|
||||
|
||||
//wifi连接状态改变回调
|
||||
static void wifi_status_callback(WiFiEvent status, void* arg)
|
||||
static void WifiStatusCallback(WiFiEvent status, void* arg)
|
||||
{
|
||||
if (status == NOTIFY_STATION_UP) //wifi连接成功
|
||||
{
|
||||
@@ -76,7 +56,7 @@ static void wifi_status_callback(WiFiEvent status, void* arg)
|
||||
bool scaned = false;
|
||||
char* wifi_ret = NULL;
|
||||
//wifi扫描结果回调
|
||||
void wifi_scan_callback(ScanResult_adv* scan_ret, void* arg)
|
||||
void WifiScanCallback(ScanResult_adv* scan_ret, void* arg)
|
||||
{
|
||||
int count = (int)scan_ret->ApNum;
|
||||
os_log("wifi_scan_callback ApNum[%d] ApList[0](%s)", count, scan_ret->ApList[0].ssid);
|
||||
@@ -108,7 +88,7 @@ void wifi_scan_callback(ScanResult_adv* scan_ret, void* arg)
|
||||
|
||||
|
||||
//100ms定时器回调
|
||||
static void wifi_led_timer_callback(void* arg)
|
||||
static void WifiLedTimerCallback(void* arg)
|
||||
{
|
||||
static unsigned int num = 0;
|
||||
num++;
|
||||
@@ -138,7 +118,7 @@ static void wifi_led_timer_callback(void* arg)
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_connect(char* wifi_ssid, char* wifi_key)
|
||||
void WifiConnect(char* wifi_ssid, char* wifi_key)
|
||||
{
|
||||
//wifi配置初始化
|
||||
network_InitTypeDef_st wNetConfig;
|
||||
@@ -159,16 +139,16 @@ void wifi_connect(char* wifi_ssid, char* wifi_key)
|
||||
wifi_status = WIFI_STATE_NOCONNECT;
|
||||
}
|
||||
|
||||
void wifi_init(void)
|
||||
void StationInit(void)
|
||||
{
|
||||
//wifi状态下led闪烁定时器初始化
|
||||
mico_rtos_init_timer(&wifi_led_timer, 100, (void *) wifi_led_timer_callback, NULL);
|
||||
mico_rtos_init_timer(&wifi_led_timer, 100, (void *) WifiLedTimerCallback, NULL);
|
||||
//wifi已连接获取到IP地址 回调
|
||||
mico_system_notify_register(mico_notify_DHCP_COMPLETED, (void *) wifi_get_ip_callback, NULL);
|
||||
mico_system_notify_register(mico_notify_DHCP_COMPLETED, (void *)WifiGetIpCallback, NULL);
|
||||
//wifi连接状态改变回调
|
||||
mico_system_notify_register(mico_notify_WIFI_STATUS_CHANGED, (void*) wifi_status_callback, NULL);
|
||||
mico_system_notify_register(mico_notify_WIFI_STATUS_CHANGED, (void*) WifiStatusCallback, NULL);
|
||||
//wifi扫描结果回调
|
||||
mico_system_notify_register(mico_notify_WIFI_SCAN_ADV_COMPLETED, (void*)wifi_scan_callback, NULL);
|
||||
mico_system_notify_register(mico_notify_WIFI_SCAN_ADV_COMPLETED, (void*)WifiScanCallback, NULL);
|
||||
|
||||
//sntp_init();
|
||||
//启动定时器开始进行wifi连接
|
||||
@@ -186,7 +166,7 @@ void wifi_init(void)
|
||||
#define ELAND_AP_DNS_SERVER "192.168.0.1"
|
||||
#define ELAND_AP_NET_MASK "255.255.255.0"
|
||||
|
||||
void ap_init()
|
||||
void ApInit()
|
||||
{
|
||||
os_log("Soft_ap_Server");
|
||||
network_InitTypeDef_st wNetConfig;
|
||||
|
||||
@@ -19,8 +19,8 @@ extern char* wifi_ret;
|
||||
|
||||
extern char wifi_status;
|
||||
|
||||
extern void wifi_init(void);
|
||||
extern void ap_init(void);
|
||||
extern void wifi_connect(char* wifi_ssid, char* wifi_key);
|
||||
extern void StationInit(void);
|
||||
extern void ApInit(void);
|
||||
extern void WifiConnect(char* wifi_ssid, char* wifi_key);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user