BugID:16966632: add some test case fot at mqtt client
*/
#include <aos/aos.h>
+#include <stdio.h>
+#include <string.h>
#include "at_mqtt_ica_client.h"
+#include "at_mqtt_client.h"
+
#define PRODUCT_KEY "a1kecMbd2yb"
#define DEVICE_NAME "mqtttest"
#define DEVICE_SECRET "aWp2N4ObAk8SZfJ81SSpfArZz16jVG45"
-#define MQTT_SUB_TOPIC "\"\/a1kecMbd2yb\/mqtttest\/get\""
-#define MQTT_PUB_TOPIC "\"\/a1kecMbd2yb\/mqtttest\/update\""
-#define MQTT_PUB_MSG "abcdefg"
+#define MQTT_SUB_TOPIC "/a1kecMbd2yb/mqtttest/get"
+#define MQTT_PUB_TOPIC "/a1kecMbd2yb/mqtttest/update"
+#define MQTT_PUB_MSG "{\"\"id\"\":\"\"a1D3oxFDwQJ_333333_mid\"\",\"\"params\"\":{\"\"_sys_device_mid\"\":\"\"example.demo.module-id\"\",\"\"_sys_device_pid\"\":\"\"example.demo.partner-id\"\"}}"
+extern int sal_init(void);
static void app_delayed_action(void *arg)
{
- LOG("helloworld %s:%d %s\r\n", __func__, __LINE__, aos_task_name());
+ char read_topic[128];
+ char read_msg[512];
+
+ if (at_mqtt_read_msg(read_topic, read_msg) == 0) {
+
+ printf("read topic: %s\r\n", read_topic);
+
+ printf("read msg_data: %s\r\n", read_msg);
+ }
+
aos_post_delayed_action(5000, app_delayed_action, NULL);
}
@@ -29,7 +43,7 @@ int application_start(int argc, char *argv[])
sal_init();
- LOG("application started.");
+ aos_msleep(1000);
// init the ica client module
ret = at_mqtt_ica_client_init();
@@ -50,7 +64,7 @@ int application_start(int argc, char *argv[])
// set topic info and qos
memset(mqtt_topic, 0, 128);
memcpy(mqtt_topic, MQTT_SUB_TOPIC, 128);
- mqtt_qos = 2;
+ mqtt_qos = 1;
aos_msleep(1000);
