diff --git a/src/esp_mn_speech_commands.c b/src/esp_mn_speech_commands.c index a1a4f2a..0aa87c9 100644 --- a/src/esp_mn_speech_commands.c +++ b/src/esp_mn_speech_commands.c @@ -137,7 +137,7 @@ esp_err_t esp_mn_commands_remove(char *phoneme_string) esp_mn_phrase_t *esp_mn_commands_get_from_index(int index) { - ESP_RETURN_ON_FALSE(NULL != esp_mn_root, ESP_ERR_INVALID_STATE, TAG, "The mn commands is not initialized"); + ESP_RETURN_ON_FALSE(NULL != esp_mn_root, NULL, TAG, "The mn commands is not initialized"); // phrase index also is phrase id, which is the depth from this phrase node to root node esp_mn_node_t *temp = esp_mn_root; @@ -151,7 +151,7 @@ esp_mn_phrase_t *esp_mn_commands_get_from_index(int index) esp_mn_phrase_t *esp_mn_commands_get_from_string(const char *phoneme_string) { - ESP_RETURN_ON_FALSE(NULL != esp_mn_root, ESP_ERR_INVALID_STATE, TAG, "The mn commands is not initialized"); + ESP_RETURN_ON_FALSE(NULL != esp_mn_root, NULL, TAG, "The mn commands is not initialized"); // phrase index also is phrase id, which is the depth from this phrase node to root node esp_mn_node_t *temp = esp_mn_root; @@ -165,9 +165,9 @@ esp_mn_phrase_t *esp_mn_commands_get_from_string(const char *phoneme_string) return NULL; } -esp_mn_error_t *esp_mn_commands_update(const esp_mn_iface_t *multinet, const model_iface_data_t *model_data) +esp_mn_error_t *esp_mn_commands_update(const esp_mn_iface_t *multinet, model_iface_data_t *model_data) { - ESP_RETURN_ON_FALSE(NULL != esp_mn_root, ESP_ERR_INVALID_STATE, TAG, "The mn commands is not initialize"); + ESP_RETURN_ON_FALSE(NULL != esp_mn_root, NULL, TAG, "The mn commands is not initialize"); esp_mn_error_t *error = multinet->set_speech_commands(model_data, esp_mn_root); if (error->num == 0) @@ -208,7 +208,7 @@ esp_mn_phrase_t *esp_mn_phrase_alloc(int command_id, char *phoneme_string) } esp_mn_phrase_t *phrase = _esp_mn_calloc_(1, sizeof(esp_mn_phrase_t)); - ESP_RETURN_ON_FALSE(NULL != phrase, ESP_ERR_NO_MEM, TAG, "Fail to alloc mn phrase"); + ESP_RETURN_ON_FALSE(NULL != phrase, NULL, TAG, "Fail to alloc mn phrase"); phrase->command_id = command_id; phrase->threshold = 0; phrase->wave = NULL; @@ -227,7 +227,7 @@ void esp_mn_phrase_free(esp_mn_phrase_t *phrase) esp_mn_node_t *esp_mn_node_alloc(esp_mn_phrase_t *phrase) { esp_mn_node_t *node = _esp_mn_calloc_(1, sizeof(esp_mn_node_t)); - ESP_RETURN_ON_FALSE(NULL != node, ESP_ERR_NO_MEM, TAG, "Fail to alloc mn node"); + ESP_RETURN_ON_FALSE(NULL != node, NULL, TAG, "Fail to alloc mn node"); node->next = NULL; node->phrase = phrase; return node; diff --git a/src/esp_process_sdkconfig.c b/src/esp_process_sdkconfig.c index 9582c63..f1489b5 100644 --- a/src/esp_process_sdkconfig.c +++ b/src/esp_process_sdkconfig.c @@ -876,7 +876,7 @@ char *get_id_name_en(int i) #endif } -esp_mn_error_t* esp_mn_commands_update_from_sdkconfig(esp_mn_iface_t *multinet, const model_iface_data_t *model_data) +esp_mn_error_t* esp_mn_commands_update_from_sdkconfig(const esp_mn_iface_t *multinet, model_iface_data_t *model_data) { esp_mn_commands_alloc(); int total_phrase_num = 0; diff --git a/src/include/esp_mn_speech_commands.h b/src/include/esp_mn_speech_commands.h index 2ef3c16..c7b2927 100644 --- a/src/include/esp_mn_speech_commands.h +++ b/src/include/esp_mn_speech_commands.h @@ -117,7 +117,7 @@ esp_mn_phrase_t *esp_mn_commands_get_from_string(const char *phoneme_string); * - NULL Success * - others The list of error phrase which can not be parsed by multinet. */ -esp_mn_error_t *esp_mn_commands_update(const esp_mn_iface_t *multinet, const model_iface_data_t *model_data); +esp_mn_error_t *esp_mn_commands_update(const esp_mn_iface_t *multinet, model_iface_data_t *model_data); /** * @brief Print the MultiNet Speech Commands. diff --git a/src/include/esp_process_sdkconfig.h b/src/include/esp_process_sdkconfig.h index 355515e..9743dca 100644 --- a/src/include/esp_process_sdkconfig.h +++ b/src/include/esp_process_sdkconfig.h @@ -20,4 +20,4 @@ void check_chip_config(void); * - ESP_OK Success * - ESP_ERR_INVALID_STATE Fail */ -esp_mn_error_t* esp_mn_commands_update_from_sdkconfig(esp_mn_iface_t *multinet, const model_iface_data_t *model_data); +esp_mn_error_t* esp_mn_commands_update_from_sdkconfig(const esp_mn_iface_t *multinet, model_iface_data_t *model_data); diff --git a/src/model_path.c b/src/model_path.c index 90fe089..053afad 100644 --- a/src/model_path.c +++ b/src/model_path.c @@ -48,13 +48,13 @@ srmodel_list_t *read_models_form_spiffs(esp_vfs_spiffs_conf_t *conf) } else { models = malloc(sizeof(srmodel_list_t*)); models->num = model_num; - models->partition_label = conf->partition_label; + models->partition_label = (char *)conf->partition_label; models->model_name = malloc(models->num*sizeof(char*)); - for (int i=0; inum; i++) + for (int i=0; inum; i++) models->model_name[i] = (char*) calloc(MODEL_NAME_MAX_LENGTH, sizeof(char)); } - // read& save model names + // read & save model names dir = opendir(conf->base_path); while ((ret = readdir(dir)) != NULL) { // NULL if reach the end of directory @@ -70,7 +70,7 @@ srmodel_list_t *read_models_form_spiffs(esp_vfs_spiffs_conf_t *conf) memcpy(models->model_name[idx], ret->d_name, (len-13)*sizeof(char)); // models->model_name[idx][len-13] = '\0'; idx ++; - } + } } } return models; @@ -186,7 +186,7 @@ void srmodel_config_deinit(srmodel_list_t *models) model_coeff_getter_t* srmodel_get_model_coeff(char *model_name) { - model_coeff_getter_t *gettercb = &WAKENET_COEFF; + model_coeff_getter_t *gettercb = (model_coeff_getter_t *)&WAKENET_COEFF; return gettercb; } @@ -201,7 +201,7 @@ int set_model_base_path(const char *base_path) { if (base_path == NULL) return 0; - SRMODE_BASE_PATH = base_path; + SRMODE_BASE_PATH = (char *)base_path; return 1; } @@ -341,7 +341,7 @@ void esp_srmodel_deinit(srmodel_list_t *models) // repackage strstr function to support needle==NULL char *_esp_strstr_(const char *haystack, const char *needle) { - if (needle == NULL) return haystack; + if (needle == NULL) return (char *)haystack; else return (char *)strstr(haystack, needle); }