src/mqtt_json_parse.c
static mqtt_json_result_t mqtt_json_parse_configure_aircon_temperature(cJSON* jsonMessage)
{
	cJSON* acTempJson;
	cJSON* indexJson;
	cJSON* tempJson;
	acTempJson = cJSON_GetObjectItem(jsonMessage, "data");
	if (!(cJSON_IsObject(acTempJson)))
		return MQTT_PARSE_DATA_ERROR;
	indexJson = cJSON_GetObjectItem(acTempJson, "index");
	if (!cJSON_IsNumber(indexJson))
		return MQTT_PARSE_DATA_ERROR;
	if ((indexJson->valueint > 5) || (indexJson->valueint < 1))
		return MQTT_PARSE_DATA_ERROR;
	tempJson = cJSON_GetObjectItem(acTempJson, "temperature");
	if (!cJSON_IsNumber(tempJson))
		return MQTT_PARSE_DATA_ERROR;
	printf("aircon set temp index: %d, threshold: %d\r\n", indexJson->valueint, tempJson->valueint);
	return MQTT_PARSE_SUCCESS;
}
/* Parse aircon set temperature configuration message */
Parse aircon set temperature configuration message
Parse aircon set temperature configuration message
static mqtt_json_result_t mqtt_json_parse_configure_aircon_temperature(cJSON* jsonMessage)
{
	cJSON* acTempJson;
	cJSON* indexJson;
	cJSON* tempJson;
	acTempJson = cJSON_GetObjectItem(jsonMessage, "data");
	if (!(cJSON_IsObject(acTempJson)))
		return MQTT_PARSE_DATA_ERROR;
	indexJson = cJSON_GetObjectItem(acTempJson, "index");
	if (!cJSON_IsNumber(indexJson))
		return MQTT_PARSE_DATA_ERROR;
	if ((indexJson->valueint > 5) || (indexJson->valueint < 1))
		return MQTT_PARSE_DATA_ERROR;
	tempJson = cJSON_GetObjectItem(acTempJson, "temperature");
	if (!cJSON_IsNumber(tempJson))
		return MQTT_PARSE_DATA_ERROR;
	printf("aircon set temp index: %d, threshold: %d\r\n", indexJson->valueint, tempJson->valueint);
	return MQTT_PARSE_SUCCESS;
}
static mqtt_json_result_t mqtt_json_parse_configure_aircon_temperature ( cJSON * jsonMessage ) { cJSON * acTempJson ; cJSON * indexJson ; cJSON * tempJson ; acTempJson = cJSON_GetObjectItem ( jsonMessage , " " ) ; if ( ! ( cJSON_IsObject ( acTempJson ) ) ) return MQTT_PARSE_DATA_ERROR ; indexJson = cJSON_GetObjectItem ( acTempJson , " " ) ; if ( ! cJSON_IsNumber ( indexJson ) ) return MQTT_PARSE_DATA_ERROR ; if ( ( indexJson -> valueint > 5 ) || ( indexJson -> valueint < 1 ) ) return MQTT_PARSE_DATA_ERROR ; tempJson = cJSON_GetObjectItem ( acTempJson , " " ) ; if ( ! cJSON_IsNumber ( tempJson ) ) return MQTT_PARSE_DATA_ERROR ; printf ( " \r \n " , indexJson -> valueint , tempJson -> valueint ) ; return MQTT_PARSE_SUCCESS ; }
Parse aircon set temperature configuration message
Parse aircon set temperature configuration message