mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
函数名驼峰式-2
This commit is contained in:
@@ -62,7 +62,7 @@ exit:
|
||||
|
||||
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_pwd = "12345678";
|
||||
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);
|
||||
require_noerr(err, exit);
|
||||
|
||||
set_socket_status(buf);
|
||||
SetSocketStatus(buf);
|
||||
|
||||
send_http("OK", 2, exit, &err);
|
||||
|
||||
@@ -103,7 +103,7 @@ exit:
|
||||
static int HttpGetWifiConfig(httpd_request_t *req)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
const unsigned char* status = get_socket_status();
|
||||
const unsigned char* status = GetSocketStatus();
|
||||
send_http(status, strlen(status), exit, &err);
|
||||
exit:
|
||||
return err;
|
||||
|
||||
@@ -100,7 +100,7 @@ int application_start(void)
|
||||
for (i = 0; i < Relay_NUM; i++)
|
||||
{
|
||||
MicoGpioInitialize(Relay[i], OUTPUT_PUSH_PULL);
|
||||
user_relay_set(i, user_config->plug[i].on);
|
||||
UserRelaySet(i, user_config->plug[i].on);
|
||||
}
|
||||
MicoSysLed(0);
|
||||
|
||||
@@ -156,7 +156,7 @@ int application_start(void)
|
||||
WifiConnect(sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key);
|
||||
}
|
||||
user_udp_init();
|
||||
key_init();
|
||||
KeyInit();
|
||||
err = user_mqtt_init();
|
||||
require_noerr(err, exit);
|
||||
err = user_rtc_init();
|
||||
|
||||
@@ -236,7 +236,7 @@ bool json_plug_analysis(int udp_flag, unsigned char x, cJSON * pJsonRoot, cJSON
|
||||
{
|
||||
if (cJSON_IsNumber(p_plug_on))
|
||||
{
|
||||
user_relay_set(x, p_plug_on->valueint);
|
||||
UserRelaySet(x, p_plug_on->valueint);
|
||||
return_flag = true;
|
||||
}
|
||||
user_mqtt_send_plug_state(x);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
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)
|
||||
MicoGpioOutputTrigger(Led);
|
||||
@@ -18,7 +18,7 @@ void user_led_set(char x)
|
||||
MicoGpioOutputLow(Led);
|
||||
}
|
||||
|
||||
bool relay_out(void)
|
||||
bool RelayOut(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < PLUG_NUM; i++)
|
||||
@@ -31,7 +31,7 @@ bool relay_out(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
const unsigned char* get_socket_status()
|
||||
const unsigned char* GetSocketStatus()
|
||||
{
|
||||
sprintf(socket_status, "%d,%d,%d,%d,%d,%d",
|
||||
user_config->plug[0].on,
|
||||
@@ -43,7 +43,7 @@ const unsigned char* get_socket_status()
|
||||
return (const unsigned char*)socket_status;
|
||||
}
|
||||
|
||||
void set_socket_status(char* socket_status)
|
||||
void SetSocketStatus(char* socket_status)
|
||||
{
|
||||
int ons[6] = { 0 };
|
||||
sscanf(socket_status, "%d,%d,%d,%d,%d,%d,",
|
||||
@@ -51,16 +51,16 @@ void set_socket_status(char* socket_status)
|
||||
int i = 0;
|
||||
for (i = 0; i < PLUG_NUM; i++)
|
||||
{
|
||||
user_relay_set(i, ons[i]);
|
||||
UserRelaySet(i, ons[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*user_relay_set
|
||||
/*UserRelaySet
|
||||
* 设置继电器开关
|
||||
* i:编号 0-5
|
||||
* 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;
|
||||
|
||||
@@ -75,13 +75,13 @@ void user_relay_set(unsigned char i, unsigned char on)
|
||||
|
||||
user_config->plug[i].on = on;
|
||||
|
||||
if (relay_out())
|
||||
if (RelayOut())
|
||||
{
|
||||
user_led_set(1);
|
||||
UserLedSet(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
user_led_set(0);
|
||||
UserLedSet(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,46 +90,46 @@ void user_relay_set(unsigned char i, unsigned char on)
|
||||
* y: 0:全部关 1:全部开
|
||||
*
|
||||
*/
|
||||
void user_relay_set_all(char y)
|
||||
void UserRelaySetAll(char y)
|
||||
{
|
||||
int 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");
|
||||
// user_led_set(1);
|
||||
// os_log("KeyLongPress");
|
||||
// UserLedSet(1);
|
||||
// user_mqtt_send("mqtt test");
|
||||
}
|
||||
|
||||
static void key_long_10s_press(void)
|
||||
static void KeyLong10sPress(void)
|
||||
{
|
||||
os_log("WARNGIN: user params restored!");
|
||||
// char i = 0;
|
||||
// for (i = 0; i < 3; i++)
|
||||
// {
|
||||
// user_led_set(1);
|
||||
// UserLedSet(1);
|
||||
// mico_rtos_thread_msleep(100);
|
||||
// user_led_set(0);
|
||||
// UserLedSet(0);
|
||||
// }
|
||||
//
|
||||
appRestoreDefault_callback(user_config, sizeof(user_config_t));
|
||||
sys_config->micoSystemConfig.ssid[0] = 0;
|
||||
mico_system_context_update(mico_system_context_get());
|
||||
}
|
||||
static void key_short_press(void)
|
||||
static void KeyShortPress(void)
|
||||
{
|
||||
char i;
|
||||
|
||||
if (relay_out())
|
||||
if (RelayOut())
|
||||
{
|
||||
user_relay_set_all(0);
|
||||
UserRelaySetAll(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
user_relay_set_all(1);
|
||||
UserRelaySetAll(1);
|
||||
}
|
||||
|
||||
for (i = 0; i < PLUG_NUM; i++)
|
||||
@@ -141,7 +141,7 @@ mico_timer_t user_key_timer;
|
||||
uint16_t key_time = 0;
|
||||
#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;
|
||||
//按键扫描程序
|
||||
@@ -160,19 +160,19 @@ static void key_timeout_handler(void* arg)
|
||||
|
||||
if (key_time == 30)
|
||||
{
|
||||
key_long_press();
|
||||
KeyLongPress();
|
||||
}
|
||||
else if (key_time == 100)
|
||||
{
|
||||
key_long_10s_press();
|
||||
KeyLong10sPress();
|
||||
}
|
||||
else if (key_time == 102)
|
||||
{
|
||||
user_led_set(1);
|
||||
UserLedSet(1);
|
||||
}
|
||||
else if (key_time == 103)
|
||||
{
|
||||
user_led_set(0);
|
||||
UserLedSet(0);
|
||||
key_time = 101;
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ static void key_timeout_handler(void* arg)
|
||||
{ //100ms*10=1s 大于1s为长按
|
||||
key_time = 0;
|
||||
os_log("button short pressed:%d",key_time);
|
||||
key_short_press();
|
||||
KeyShortPress();
|
||||
} else if (key_time > 100)
|
||||
{
|
||||
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);
|
||||
}
|
||||
void key_init(void)
|
||||
void KeyInit(void)
|
||||
{
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
#include "mico.h"
|
||||
#include "micokit_ext.h"
|
||||
|
||||
void user_led_set(char x);
|
||||
void key_init(void);
|
||||
void user_relay_set(unsigned char x,unsigned char y);
|
||||
void user_relay_set_all(char y);
|
||||
bool relay_out(void);
|
||||
const unsigned char* get_socket_status();
|
||||
void set_socket_status(char* socket_status);
|
||||
void UserLedSet(char x);
|
||||
void KeyInit(void);
|
||||
void UserRelaySet(unsigned char x,unsigned char y);
|
||||
void UserRelaySetAll(char y);
|
||||
bool RelayOut(void);
|
||||
const unsigned char* GetSocketStatus();
|
||||
void SetSocketStatus(char* socket_status);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -406,9 +406,9 @@ void mqtt_client_thread(mico_thread_arg_t arg)
|
||||
|
||||
mqtt_client_release(&c, &n);
|
||||
isconnect = false;
|
||||
user_led_set(-1);
|
||||
UserLedSet(-1);
|
||||
mico_rtos_thread_msleep(100);
|
||||
user_led_set(-1);
|
||||
UserLedSet(-1);
|
||||
mico_rtos_thread_sleep(5);
|
||||
goto MQTT_start;
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
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;
|
||||
user_mqtt_send_plug_state(i);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ static void WifiLedTimerCallback(void* arg)
|
||||
{
|
||||
case WIFI_STATE_FAIL:
|
||||
os_log("wifi connect fail");
|
||||
user_led_set(0);
|
||||
UserLedSet(0);
|
||||
mico_rtos_stop_timer(&wifi_led_timer);
|
||||
break;
|
||||
case WIFI_STATE_NOCONNECT:
|
||||
@@ -105,15 +105,15 @@ static void WifiLedTimerCallback(void* arg)
|
||||
break;
|
||||
case WIFI_STATE_CONNECTING:
|
||||
num = 0;
|
||||
user_led_set(-1);
|
||||
UserLedSet(-1);
|
||||
break;
|
||||
case WIFI_STATE_CONNECTED:
|
||||
user_led_set(0);
|
||||
UserLedSet(0);
|
||||
mico_rtos_stop_timer(&wifi_led_timer);
|
||||
if (relay_out())
|
||||
user_led_set(1);
|
||||
if (RelayOut())
|
||||
UserLedSet(1);
|
||||
else
|
||||
user_led_set(0);
|
||||
UserLedSet(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user