AWS IoT Jobs v1.5.1
Client library for AWS IoT Jobs
 
Loading...
Searching...
No Matches
Jobs_MatchTopic
size_t length,
const char * thingName,
uint16_t thingNameLength,
JobsTopic_t * outApi,
char ** outJobId,
uint16_t * outJobIdLength );
JobsTopic_t
Topic values for subscription requests.
Definition: jobs.h:301
JobsStatus_t
Return codes from jobs functions.
Definition: jobs.h:255
JobsStatus_t Jobs_MatchTopic(char *topic, size_t length, const char *thingName, uint16_t thingNameLength, JobsTopic_t *outApi, char **outJobId, uint16_t *outJobIdLength)
Output a topic value if a Jobs API topic string is present. Optionally, output a pointer to a jobID w...
Definition: jobs.c:597

Output a topic value if a Jobs API topic string is present. Optionally, output a pointer to a jobID within the topic and its length.

Parameters
[in]topicThe topic string to check.
[in]lengthThe length of the topic string.
[in]thingNameThe device's thingName as registered with AWS IoT.
[in]thingNameLengthThe length of the thingName.
[out]outApiThe jobs topic API value if present, e.g., JobsUpdateSuccess.
[out]outJobIdThe beginning of the jobID in the topic string.
[out]outJobIdLengthThe length of the jobID in the topic string.
Returns
JobsSuccess if a matching topic was found; JobsNoMatch if a matching topic was NOT found (parameter outApi gets JobsInvalidTopic ); JobsBadParameter if invalid parameters are passed.
Note
The topic and thingName parameters do not need a NUL terminator.
Not all Jobs APIs have jobIDs within the topic string. NULL and 0 are output when no jobID is present. The parameters jobId and jobIdLength may be NULL.

Example

// The following example shows how to use the Jobs_MatchTopic API to
// check if an incoming MQTT publish message is from the AWS IoT Jobs
// service.
// Assuming that these variables contain incoming topic data received
// from the MQTT client used.
char * pIncomingTopic;
size_t topicLength;
// Every device should have a unique thing name registered with AWS IoT Core.
// This example uses a dummy serial number for the thing name.
// The Jobs_MatchTopic API will check that the incoming message topic contains
// this thing name.
#define THING_NAME "11223445566"
#define THING_NAME_LENGTH ( sizeof( THING_NAME ) - 1U )
char * pJobId = NULL;
uint16_t jobIdLength;
status = Jobs_MatchTopic( pIncomingTopic,
topicLength,
THING_NAME,
THING_NAME_LENGTH,
&api,
&pJobId,
&jobIdLength );
if( status == JobsSuccess )
{
// The Jobs_MatchTopic API has determined that the incoming topic is from
// AWS IoT Jobs service for the expected thing name.
// If the topic contains a jobID, then the pJobId and jobIdLength parameters
// populated by the API.
if( api == JobsJobsChanged )
{ // Message from JobExecutionsChanged API.
}
else if( api == JobsNextJobChanged )
{ // Message from NextJobExecutionChanged API.
}
else if( api == JobsGetPendingSuccess )
{ // Received accepted response for request to GetPendingJobExecutions API.
}
else if( api == JobsGetPendingFailed )
{ // Received rejected response for request to GetPendingJobExecutions API.
}
else if( api == JobsStartNextSuccess )
{ // Received accepted response for request to StartNextPendingJobExecution API.
}
else if( api == JobsStartNextFailed )
{ // Received rejected response for request to StartNextPendingJobExecution API.
}
else if( api == JobsDescribeSuccess )
{ // Received accepted response for request to DescribeJobExecution API.
}
else if( api == JobsDescribeFailed )
{ // Received rejected response for request to DescribeJobExecution API.
}
else if( api == JobsUpdateSuccess )
{ // Received accepted response for request to UpdateJobExecution API.
}
else if( api == JobsUpdateFailed )
{ // Received rejected response for request to UpdateJobExecution API.
}
else
{
// Unexpected response.
}
}
@ JobsSuccess
The buffer was properly written or a match was found.
Definition: jobs.h:257

Output a topic value if a Jobs API topic string is present. Optionally, output a pointer to a jobID within the topic and its length.

See jobs.h for docs.