函数名驼峰式-2

This commit is contained in:
zogodo
2019-10-09 18:12:20 +08:00
parent ec4eef27e4
commit 58eec84eec
8 changed files with 54 additions and 54 deletions

View File

@@ -62,7 +62,7 @@ exit:
static int HttpGetTc1Status(httpd_request_t *req) static int HttpGetTc1Status(httpd_request_t *req)
{ {
const unsigned char* sockets = get_socket_status(); const unsigned char* sockets = GetSocketStatus();
char* ap_name = "TC1-AP"; char* ap_name = "TC1-AP";
char* ap_pwd = "12345678"; char* ap_pwd = "12345678";
char* ip = "192.168.33.222"; char* ip = "192.168.33.222";
@@ -91,7 +91,7 @@ static int HttpSetSocketStatus(httpd_request_t *req)
err = httpd_get_data(req, buf, buf_size); err = httpd_get_data(req, buf, buf_size);
require_noerr(err, exit); require_noerr(err, exit);
set_socket_status(buf); SetSocketStatus(buf);
send_http("OK", 2, exit, &err); send_http("OK", 2, exit, &err);
@@ -103,7 +103,7 @@ exit:
static int HttpGetWifiConfig(httpd_request_t *req) static int HttpGetWifiConfig(httpd_request_t *req)
{ {
OSStatus err = kNoErr; OSStatus err = kNoErr;
const unsigned char* status = get_socket_status(); const unsigned char* status = GetSocketStatus();
send_http(status, strlen(status), exit, &err); send_http(status, strlen(status), exit, &err);
exit: exit:
return err; return err;

View File

@@ -100,7 +100,7 @@ int application_start(void)
for (i = 0; i < Relay_NUM; i++) for (i = 0; i < Relay_NUM; i++)
{ {
MicoGpioInitialize(Relay[i], OUTPUT_PUSH_PULL); MicoGpioInitialize(Relay[i], OUTPUT_PUSH_PULL);
user_relay_set(i, user_config->plug[i].on); UserRelaySet(i, user_config->plug[i].on);
} }
MicoSysLed(0); MicoSysLed(0);
@@ -156,7 +156,7 @@ int application_start(void)
WifiConnect(sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key); WifiConnect(sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key);
} }
user_udp_init(); user_udp_init();
key_init(); KeyInit();
err = user_mqtt_init(); err = user_mqtt_init();
require_noerr(err, exit); require_noerr(err, exit);
err = user_rtc_init(); err = user_rtc_init();

View File

@@ -236,7 +236,7 @@ bool json_plug_analysis(int udp_flag, unsigned char x, cJSON * pJsonRoot, cJSON
{ {
if (cJSON_IsNumber(p_plug_on)) if (cJSON_IsNumber(p_plug_on))
{ {
user_relay_set(x, p_plug_on->valueint); UserRelaySet(x, p_plug_on->valueint);
return_flag = true; return_flag = true;
} }
user_mqtt_send_plug_state(x); user_mqtt_send_plug_state(x);

View File

@@ -8,7 +8,7 @@
mico_gpio_t relay[Relay_NUM] = { Relay_0, Relay_1, Relay_2, Relay_3, Relay_4, Relay_5 }; mico_gpio_t relay[Relay_NUM] = { Relay_0, Relay_1, Relay_2, Relay_3, Relay_4, Relay_5 };
void user_led_set(char x) void UserLedSet(char x)
{ {
if (x == -1) if (x == -1)
MicoGpioOutputTrigger(Led); MicoGpioOutputTrigger(Led);
@@ -18,7 +18,7 @@ void user_led_set(char x)
MicoGpioOutputLow(Led); MicoGpioOutputLow(Led);
} }
bool relay_out(void) bool RelayOut(void)
{ {
int i; int i;
for (i = 0; i < PLUG_NUM; i++) for (i = 0; i < PLUG_NUM; i++)
@@ -31,7 +31,7 @@ bool relay_out(void)
return false; return false;
} }
const unsigned char* get_socket_status() const unsigned char* GetSocketStatus()
{ {
sprintf(socket_status, "%d,%d,%d,%d,%d,%d", sprintf(socket_status, "%d,%d,%d,%d,%d,%d",
user_config->plug[0].on, user_config->plug[0].on,
@@ -43,7 +43,7 @@ const unsigned char* get_socket_status()
return (const unsigned char*)socket_status; return (const unsigned char*)socket_status;
} }
void set_socket_status(char* socket_status) void SetSocketStatus(char* socket_status)
{ {
int ons[6] = { 0 }; int ons[6] = { 0 };
sscanf(socket_status, "%d,%d,%d,%d,%d,%d,", sscanf(socket_status, "%d,%d,%d,%d,%d,%d,",
@@ -51,16 +51,16 @@ void set_socket_status(char* socket_status)
int i = 0; int i = 0;
for (i = 0; i < PLUG_NUM; i++) for (i = 0; i < PLUG_NUM; i++)
{ {
user_relay_set(i, ons[i]); UserRelaySet(i, ons[i]);
} }
} }
/*user_relay_set /*UserRelaySet
* 设置继电器开关 * 设置继电器开关
* i:编号 0-5 * i:编号 0-5
* on:开关 0:关 1:开 * on:开关 0:关 1:开
*/ */
void user_relay_set(unsigned char i, unsigned char on) void UserRelaySet(unsigned char i, unsigned char on)
{ {
if (i >= PLUG_NUM) return; if (i >= PLUG_NUM) return;
@@ -75,13 +75,13 @@ void user_relay_set(unsigned char i, unsigned char on)
user_config->plug[i].on = on; user_config->plug[i].on = on;
if (relay_out()) if (RelayOut())
{ {
user_led_set(1); UserLedSet(1);
} }
else else
{ {
user_led_set(0); UserLedSet(0);
} }
} }
@@ -90,46 +90,46 @@ void user_relay_set(unsigned char i, unsigned char on)
* y: 0:全部关 1:全部开 * y: 0:全部关 1:全部开
* *
*/ */
void user_relay_set_all(char y) void UserRelaySetAll(char y)
{ {
int i; int i;
for (i = 0; i < PLUG_NUM; i++) for (i = 0; i < PLUG_NUM; i++)
user_relay_set(i, y); UserRelaySet(i, y);
} }
static void key_long_press(void) static void KeyLongPress(void)
{ {
// os_log("key_long_press"); // os_log("KeyLongPress");
// user_led_set(1); // UserLedSet(1);
// user_mqtt_send("mqtt test"); // user_mqtt_send("mqtt test");
} }
static void key_long_10s_press(void) static void KeyLong10sPress(void)
{ {
os_log("WARNGIN: user params restored!"); os_log("WARNGIN: user params restored!");
// char i = 0; // char i = 0;
// for (i = 0; i < 3; i++) // for (i = 0; i < 3; i++)
// { // {
// user_led_set(1); // UserLedSet(1);
// mico_rtos_thread_msleep(100); // mico_rtos_thread_msleep(100);
// user_led_set(0); // UserLedSet(0);
// } // }
// //
appRestoreDefault_callback(user_config, sizeof(user_config_t)); appRestoreDefault_callback(user_config, sizeof(user_config_t));
sys_config->micoSystemConfig.ssid[0] = 0; sys_config->micoSystemConfig.ssid[0] = 0;
mico_system_context_update(mico_system_context_get()); mico_system_context_update(mico_system_context_get());
} }
static void key_short_press(void) static void KeyShortPress(void)
{ {
char i; char i;
if (relay_out()) if (RelayOut())
{ {
user_relay_set_all(0); UserRelaySetAll(0);
} }
else else
{ {
user_relay_set_all(1); UserRelaySetAll(1);
} }
for (i = 0; i < PLUG_NUM; i++) for (i = 0; i < PLUG_NUM; i++)
@@ -141,7 +141,7 @@ mico_timer_t user_key_timer;
uint16_t key_time = 0; uint16_t key_time = 0;
#define BUTTON_LONG_PRESS_TIME 10 //100ms*10=1s #define BUTTON_LONG_PRESS_TIME 10 //100ms*10=1s
static void key_timeout_handler(void* arg) static void KeyTimeoutHandler(void* arg)
{ {
static char key_trigger, key_continue; static char key_trigger, key_continue;
//按键扫描程序 //按键扫描程序
@@ -160,19 +160,19 @@ static void key_timeout_handler(void* arg)
if (key_time == 30) if (key_time == 30)
{ {
key_long_press(); KeyLongPress();
} }
else if (key_time == 100) else if (key_time == 100)
{ {
key_long_10s_press(); KeyLong10sPress();
} }
else if (key_time == 102) else if (key_time == 102)
{ {
user_led_set(1); UserLedSet(1);
} }
else if (key_time == 103) else if (key_time == 103)
{ {
user_led_set(0); UserLedSet(0);
key_time = 101; key_time = 101;
} }
} }
@@ -184,7 +184,7 @@ static void key_timeout_handler(void* arg)
{ //100ms*10=1s 大于1s为长按 { //100ms*10=1s 大于1s为长按
key_time = 0; key_time = 0;
os_log("button short pressed:%d",key_time); os_log("button short pressed:%d",key_time);
key_short_press(); KeyShortPress();
} else if (key_time > 100) } else if (key_time > 100)
{ {
MicoSystemReboot(); MicoSystemReboot();
@@ -193,16 +193,16 @@ static void key_timeout_handler(void* arg)
} }
} }
static void key_falling_irq_handler(void* arg) static void KeyFallingIrqHandler(void* arg)
{ {
mico_rtos_start_timer(&user_key_timer); mico_rtos_start_timer(&user_key_timer);
} }
void key_init(void) void KeyInit(void)
{ {
MicoGpioInitialize(Button, INPUT_PULL_UP); MicoGpioInitialize(Button, INPUT_PULL_UP);
mico_rtos_init_timer(&user_key_timer, 100, key_timeout_handler, NULL); mico_rtos_init_timer(&user_key_timer, 100, KeyTimeoutHandler, NULL);
MicoGpioEnableIRQ(Button, IRQ_TRIGGER_FALLING_EDGE, key_falling_irq_handler, NULL); MicoGpioEnableIRQ(Button, IRQ_TRIGGER_FALLING_EDGE, KeyFallingIrqHandler, NULL);
} }

View File

@@ -6,12 +6,12 @@
#include "mico.h" #include "mico.h"
#include "micokit_ext.h" #include "micokit_ext.h"
void user_led_set(char x); void UserLedSet(char x);
void key_init(void); void KeyInit(void);
void user_relay_set(unsigned char x,unsigned char y); void UserRelaySet(unsigned char x,unsigned char y);
void user_relay_set_all(char y); void UserRelaySetAll(char y);
bool relay_out(void); bool RelayOut(void);
const unsigned char* get_socket_status(); const unsigned char* GetSocketStatus();
void set_socket_status(char* socket_status); void SetSocketStatus(char* socket_status);
#endif #endif

View File

@@ -406,9 +406,9 @@ void mqtt_client_thread(mico_thread_arg_t arg)
mqtt_client_release(&c, &n); mqtt_client_release(&c, &n);
isconnect = false; isconnect = false;
user_led_set(-1); UserLedSet(-1);
mico_rtos_thread_msleep(100); mico_rtos_thread_msleep(100);
user_led_set(-1); UserLedSet(-1);
mico_rtos_thread_sleep(5); mico_rtos_thread_sleep(5);
goto MQTT_start; goto MQTT_start;

View File

@@ -192,7 +192,7 @@ void rtc_thread(mico_thread_arg_t arg)
{ {
if (user_config->plug[i].on != user_config->plug[i].task[j].action) if (user_config->plug[i].on != user_config->plug[i].task[j].action)
{ {
user_relay_set(i, user_config->plug[i].task[j].action); UserRelaySet(i, user_config->plug[i].task[j].action);
update_user_config_flag = 1; update_user_config_flag = 1;
user_mqtt_send_plug_state(i); user_mqtt_send_plug_state(i);
} }

View File

@@ -97,7 +97,7 @@ static void WifiLedTimerCallback(void* arg)
{ {
case WIFI_STATE_FAIL: case WIFI_STATE_FAIL:
os_log("wifi connect fail"); os_log("wifi connect fail");
user_led_set(0); UserLedSet(0);
mico_rtos_stop_timer(&wifi_led_timer); mico_rtos_stop_timer(&wifi_led_timer);
break; break;
case WIFI_STATE_NOCONNECT: case WIFI_STATE_NOCONNECT:
@@ -105,15 +105,15 @@ static void WifiLedTimerCallback(void* arg)
break; break;
case WIFI_STATE_CONNECTING: case WIFI_STATE_CONNECTING:
num = 0; num = 0;
user_led_set(-1); UserLedSet(-1);
break; break;
case WIFI_STATE_CONNECTED: case WIFI_STATE_CONNECTED:
user_led_set(0); UserLedSet(0);
mico_rtos_stop_timer(&wifi_led_timer); mico_rtos_stop_timer(&wifi_led_timer);
if (relay_out()) if (RelayOut())
user_led_set(1); UserLedSet(1);
else else
user_led_set(0); UserLedSet(0);
break; break;
} }
} }