Skip to content

Commit

Permalink
fixed:fix setWaypointEventCallback fail problem.
Browse files Browse the repository at this point in the history
OSDK-2590
  • Loading branch information
DJI-Colin committed Jun 4, 2020
1 parent 55296f6 commit ed2629c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions osdk-core/api/src/dji_legacy_linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ CmdListData cmdListData[] = {
{{0}, {0, 0, OpenProtocolCMD::CMDSet::Broadcast::broadcast[0], OpenProtocolCMD::CMDSet::Broadcast::broadcast[1], MASK_HOST_XXXXXX_SET_ID, malloc(sizeof(legacyAdaptingData)), NULL}},
{{0}, {0, 0, OpenProtocolCMD::CMDSet::Broadcast::fromMobile[0], OpenProtocolCMD::CMDSet::Broadcast::fromMobile[1], MASK_HOST_XXXXXX_SET_ID, malloc(sizeof(legacyAdaptingData)), NULL}},
{{0}, {0, 0, OpenProtocolCMD::CMDSet::Broadcast::fromPayload[0], OpenProtocolCMD::CMDSet::Broadcast::fromPayload[1], MASK_HOST_XXXXXX_SET_ID, malloc(sizeof(legacyAdaptingData)), NULL}},
{{0}, {0, 0, OpenProtocolCMD::CMDSet::Broadcast::waypoint[0], OpenProtocolCMD::CMDSet::Broadcast::waypoint[1], MASK_HOST_XXXXXX_SET_ID, malloc(sizeof(legacyAdaptingData)), NULL}},
{{0}, {0, 0, OpenProtocolCMD::CMDSet::HardwareSync::ppsNMEAGPSGSA[0], OpenProtocolCMD::CMDSet::HardwareSync::ppsNMEAGPSGSA[1], MASK_HOST_XXXXXX_SET_ID, malloc(sizeof(legacyAdaptingData)), NULL}},
{{0}, {0, 0, OpenProtocolCMD::CMDSet::HardwareSync::ppsNMEAGPSRMC[0], OpenProtocolCMD::CMDSet::HardwareSync::ppsNMEAGPSRMC[1], MASK_HOST_XXXXXX_SET_ID, malloc(sizeof(legacyAdaptingData)), NULL}},
{{0}, {0, 0, OpenProtocolCMD::CMDSet::HardwareSync::ppsNMEARTKGSA[0], OpenProtocolCMD::CMDSet::HardwareSync::ppsNMEARTKGSA[1], MASK_HOST_XXXXXX_SET_ID, malloc(sizeof(legacyAdaptingData)), NULL}},
Expand Down
5 changes: 5 additions & 0 deletions osdk-core/api/src/dji_waypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,11 @@ WaypointMission::setWaypointEventCallback(VehicleCallBack callback,
{
wayPointEventCallback.callback = callback;
wayPointEventCallback.userData = userData;
vehicle->legacyLinker->registerCMDCallback(
OpenProtocolCMD::CMDSet::Broadcast::waypoint[0],
OpenProtocolCMD::CMDSet::Broadcast::waypoint[1],
wayPointEventCallback.callback,
wayPointEventCallback.userData);
}

void
Expand Down
14 changes: 14 additions & 0 deletions sample/platform/linux/missions/mission_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/

#include "mission_sample.hpp"
#include "osdkosal_linux.h"

using namespace DJI::OSDK;
using namespace DJI::OSDK::Telemetry;
Expand Down Expand Up @@ -95,6 +96,15 @@ teardownSubscription(DJI::OSDK::Vehicle* vehicle, const int pkgIndex,
return true;
}

static void WaypointEventCallBack(Vehicle* vehicle, RecvContainer recvFrame,
UserData userData)
{
DSTATUS("%s",__FUNCTION__ );
DSTATUS("waypoint_index is %d.\n", recvFrame.recvData.wayPointReachedData.waypoint_index);
DSTATUS("current_status is %d.\n", recvFrame.recvData.wayPointReachedData.current_status);
DSTATUS("incident_type is %d.\n", recvFrame.recvData.wayPointReachedData.incident_type);
}

bool
runWaypointMission(Vehicle* vehicle, uint8_t numWaypoints, int responseTimeout)
{
Expand All @@ -120,6 +130,9 @@ runWaypointMission(Vehicle* vehicle, uint8_t numWaypoints, int responseTimeout)

ACK::ErrorCode initAck = vehicle->missionManager->init(
DJI_MISSION_TYPE::WAYPOINT, responseTimeout, &fdata);

vehicle->missionManager->wpMission->setWaypointEventCallback(&WaypointEventCallBack,vehicle);

if (ACK::getError(initAck))
{
ACK::getErrorCodeMessage(initAck, __func__);
Expand Down Expand Up @@ -149,6 +162,7 @@ runWaypointMission(Vehicle* vehicle, uint8_t numWaypoints, int responseTimeout)
std::cout << "Starting Waypoint Mission.\n";
}

OsdkOsal_TaskSleepMs(1200000);
// Cleanup before return. The mission isn't done yet, but it doesn't need any
// more input from our side.
if (!vehicle->isM100() && !vehicle->isLegacyM600())
Expand Down

0 comments on commit ed2629c

Please sign in to comment.