'''C
/**
* 解析ASR&NLP信息
*/
int aui_nlp_action_set_volume(cJSON *js, uint8_t *need_resume)
{
aos_dev_t *comm_handleB = NULL;
char my1[] = {0xFA,0xFD,0x02,0x01,0xDF};
char my2[] = {0xFA,0xFD,0x02,0x00,0xDF};
comm_handleB = uart_open_id("uart", 2);
uart_config_t configabc;
uart_config_default(&configabc);
configabc.baud_rate = 115200;
uart_config(comm_handleB, &configabc);
uart_set_type(comm_handleB, UART_TYPE_GENERAL);
int ret = -1;
int vol_step = 10;
cJSON *action_params = cJSON_GetObjectItemByPath(js, "payload.action_params");
if(cJSON_IsArray(action_params)) {
cJSON *param = NULL;
cJSON *param_name = NULL, *param_value = NULL;
char *action = NULL;
cJSON_ArrayForEach(param, action_params) {
if (cJSON_HasObjectItem(param, "name")) {
param_name = cJSON_GetObjectItemCaseSensitive(param, "name");
if (json_string_eq(param_name, "sound") && cJSON_HasObjectItem(param, "value")) {
param_value = cJSON_GetObjectItemCaseSensitive(param, "value");
action = param_value->valuestring;
LOGD(TAG, "volume action [%s]000", action);
if (strcmp(action, "down")==0){
//LOGD(TAG, "---down---");
uart_send(comm_handleB, &my1, 5);
}
if (strcmp(action, "up")==0){
//LOGD(TAG, "---up---");
uart_send(comm_handleB, &my2, 5);
}
}
if ((json_string_eq(param_name, "degree") && cJSON_HasObjectItem(param, "value"))
|| (json_string_eq(param_name, "volumn") && cJSON_HasObjectItem(param, "value"))){
param_value = cJSON_GetObjectItemCaseSensitive(param, "value");
vol_step = atoi(param_value->valuestring);
LOGD(TAG, "volume degree [%d]", vol_step);
}
}
}
if (strcmp(action, "up") == 0) {
SMTaudio_vol_up(vol_step);
ret = 0;
} else if (strcmp(action, "down") == 0) {
smtaudio_vol_down(vol_step);
ret = 0;
} else if (strcmp(action, "max") == 0) {
smtaudio_vol_set(100);
ret = 0;
} else if (strcmp(action, "min") == 0) {
smtaudio_vol_set(0);
ret = 0;
} else if (strcmp(action, "mute") == 0) {
*need_resume = 0;
ret = 0;
} else if (strcmp(action, "unmute") == 0) {
*need_resume = 1;
ret = 0;
} else if (strcmp(action, "set") == 0) {
smtaudio_vol_set(20);
ret = 0;
}
} else {
LOGE(TAG, "set_volume payload error!");
return -1;
}
return ret;
}
'''