AWS IoT Jobs v2.0.0
Client library for AWS IoT Jobs
 
Loading...
Searching...
No Matches
Jobs_GetPending
size_t length,
const char * thingName,
uint16_t thingNameLength,
size_t * outLength );
JobsStatus_t
Return codes from jobs functions.
Definition: jobs.h:258
JobsStatus_t Jobs_GetPending(char *buffer, size_t length, const char *thingName, uint16_t thingNameLength, size_t *outLength)
Populate a topic string for a GetPendingJobExecutions request.
Definition: jobs.c:666

Populate a topic string for a GetPendingJobExecutions request.

Parameters
[in]bufferThe buffer to contain the topic string.
[in]lengthThe size of the buffer.
[in]thingNameThe device's thingName as registered with AWS IoT.
[in]thingNameLengthThe length of the thingName.
[out]outLengthThe length of the topic string written to the buffer.
Returns
JobsSuccess if the topic was written to the buffer; JobsBadParameter if invalid parameters are passed; JobsBufferTooSmall if the buffer cannot hold the full topic string.

When all parameters are valid, the topic string is written to the buffer up to one less than the buffer size. The topic is ended with a NUL character.

Note
The thingName parameter does not need a NUL terminator.
The AWS IoT Jobs service does not require clients to subscribe to the "/accepted" and "/rejected" response topics of the GetPendingJobExecutions API. The Jobs service will send responses to requests published to the API from clients irrespective of whether they have subscribed to response topics or not. For more information, refer to the AWS docs here: https://docs.aws.amazon.com/iot/latest/developerguide/jobs-mqtt-api.html

Example

// The following example shows usage of the Jobs_GetPending API to
// generate topic string for the GetPendingJobExecutions API
// of the AWS IoT Jobs service.
// Every device should have a unique thing name registered with AWS IoT Core.
// This example uses a dummy serial number for the thing name.
#define THING_NAME "11223445566"
#define THING_NAME_LENGTH ( sizeof( THING_NAME ) - 1U )
// This example allocates a buffer of maximum length for a Jobs topic
// possible for the thing name using the JOBS_API_MAX_LENGTH macro.
char topicBuffer[ JOBS_API_MAX_LENGTH( THING_NAME_LENGTH ) ] = { 0 };
uint16_t topicLength = 0U;
status = Jobs_GetPending( topicBuffer,
sizeof( topicBuffer ),
THING_NAME,
THING_NAME_LENGTH,
&( topicLength ) );
if( status == JobsSuccess )
{
// The topic string of length, topicLength, has been
// generated in the buffer, topicBuffer, for the GetPendingJobExecutions API.
// Publish to this topic using an MQTT client of your choice.
}
#define JOBS_API_MAX_LENGTH(thingNameLength)
The size needed to hold the longest topic for a given thing name length.
Definition: jobs.h:248
@ JobsSuccess
The buffer was properly written or a match was found.
Definition: jobs.h:260

See jobs.h for docs.