-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deepstream 5.0 Subscription Implementation #1
base: master
Are you sure you want to change the base?
Changes from 4 commits
2e29abb
2a7a3d6
9a5bc7a
b2c6940
bf90453
67dffec
5ca5006
4821a94
adc30df
f8f0099
7aa84e7
9a8ff42
bd3310d
7e4b8d9
f2cd2b9
3707004
2fd20b1
072dfbb
93deacc
9c1449a
fa94cc3
525ee45
579d7b4
d330130
819cdc0
0bac762
ef454fb
9c61435
d9fa5a6
54fff91
c99d2de
0c7895e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,6 +243,44 @@ NvDsMsgApiErrorType nvds_msgapi_send_async(NvDsMsgApiHandle h_ptr, char *topic, | |
return NVDS_MSGAPI_OK; | ||
} | ||
|
||
/* ************************************************************************* */ | ||
// Subscribe def | ||
/* ************************************************************************* */ | ||
|
||
void subscribe_callback_handler(AWS_IoT_Client *pClient, char *topicName, uint16_t topicNameLen, | ||
IoT_Publish_Message_Params *params, void *pData) | ||
{ | ||
IOT_INFO("Subscribe callback"); | ||
IOT_INFO("%.*s\t%.*s", topicNameLen, topicName, (int)params->payloadLen, (char *)params->payload); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this here? See comments below. |
||
|
||
NvDsMsgApiErrorType nvds_msgapi_subscribe(NvDsMsgApiHandle h_ptr, char **topics, int num_topics, nvds_msgapi_subscribe_request_cb_t cb, void *user_ctx) | ||
{ | ||
printf("Subscribe called\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should use the IOT logging functions. |
||
|
||
if ((h_ptr == NULL) || (topics == NULL) || (num_topics <= 0)) | ||
{ | ||
IOT_ERROR("Essensial args missing for function nvds_msgapi_subscribe: %d, %d, %d\n", (h_ptr == NULL), (topics == NULL), (num_topics == NULL); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: "essensial" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thats the typo in the whole file I will correct that in all other places as well |
||
return NVDS_MSGAPI_ERR; | ||
} | ||
if (!cb) | ||
{ | ||
IOT_ERROR("Callback function for nvds_msgapi_send cannot be NULL\n"); | ||
return NVDS_MSGAPI_ERR; | ||
} | ||
IoT_Error_t rc = FAILURE; | ||
AWS_IoT_Client *client = (AWS_IoT_Client *)h_ptr; | ||
rc = aws_iot_mqtt_subscribe(client, topics, strlen(topics), QOS0, subscribe_callback_handler, NULL); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please review the documentation for this function. There are a few problems here:
|
||
if (SUCCESS != rc) | ||
{ | ||
IOT_ERROR("Unable to subscribe, error: %d\n", rc); | ||
return NVDS_MSGAPI_ERR; | ||
} | ||
IOT_INFO("Successfully subscribed"); | ||
g_free(client); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You realize this will destroy the client, right? Why would we want to do that? |
||
return NVDS_MSGAPI_OK; | ||
} | ||
|
||
/* ************************************************************************* */ | ||
// Do Work function def | ||
/* ************************************************************************* */ | ||
|
@@ -277,7 +315,8 @@ void nvds_msgapi_do_work(NvDsMsgApiHandle h_ptr) | |
} | ||
return; | ||
} | ||
while (! g_queue_is_empty(work_queue)){ | ||
while (!g_queue_is_empty(work_queue)) | ||
{ | ||
Work *work_node = (Work *)g_queue_pop_head(work_queue); | ||
AWS_IoT_Client *client = (AWS_IoT_Client *)work_node->h_ptr; | ||
rc = _mqtt_msg_send(client, work_node->topic, work_node->payload, work_node->payload_size); | ||
|
@@ -291,7 +330,8 @@ void nvds_msgapi_do_work(NvDsMsgApiHandle h_ptr) | |
g_free(work_node); | ||
return; | ||
} | ||
if (work_node->call_back_handler != NULL){ | ||
if (work_node->call_back_handler != NULL) | ||
{ | ||
IOT_INFO("Pointer callback."); | ||
work_node->call_back_handler(work_node->user_ptr, NVDS_MSGAPI_OK); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get rid of this comment.