修复代码错误

This commit is contained in:
nhkefus
2025-03-11 14:10:51 +08:00
parent a7f6e9379a
commit 3422912129
576 changed files with 39303 additions and 1012 deletions

0
mico-os/MiCO/system/command_console/mico_cli.h Normal file → Executable file
View File

View File

@@ -48,7 +48,7 @@ static mico_thread_t easylink_thread_handler = NULL;
static bool easylink_thread_force_exit = false;
static mico_config_source_t source = CONFIG_BY_NONE;
static bool easylink_with_softap = false;
/******************************************************
* Function Definitions
******************************************************/
@@ -99,20 +99,7 @@ static void easylink_complete_cb( network_InitTypeDef_st *nwkpara, system_contex
}
return;
}
#ifdef MICO_EASYLINK_AND_SOFTAP_ENABLED
void easylink_uap_success(uint32_t id)
{
if (easylink_with_softap == false)
return;
system_log("sofapt configured");
easylinkIndentifier = id;
easylink_success = true;
micoWlanSuspendSoftAP();
mico_rtos_set_semaphore( &easylink_sem );
}
#endif
/* MiCO callback when EasyLink is finished step 2, return extra data
data format: [AuthData#Identifier]<localIp/netMask/gateWay/dnsServer>
Auth data: Provide to application, application will decide if this is a proter configuration for currnet device
@@ -123,7 +110,7 @@ static void easylink_extra_data_cb( int datalen, char* data, system_context_t *
{
OSStatus err = kNoErr;
int index;
uint32_t ipInfoCount;
uint32_t *identifier, ipInfoCount;
char *debugString;
struct in_addr ipv4_addr;
@@ -145,7 +132,9 @@ static void easylink_extra_data_cb( int datalen, char* data, system_context_t *
require_noerr( err, exit );
/* Read identifier */
memcpy(&easylinkIndentifier, &data[index], 4);
identifier = (uint32_t *) &data[index];
easylinkIndentifier = *identifier;
/* Identifier: 1 x uint32_t or Identifier/localIp/netMask/gateWay/dnsServer: 5 x uint32_t */
ipInfoCount = (datalen - index) / sizeof(uint32_t);
require_action( ipInfoCount >= 1, exit, err = kParamErr );
@@ -159,13 +148,13 @@ static void easylink_extra_data_cb( int datalen, char* data, system_context_t *
} else
{ //Use static ip address
inContext->flashContentInRam.micoSystemConfig.dhcpEnable = false;
memcpy(&ipv4_addr.s_addr, &data[index+4], 4);
ipv4_addr.s_addr = *(identifier+1);
strcpy( (char *) inContext->micoStatus.localIp, inet_ntoa( ipv4_addr ) );
memcpy(&ipv4_addr.s_addr, &data[index+8], 4);
ipv4_addr.s_addr = *(identifier+2);
strcpy( (char *) inContext->micoStatus.netMask, inet_ntoa( ipv4_addr ) );
memcpy(&ipv4_addr.s_addr, &data[index+12], 4);
ipv4_addr.s_addr = *(identifier+3);
strcpy( (char *) inContext->micoStatus.gateWay, inet_ntoa( ipv4_addr ) );
memcpy(&ipv4_addr.s_addr, &data[index+16], 4);
ipv4_addr.s_addr = *(identifier+4);
strcpy( (char *) inContext->micoStatus.dnsServer, inet_ntoa( ipv4_addr ) );
system_log("Get auth info: %s, EasyLink identifier: %lx, local IP info:%s %s %s %s ", data, easylinkIndentifier, inContext->flashContentInRam.micoSystemConfig.localIp,
@@ -208,24 +197,9 @@ static void easylink_thread( uint32_t arg )
restart:
mico_system_delegate_config_will_start( );
system_log("Start easylink combo mode");
#ifdef MICO_EASYLINK_AND_SOFTAP_ENABLED
if (easylink_with_softap == true) {
char wifi_ssid[32];
sprintf( wifi_ssid, "EasyLink_%c%c%c%c%c%c",
context->micoStatus.mac[9], context->micoStatus.mac[10], context->micoStatus.mac[12],
context->micoStatus.mac[13], context->micoStatus.mac[15], context->micoStatus.mac[16]);
system_log("Enable softap %s in easylink", wifi_ssid);
OpenEasylink_softap( EasyLink_TimeOut / 1000, wifi_ssid, NULL, 6 );
/* Start config server */
config_server_start( );
easylink_bonjour_start( Soft_AP, 0, context );
} else
#endif
micoWlanStartEasyLinkPlus( EasyLink_TimeOut / 1000 );
while( mico_rtos_get_semaphore( &easylink_sem, 0 ) == kNoErr );
err = mico_rtos_get_semaphore( &easylink_sem, EasyLink_TimeOut );
err = mico_rtos_get_semaphore( &easylink_sem, MICO_WAIT_FOREVER );
/* Easylink force exit by user, clean and exit */
if( err != kNoErr && easylink_thread_force_exit )
@@ -296,7 +270,7 @@ exit:
mico_rtos_delete_thread( NULL );
}
OSStatus mico_easylink( mico_Context_t * const in_context, mico_bool_t enable, mico_bool_t softap )
OSStatus mico_easylink( mico_Context_t * const in_context, mico_bool_t enable )
{
OSStatus err = kUnknownErr;
@@ -313,10 +287,6 @@ OSStatus mico_easylink( mico_Context_t * const in_context, mico_bool_t enable, m
}
if ( enable == MICO_TRUE ) {
if (softap == MICO_TRUE)
easylink_with_softap = true;
else
easylink_with_softap = false;
err = mico_rtos_create_thread( &easylink_thread_handler, MICO_APPLICATION_PRIORITY, "EASYLINK", easylink_thread,
0x1000, (mico_thread_arg_t) in_context );
require_noerr_string( err, exit, "ERROR: Unable to start the EasyLink thread." );

View File

@@ -84,20 +84,6 @@ WEAK void mico_system_delegate_config_recv_ssid ( char *ssid, char *key )
return;
}
WEAK mico_connect_fail_config_t mico_system_delegate_config_result( mico_config_source_t source, uint8_t result )
{
//system_log( "Configed by %d", source );
UNUSED_PARAMETER(source);
if(MICO_FALSE == result)
{
return RESTART_EASYLINK;
}
else
{
return EXIT_EASYLINK;
}
}
WEAK void mico_system_delegate_config_success( mico_config_source_t source )
{
//system_log( "Configed by %d", source );
@@ -105,19 +91,6 @@ WEAK void mico_system_delegate_config_success( mico_config_source_t source )
return;
}
WEAK void mico_system_delegate_easylink_timeout( system_context_t *context )
{
/* so roll back to previous settings (if it has) and connect */
if ( context->flashContentInRam.micoSystemConfig.configured != unConfigured ) {
MICOReadConfiguration( context );
system_connect_wifi_normal( context );
}
else {
/*module should power down in default setting*/
micoWlanPowerOff();
}
}
WEAK OSStatus mico_system_delegate_config_recv_auth_data(char * anthData )
{

View File

@@ -56,7 +56,6 @@ static mico_thread_t easylink_monitor_thread_handler = NULL;
static bool easylink_thread_force_exit = false;
static mico_config_source_t source = CONFIG_BY_NONE;
static mico_connect_fail_config_t connect_fail_config = EXIT_EASYLINK;
/******************************************************
* Function Definitions
@@ -275,32 +274,33 @@ restart:
goto exit;
}
source = (source == CONFIG_BY_NONE) ? CONFIG_BY_MONITOR : source;
/*SSID or Password is not correct, module cannot connect to wlan, so restart EasyLink again*/
require_noerr_action_string( err, restart, micoWlanSuspend(), "Re-start easylink combo mode" );
/* Easylink connect result */
if ( err != kNoErr )
{
connect_fail_config = mico_system_delegate_config_result( source, MICO_FALSE );
if ( RESTART_EASYLINK == connect_fail_config )
{
system_log("Re-start easylink combo mode");
micoWlanSuspend( );
goto restart;
} else {
system_log("exit easylink combo mode");
micoWlanSuspendStation( );
goto exit;
}
}
else
{
mico_system_delegate_config_result( source, MICO_TRUE );
mico_easylink_monitor_delegate_connect_success( source );
}
/* Start bonjour service for new device discovery */
err = easylink_bonjour_start( Station, easylink_id, context );
require_noerr( err, exit );
SetTimer( 60 * 1000, easylink_remove_bonjour );
source = (source == CONFIG_BY_NONE) ? CONFIG_BY_MONITOR : source;
mico_system_delegate_config_success( source );
mico_easylink_monitor_delegate_connect_success( source );
goto exit;
}
else /* EasyLink failed */
{
mico_system_delegate_easylink_timeout( context );
/* so roll back to previous settings (if it has) and connect */
if ( context->flashContentInRam.micoSystemConfig.configured != unConfigured ) {
system_log("Roll back to previous settings");
MICOReadConfiguration( context );
system_connect_wifi_normal( context );
}
else {
/*module should power down in default setting*/
system_log("Wi-Fi power off");
micoWlanPowerOff();
}
}
exit:
@@ -348,7 +348,7 @@ OSStatus mico_easylink_monitor_save_result( network_InitTypeDef_st *nwkpara )
OSStatus mico_easylink_monitor_with_easylink( mico_Context_t * const in_context, mico_bool_t enable )
{
OSStatus err = kNoErr;
OSStatus err = kUnknownErr;
require_action( in_context, exit, err = kNotPreparedErr );

View File

@@ -127,9 +127,7 @@ OSStatus ConfigIncommingJsonMessageUAP( int fd, const uint8_t *input, size_t siz
easylink_success = true;
if( easylink_sem ) mico_rtos_set_semaphore( &easylink_sem );
#ifdef MICO_EASYLINK_AND_SOFTAP_ENABLED
easylink_uap_success(easylinkIndentifier);
#endif
exit:
if ( input_str ) free( input_str );

View File

@@ -52,11 +52,7 @@ OSStatus system_discovery_init( system_context_t * const inContext )
inContext->micoStatus.mac[15], inContext->micoStatus.mac[16] );
init.instance_name = (char*)__strdup(temp_txt);
#ifndef MICO_LOCAL_SERVER_PORT
init.service_port = MICO_CONFIG_SERVER_PORT;
#else
init.service_port = MICO_LOCAL_SERVER_PORT;
#endif
temp_txt2 = __strdup_trans_dot(inContext->micoStatus.mac);
sprintf(temp_txt, "MAC=%s.", temp_txt2);

View File

@@ -40,9 +40,7 @@ static OSStatus system_config_mode_worker( void *arg )
micoWlanPowerOn();
#if (MICO_WLAN_CONFIG_MODE == CONFIG_MODE_EASYLINK)
err = mico_easylink( in_context, MICO_TRUE, MICO_FALSE );
#elif (MICO_WLAN_CONFIG_MODE == CONFIG_MODE_EASYLINK_WITH_SOFTAP)
err = mico_easylink( in_context, MICO_TRUE, MICO_TRUE );
err = mico_easylink( in_context, MICO_TRUE );
#elif ( MICO_WLAN_CONFIG_MODE == CONFIG_MODE_SOFTAP)
err = mico_easylink_softap( in_context, MICO_TRUE );
#elif ( MICO_WLAN_CONFIG_MODE == CONFIG_MODE_MONITOR)
@@ -100,9 +98,8 @@ OSStatus mico_system_init( mico_Context_t* in_context )
#ifdef MICO_WLAN_CONNECTION_ENABLE
#ifndef EasyLink_Needs_Reboot
/* Create a worker thread for user handling wlan auto-conf event, this worker thread only has
one event on queue, avoid some unwanted operation */
err = mico_rtos_create_worker_thread( &wlan_autoconf_worker_thread, MICO_APPLICATION_PRIORITY, 0x500, 1 );
/* Create a worker thread for user handling wlan auto-conf event */
err = mico_rtos_create_worker_thread( &wlan_autoconf_worker_thread, MICO_APPLICATION_PRIORITY, 0x300, 1 );
require_noerr_string( err, exit, "ERROR: Unable to start the autoconf worker thread." );
#endif

0
mico-os/MiCO/system/mico_system_time.c Normal file → Executable file
View File

View File

@@ -51,7 +51,7 @@ int mf_get_line( char** p_cmd_str );
void qc_test_ble(void);
void qc_test_gpio(void);
void qc_test_tcpip(void);
void qc_scan(void);

View File

@@ -31,7 +31,7 @@ extern void mfg_option (int use_udp, uint32_t remoteaddr); //TODO: Get it from
* Function Definitions
******************************************************/
MAY_BE_UNUSED static char * ssid_get(void)
static char * ssid_get(void)
{
char *cmd;
uint32_t remote_addr = 0xFFFFFFFF;
@@ -65,7 +65,7 @@ MAY_BE_UNUSED static char * ssid_get(void)
void qc_test_tcpip(void)
{
//mfg_connect (ssid_get());
mfg_connect (ssid_get());
}

View File

@@ -155,7 +155,7 @@ static void _qc_test_thread( mico_thread_arg_t arg )
sprintf( str, "%02X-%02X-%02X-%02X-%02X-%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] );
QC_TEST_PRINT_STRING( "MAC:", str );
qc_scan( );
mfg_scan( );
qc_test_tcpip( );

View File

@@ -12,7 +12,6 @@ NAME = Lib_MiCO_System_QC
$(NAME)_SOURCES := qc_test.c \
internal/qc_test_tcpip.c \
internal/qc_test_wlan.c \
internal/qc_test_ble.c \
internal/qc_test_cli.c

View File

@@ -27,7 +27,7 @@
#define CONFIG_MODE_USER (2)
#define CONFIG_MODE_WAC (3)
#define CONFIG_MODE_EASYLINK (4)
#define CONFIG_MODE_EASYLINK_WITH_SOFTAP (8)
#define CONFIG_MODE_EASYLINK_WITH_SOFTAP (4) //Legacy definition, not supported any more
#define CONFIG_MODE_SOFTAP (5)
#define CONFIG_MODE_MONITOR (6)
#define CONFIG_MODE_MONITOR_EASYLINK (7)

View File

@@ -16,7 +16,6 @@ $(NAME)_SOURCES := mico_system_init.c \
mico_system_para_storage.c \
mico_system_time.c \
mico_system_power_daemon.c \
mico_filesystem.c \
system_misc.c
$(NAME)_SOURCES += command_console/mico_cli.c
@@ -42,6 +41,7 @@ $(NAME)_SOURCES += mdns/mico_mdns.c \
$(NAME)_SOURCES += tftp_ota/tftp_ota.c \
tftp_ota/tftpc.c
$(NAME)_LINK_FILES := mico_system_power_daemon.o
$(NAME)_COMPONENTS := system/qc_test system/easylink/MFi_WAC

0
mico-os/MiCO/system/tftp_ota/tftpc.o Normal file → Executable file
View File