|
@@ -103,14 +103,16 @@ uint32_t getFileCrc32(char *filename)
|
|
|
{
|
|
|
struct stat st;
|
|
|
stat(filename, &st);
|
|
|
- uint8_t data[st.st_size];
|
|
|
+ uint8_t *data;
|
|
|
+ data = malloc(st.st_size);
|
|
|
|
|
|
if(read(fd,data,st.st_size) == st.st_size)
|
|
|
{
|
|
|
result = crc32(data, st.st_size);
|
|
|
+ close(fd);
|
|
|
}
|
|
|
|
|
|
- close(fd);
|
|
|
+ free(data);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
@@ -304,12 +306,19 @@ int on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_me
|
|
|
*/
|
|
|
if(strstr(msg->topic, "client/connect"))
|
|
|
{
|
|
|
- DEBUG_INFO("HW_version: %s\n", json_object_get_string(json_object_object_get(payload, "HW_version")));
|
|
|
- DEBUG_INFO("FW_version_OS: %s\n", json_object_get_string(json_object_object_get(payload, "FW_version_OS")));
|
|
|
- DEBUG_INFO("FW_version_APK: %s\n", json_object_get_string(json_object_object_get(payload, "FW_version_APK")));
|
|
|
- DEBUG_INFO("FW_version_UI: %s\n", json_object_get_string(json_object_object_get(payload, "FW_version_UI")));
|
|
|
- DEBUG_INFO("MAC_addr: %s\n", json_object_get_string(json_object_object_get(payload, "MAC_addr")));
|
|
|
- DEBUG_INFO("Orientation: %s\n", json_object_get_string(json_object_object_get(payload, "Orientation")));
|
|
|
+ sprintf((char*)clientInfo.verHW, "%s", json_object_get_string(json_object_object_get(payload, "HW_version")));
|
|
|
+ sprintf((char*)clientInfo.verFW_OS, "%s", json_object_get_string(json_object_object_get(payload, "FW_version_OS")));
|
|
|
+ sprintf((char*)clientInfo.verFW_APK, "%s", json_object_get_string(json_object_object_get(payload, "FW_version_APK")));
|
|
|
+ sprintf((char*)clientInfo.verFW_UI, "%s", json_object_get_string(json_object_object_get(payload, "FW_version_UI")));
|
|
|
+ sprintf((char*)clientInfo.macAddr, "%s", json_object_get_string(json_object_object_get(payload, "MAC_addr")));
|
|
|
+ sprintf((char*)clientInfo.orientation, "%s", json_object_get_string(json_object_object_get(payload, "Orientation")));
|
|
|
+
|
|
|
+ DEBUG_INFO("HW_version: %s\n", clientInfo.verHW);
|
|
|
+ DEBUG_INFO("FW_version_OS: %s\n", clientInfo.verFW_OS);
|
|
|
+ DEBUG_INFO("FW_version_APK: %s\n", clientInfo.verFW_APK);
|
|
|
+ DEBUG_INFO("FW_version_UI: %s\n", clientInfo.verFW_UI);
|
|
|
+ DEBUG_INFO("MAC_addr: %s\n", clientInfo.macAddr);
|
|
|
+ DEBUG_INFO("Orientation: %s\n", clientInfo.orientation);
|
|
|
}
|
|
|
else if(strstr(msg->topic, "client/touch"))
|
|
|
{
|
|
@@ -346,11 +355,27 @@ int on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_me
|
|
|
case 5:
|
|
|
DEBUG_INFO("Status reset.\n");
|
|
|
break;
|
|
|
+ case 6:
|
|
|
+ DEBUG_INFO("Status sleep.\n");
|
|
|
+ break;
|
|
|
+ case 255:
|
|
|
+ DEBUG_INFO("Status fault.\n");
|
|
|
+ break;
|
|
|
default:
|
|
|
DEBUG_INFO("Unknown status.\n");
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if(json_object_object_get(payload, "temperature") != NULL)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Temperature: %s.\n", json_object_get_string(json_object_object_get(payload, "temperature")));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(json_object_object_get(payload, "cpu_temperatue") != NULL)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("CPU temperature: %s.\n", json_object_get_string(json_object_object_get(payload, "cpu_temperatue")));
|
|
|
+ }
|
|
|
}
|
|
|
else if(strstr(msg->topic, "client/profile") ||
|
|
|
strstr(msg->topic, "client/command") ||
|
|
@@ -580,10 +605,10 @@ int publish_upgrade_sample(struct mosquitto *mosq)
|
|
|
char chkCrc32[16];
|
|
|
|
|
|
sprintf(url, "ftp://ftpuser:ftppasswd@%s/mnt/dummy_Image.zip", BROKER_ADDRESS);
|
|
|
+ sprintf(chkCrc32, "0x%08X", getFileCrc32("/mnt/dummy_Image.zip"));
|
|
|
+ DEBUG_INFO("image file crc32: %s\n", chkCrc32);
|
|
|
|
|
|
- sprintf(chkCrc32, "0x%08X", getFileCrc32("/root/main"));
|
|
|
-
|
|
|
- return publish_upgrade(mosq, OTA_TYPE_UI, url, chkCrc32, "V0.01");
|
|
|
+ return publish_upgrade(mosq, OTA_TYPE_SDCARD, url, chkCrc32, "V0.01");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -592,7 +617,7 @@ int publish_upgrade_sample(struct mosquitto *mosq)
|
|
|
*/
|
|
|
int publish_restart_sample(struct mosquitto *mosq)
|
|
|
{
|
|
|
- return publish_restart(mosq, TRUE);
|
|
|
+ return publish_restart(mosq, FALSE);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -637,8 +662,8 @@ int publish_textview_add_sample(struct mosquitto *mosq)
|
|
|
sprintf(textList[idx].textFont, FONT_ARIAL);
|
|
|
sprintf(textList[idx].textStyle, FONT_STYLE_NORMAL);
|
|
|
textList[idx].textSize = FONT_SIZE_20PX;
|
|
|
- textList[idx].layout_x = (rand()%800+100);
|
|
|
- textList[idx].layout_y = (rand()%800+100);
|
|
|
+ textList[idx].layout_x = 10;//(rand()%800+100);
|
|
|
+ textList[idx].layout_y = 10;//(rand()%800+100);
|
|
|
}
|
|
|
|
|
|
return publish_textview_add(mosq, textList, ARRAY_SIZE(textList));
|
|
@@ -656,8 +681,8 @@ int publish_imageview_add_sample(struct mosquitto *mosq)
|
|
|
{
|
|
|
imageList[idx].imageviewIndex = idx;
|
|
|
imageList[idx].imgsrc_addr = (rand()%10+0);
|
|
|
- imageList[idx].layout_x = (rand()%800+100);
|
|
|
- imageList[idx].layout_y = (rand()%800+100);
|
|
|
+ imageList[idx].layout_x = 100;//(rand()%800+100);
|
|
|
+ imageList[idx].layout_y = 100;//(rand()%800+100);
|
|
|
imageList[idx].width = (rand()%800+100);
|
|
|
imageList[idx].height = (rand()%800+100);
|
|
|
}
|
|
@@ -676,15 +701,38 @@ int publish_videoview_add_sample(struct mosquitto *mosq)
|
|
|
for(int idx=0;idx<ARRAY_SIZE(videoList);idx++)
|
|
|
{
|
|
|
videoList[idx].videoviewIndex = idx;
|
|
|
- videoList[idx].videosrc_addr = (rand()%10+0);
|
|
|
- videoList[idx].layout_x = (rand()%800+100);
|
|
|
- videoList[idx].layout_y = (rand()%800+100);
|
|
|
+ videoList[idx].videosrc_addr = 11;//(rand()%10+0);
|
|
|
+ videoList[idx].layout_x = 200;//(rand()%800+100);
|
|
|
+ videoList[idx].layout_y = 200;//(rand()%800+100);
|
|
|
videoList[idx].width = (rand()%800+100);
|
|
|
videoList[idx].height = (rand()%800+100);
|
|
|
}
|
|
|
|
|
|
return publish_videoview_add(mosq, videoList, ARRAY_SIZE(videoList));
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param mosq
|
|
|
+ */
|
|
|
+int publish_qr_code_image(struct mosquitto *mosq)
|
|
|
+{
|
|
|
+ QrCode_List qrCodeList[2] = {0};
|
|
|
+
|
|
|
+ for(int idx=0;idx<ARRAY_SIZE(qrCodeList);idx++)
|
|
|
+ {
|
|
|
+ qrCodeList[idx].qrCodeIndex = idx;
|
|
|
+ sprintf((char*)qrCodeList[idx].qrCodeContent, "djsalkdjskjslkdjsalkdjslkdjsalkdjsal");
|
|
|
+ sprintf((char*)qrCodeList[idx].errorCorrection, "M");
|
|
|
+ qrCodeList[idx].layout_x = 100;//(rand()%800+100);
|
|
|
+ qrCodeList[idx].layout_y = 100;//(rand()%800+100);
|
|
|
+ qrCodeList[idx].width = (rand()%800+100);
|
|
|
+ qrCodeList[idx].height = (rand()%800+100);
|
|
|
+ }
|
|
|
+
|
|
|
+ return publish_qrcodeimage_add(mosq, qrCodeList, ARRAY_SIZE(qrCodeList));
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param mosq
|
|
@@ -694,6 +742,7 @@ int publish_view_remove_sample(struct mosquitto *mosq)
|
|
|
Text_List textList[2] = {0};
|
|
|
Image_List imageList[2] = {0};
|
|
|
Video_List videoList[2] = {0};
|
|
|
+ QrCode_List qrCodeList[2] = {0};
|
|
|
|
|
|
// Remove text view
|
|
|
for(int idx=0;idx<ARRAY_SIZE(textList);idx++)
|
|
@@ -713,7 +762,13 @@ int publish_view_remove_sample(struct mosquitto *mosq)
|
|
|
videoList[idx].videoviewIndex = idx;
|
|
|
}
|
|
|
|
|
|
- return publish_view_remove(mosq, textList, ARRAY_SIZE(textList), imageList, ARRAY_SIZE(imageList), videoList, ARRAY_SIZE(videoList));
|
|
|
+ // Remove qrCode view
|
|
|
+ for(int idx=0;idx<ARRAY_SIZE(qrCodeList);idx++)
|
|
|
+ {
|
|
|
+ qrCodeList[idx].qrCodeIndex = idx;
|
|
|
+ }
|
|
|
+
|
|
|
+ return publish_view_remove(mosq, textList, ARRAY_SIZE(textList), imageList, ARRAY_SIZE(imageList), videoList, ARRAY_SIZE(videoList), qrCodeList, ARRAY_SIZE(qrCodeList));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1039,6 +1094,7 @@ int main(void)
|
|
|
printf("\n 11: publish_clear_screen.");
|
|
|
printf("\n 12: publish_audio_volume.");
|
|
|
printf("\n 13: publish_trigger_report_status.");
|
|
|
+ printf("\n 14: publish_qr_code_image.");
|
|
|
printf("\n ==================================================");
|
|
|
printf("\n Please input item to test: ");
|
|
|
scanf("%s", &cmd[0]);
|
|
@@ -1083,6 +1139,8 @@ int main(void)
|
|
|
break;
|
|
|
case 13:
|
|
|
publish_trigger_report_status_sample(mosq);
|
|
|
+ case 14:
|
|
|
+ publish_qr_code_image(mosq);
|
|
|
break;
|
|
|
}
|
|
|
#endif
|