mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 04:58:17 +08:00
add:增加重启命令
fix:修复设置插口名称后,hass中friendlyname显示为id的问题 版本号:v0.10.1
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "mico.h"
|
||||
#include "MiCOKit_EXT.h"
|
||||
|
||||
#define VERSION "v0.10"
|
||||
#define VERSION "v0.10.1"
|
||||
|
||||
#define TYPE 1
|
||||
#define TYPE_NAME "zTC1"
|
||||
|
||||
@@ -75,6 +75,14 @@ void user_function_cmd_received( int udp_flag, uint8_t *pusrdata )
|
||||
cJSON *json_send = cJSON_CreateObject( );
|
||||
cJSON_AddStringToObject( json_send, "mac", strMac );
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// cJSON *p_cmd = cJSON_GetObjectItem( pJsonRoot, "name" );
|
||||
if(p_cmd && cJSON_IsString( p_cmd ) && strcmp( p_cmd->valuestring, "restart" ) == 0)
|
||||
{
|
||||
os_log("cmd:restart");
|
||||
mico_system_power_perform( mico_system_context_get( ), eState_Software_Reset );
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>汾
|
||||
cJSON *p_version = cJSON_GetObjectItem( pJsonRoot, "version" );
|
||||
if ( p_version )
|
||||
@@ -247,7 +255,7 @@ bool json_plug_analysis( int udp_flag, unsigned char x, cJSON * pJsonRoot, cJSON
|
||||
{
|
||||
return_flag = true;
|
||||
sprintf( user_config->plug[x].name, p_plug_setting_name->valuestring );
|
||||
user_mqtt_hass_auto( x );
|
||||
user_mqtt_hass_auto_name( x );
|
||||
}
|
||||
cJSON_AddStringToObject( json_plug_setting_send, "name", user_config->plug[x].name );
|
||||
}
|
||||
|
||||
@@ -99,14 +99,22 @@ char topic_state[MAX_MQTT_TOPIC_SIZE];
|
||||
char topic_set[MAX_MQTT_TOPIC_SIZE];
|
||||
|
||||
mico_timer_t timer_handle;
|
||||
static uint8_t status = 0;
|
||||
static uint8_t timer_status = 0;
|
||||
void user_mqtt_timer_func( void *arg )
|
||||
{
|
||||
uint8_t *buf1 = NULL;
|
||||
|
||||
LinkStatusTypeDef LinkStatus;
|
||||
micoWlanGetLinkStatus( &LinkStatus );
|
||||
if ( LinkStatus.is_connected != 1 )
|
||||
{
|
||||
mico_stop_timer( &timer_handle );
|
||||
return;
|
||||
}
|
||||
if ( mico_rtos_is_queue_empty( &mqtt_msg_send_queue ) == true )
|
||||
{
|
||||
status++;
|
||||
switch ( status )
|
||||
timer_status++;
|
||||
switch ( timer_status )
|
||||
{
|
||||
case 1:
|
||||
user_mqtt_hass_auto_power( );
|
||||
@@ -401,11 +409,7 @@ void mqtt_client_thread( mico_thread_arg_t arg )
|
||||
|
||||
mqtt_log("Disconnect MQTT client, and reconnect after 5s, reason: mqtt_rc = %d, err = %d", rc, err );
|
||||
|
||||
if ( &timer_handle != NULL && mico_rtos_is_timer_running( &timer_handle ) )
|
||||
{
|
||||
mico_stop_timer( &timer_handle );
|
||||
// mico_deinit_timer( &timer_handle );
|
||||
}
|
||||
timer_status=100;
|
||||
|
||||
mqtt_client_release( &c, &n );
|
||||
isconnect = false;
|
||||
@@ -428,11 +432,7 @@ static void messageArrived( MessageData* md )
|
||||
OSStatus err = kUnknownErr;
|
||||
p_mqtt_recv_msg_t p_recv_msg = NULL;
|
||||
MQTTMessage* message = md->message;
|
||||
/*
|
||||
app_log("MQTT messageArrived callback: topiclen=[%d][%s],\t payloadlen=[%d][%s]",md->topicName->lenstring.len,
|
||||
md->topicName->lenstring.data,(int)message->payloadlen,(char*)message->payload);
|
||||
*/
|
||||
// mqtt_log("======MQTT received callback ![%d]======", MicoGetMemoryInfo()->free_memory );
|
||||
|
||||
p_recv_msg = (p_mqtt_recv_msg_t) calloc( 1, sizeof(mqtt_recv_msg_t) );
|
||||
require_action( p_recv_msg, exit, err = kNoMemoryErr );
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ static void power_timer_handler( void* arg )
|
||||
{
|
||||
timer = (clock_count - clock_count_last);
|
||||
|
||||
os_log("power_irq_handler:%09u %u %u",timer,timer_irq_count,timer_count);
|
||||
// os_log("power_irq_handler:%09u %u %u",timer,timer_irq_count,timer_count);
|
||||
if ( timer_count > 3 )
|
||||
{
|
||||
timer /= 1000;
|
||||
|
||||
@@ -34,7 +34,7 @@ void wifi_start_easylink( )
|
||||
micoWlanStartEasyLink( 20000 );
|
||||
user_led_set( 1 );
|
||||
}
|
||||
uint32_t ip = 0xd248912c;
|
||||
|
||||
//easylink <20><><EFBFBD>ɻص<C9BB>
|
||||
void wifi_easylink_completed_handle( network_InitTypeDef_st *nwkpara, void * arg )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user