Skip to content

Commit b18ff22

Browse files
committed
LP-548 Removes create option from UAVTalkReceiveObject and creates a new function UAVTalkReceiveObjectNoCreate.
1 parent 4e6077c commit b18ff22

4 files changed

Lines changed: 30 additions & 7 deletions

File tree

flight/modules/RadioComBridge/RadioComBridge.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ static void ProcessTelemetryStream(UAVTalkConnection inConnectionHandle, UAVTalk
553553
case OPLINKSETTINGS_OBJID:
554554
case MetaObjectId(OPLINKSTATUS_OBJID):
555555
case MetaObjectId(OPLINKSETTINGS_OBJID):
556-
UAVTalkReceiveObject(inConnectionHandle, true);
556+
UAVTalkReceiveObject(inConnectionHandle);
557557
break;
558558
case OBJECTPERSISTENCE_OBJID:
559559
case MetaObjectId(OBJECTPERSISTENCE_OBJID):
@@ -566,7 +566,7 @@ static void ProcessTelemetryStream(UAVTalkConnection inConnectionHandle, UAVTalk
566566
// Second ack/nack will not match an open transaction or will apply to wrong transaction
567567
// Question : how does GCS handle receiving the same object twice
568568
// The OBJECTPERSISTENCE logic can be broken too if for example OPLM nacks and then REVO acks...
569-
UAVTalkReceiveObject(inConnectionHandle, true);
569+
UAVTalkReceiveObject(inConnectionHandle);
570570
// relay packet to remote modem
571571
UAVTalkRelayPacket(inConnectionHandle, outConnectionHandle);
572572
break;
@@ -611,7 +611,7 @@ static void ProcessRadioStream(UAVTalkConnection inConnectionHandle, UAVTalkConn
611611
case OPLINKRECEIVER_OBJID:
612612
case MetaObjectId(OPLINKRECEIVER_OBJID):
613613
// Receive object locally
614-
UAVTalkReceiveObject(inConnectionHandle, true);
614+
UAVTalkReceiveObject(inConnectionHandle);
615615
// Also send the packet to the telemetry point.
616616
UAVTalkRelayPacket(inConnectionHandle, outConnectionHandle);
617617
break;

flight/uavobjects/uavobjectmanager.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ uint16_t UAVObjCreateInstance(UAVObjHandle obj_handle)
511511
* \param[in] obj The object handle
512512
* \param[in] instId The instance ID
513513
* \param[in] dataIn The byte array
514+
* \param[in] create Create the object if it does not already exist.
514515
* \return 0 if success or -1 if failure
515516
*/
516517
int32_t UAVObjUnpack(UAVObjHandle obj_handle, uint16_t instId, const uint8_t *dataIn, bool create)

flight/uavtalk/inc/uavtalk.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ int32_t UAVTalkSendObjectRequest(UAVTalkConnection connection, UAVObjHandle obj,
6060
UAVTalkRxState UAVTalkProcessInputStream(UAVTalkConnection connectionHandle, uint8_t *rxbuffer, uint8_t length);
6161
UAVTalkRxState UAVTalkProcessInputStreamQuiet(UAVTalkConnection connectionHandle, uint8_t *rxbuffer, uint8_t length, uint8_t *position);
6262
int32_t UAVTalkRelayPacket(UAVTalkConnection inConnectionHandle, UAVTalkConnection outConnectionHandle);
63-
int32_t UAVTalkReceiveObject(UAVTalkConnection connectionHandle, bool create);
63+
int32_t UAVTalkReceiveObject(UAVTalkConnection connectionHandle);
64+
int32_t UAVTalkReceiveObjectNoCreate(UAVTalkConnection connectionHandle);
6465
void UAVTalkGetStats(UAVTalkConnection connection, UAVTalkStats *stats, bool reset);
6566
void UAVTalkAddStats(UAVTalkConnection connection, UAVTalkStats *stats, bool reset);
6667
void UAVTalkResetStats(UAVTalkConnection connection);

flight/uavtalk/uavtalk.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ UAVTalkRxState UAVTalkProcessInputStream(UAVTalkConnection connectionHandle, uin
444444
while (position < length) {
445445
state = UAVTalkProcessInputStreamQuiet(connectionHandle, rxbuffer, length, &position);
446446
if (state == UAVTALK_STATE_COMPLETE) {
447-
UAVTalkReceiveObject(connectionHandle, true);
447+
UAVTalkReceiveObject(connectionHandle);
448448
}
449449
}
450450
return state;
@@ -546,7 +546,7 @@ int32_t UAVTalkRelayPacket(UAVTalkConnection inConnectionHandle, UAVTalkConnecti
546546
* \return 0 Success
547547
* \return -1 Failure
548548
*/
549-
int32_t UAVTalkReceiveObject(UAVTalkConnection connectionHandle, bool create)
549+
int32_t UAVTalkReceiveObject(UAVTalkConnection connectionHandle)
550550
{
551551
UAVTalkConnectionData *connection;
552552

@@ -557,7 +557,28 @@ int32_t UAVTalkReceiveObject(UAVTalkConnection connectionHandle, bool create)
557557
return -1;
558558
}
559559

560-
return receiveObject(connection, iproc->type, iproc->objId, iproc->instId, connection->rxBuffer, create);
560+
return receiveObject(connection, iproc->type, iproc->objId, iproc->instId, connection->rxBuffer, true);
561+
}
562+
563+
/**
564+
* Complete receiving a UAVTalk packet. This will cause the packet to be unpacked, acked, etc.
565+
* This version will not create/unpack an object if it does not already exist.
566+
* \param[in] connectionHandle UAVTalkConnection to be used
567+
* \return 0 Success
568+
* \return -1 Failure
569+
*/
570+
int32_t UAVTalkReceiveObjectNoCreate(UAVTalkConnection connectionHandle)
571+
{
572+
UAVTalkConnectionData *connection;
573+
574+
CHECKCONHANDLE(connectionHandle, connection, return -1);
575+
576+
UAVTalkInputProcessor *iproc = &connection->iproc;
577+
if (iproc->state != UAVTALK_STATE_COMPLETE) {
578+
return -1;
579+
}
580+
581+
return receiveObject(connection, iproc->type, iproc->objId, iproc->instId, connection->rxBuffer, false);
561582
}
562583

563584
/**

0 commit comments

Comments
 (0)