修改摄像头控制bug
wifi连接到4g环境
This commit is contained in:
parent
96df77d785
commit
c2356769bd
@ -331,6 +331,13 @@ void FoodCube::udpSendToCamera(uint8_t* p_command, uint32_t len) {
|
||||
}
|
||||
bytes[len] = static_cast<uint8_t>(result); // 低位 互换
|
||||
bytes[len + 1] = static_cast<uint8_t>(result >> 8); // 高位 互换
|
||||
|
||||
/* //发送日志
|
||||
printf("SendToCamera:");
|
||||
for (int i=0;i<len+2;i++)
|
||||
printf("0x%02X,", bytes[i]);
|
||||
printf("\n");
|
||||
*/
|
||||
//udp发送命令帧
|
||||
udp.beginPacket(udpServerIP, udpServerPort);
|
||||
udp.write(bytes, len + 2);
|
||||
|
26
src/main.cpp
26
src/main.cpp
@ -88,8 +88,8 @@ unsigned long _tm_waitinit;
|
||||
/*项目对象*/
|
||||
//char* ssid = "szdot"; //wifi帐号
|
||||
//char* password = "Ttaj@#*.com"; //wifi密码
|
||||
char* ssid = (char*)"flicube"; //wifi帐号
|
||||
char* password = (char*)"fxmf0622"; //wifi密码
|
||||
char* ssid = (char*)"fxmf_sc01"; //wifi帐号
|
||||
char* password = (char*)"12345678"; //wifi密码
|
||||
char* mqttServer = (char*)"szdot.top"; //mqtt地址
|
||||
int mqttPort = 1883; //mqtt端口
|
||||
char* mqttName = (char*)"admin"; //mqtt帐号
|
||||
@ -774,27 +774,29 @@ void mqtt_receiveCallback(char* topic, byte* payload, unsigned int length) {
|
||||
DynamicJsonDocument doc(0x2FFF);
|
||||
deserializeJson(doc, topicStr);
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
|
||||
//相机控制
|
||||
uint8_t item=obj["item"];
|
||||
|
||||
size_t len;
|
||||
if (obj["item"] == "0") { //0:一键回中
|
||||
if (item ==0) { //0:一键回中
|
||||
uint8_t command[] = { 0x55, 0x66, 0x01, 0x01, 0x00, 0x00, 0x00, 0x08, 0x01 };
|
||||
len = sizeof(command);
|
||||
fc.udpSendToCamera(command, len);
|
||||
} else if (obj["item"] == "1") { //1:变焦
|
||||
uint8_t command[] = { 0x55, 0x66, 0x01, 0x01, 0x00, 0x00, 0x00, 0x05, 0x0 };
|
||||
// strval=(obj["val"] as String);
|
||||
command[8] = (uint8_t)obj["val"];
|
||||
} else if (item == 1) { //1:变焦
|
||||
uint8_t command[] = { 0x55, 0x66, 0x01, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00 };
|
||||
command[8] = obj["val"];
|
||||
len = sizeof(command);
|
||||
fc.udpSendToCamera(command, len);
|
||||
} else if (obj["item"] == "2") { //2:俯仰,旋转
|
||||
} else if (item == 2) { //2:俯仰,旋转
|
||||
uint8_t command[] = { 0x55, 0x66, 0x01, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00 };
|
||||
command[9] = (uint8_t)obj["pitch"]; //俯仰
|
||||
command[8] = (uint8_t)obj["yaw"]; //旋转
|
||||
int8_t pitchvalue=obj["pitch"];
|
||||
int8_t yawvalue=obj["yaw"];
|
||||
command[9] =pitchvalue; //俯仰
|
||||
command[8] =yawvalue; //旋转
|
||||
|
||||
len = sizeof(command);
|
||||
fc.udpSendToCamera(command, len);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user