Skip to content

Commit

Permalink
Integrating callback change
Browse files Browse the repository at this point in the history
  • Loading branch information
RLeclair committed Oct 10, 2023
1 parent 7973efa commit 41cbb0b
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 22 deletions.
6 changes: 3 additions & 3 deletions sdk/inc/azure/core/az_mqtt5_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ enum az_event_type_mqtt5_connection
* @brief Callback for MQTT 5 connection events.
*
*/
typedef az_result (*az_mqtt5_connection_callback)(az_mqtt5_connection* client, az_event event, const void* event_callback_context);
typedef az_result (*az_mqtt5_connection_callback)(az_mqtt5_connection* client, az_event event, void* event_callback_context);

/**
* @brief MQTT 5 connection options.
Expand Down Expand Up @@ -158,7 +158,7 @@ struct az_mqtt5_connection
* @brief Context for MQTT 5 connection events callback.
*
*/
const void* event_callback_context;
void* event_callback_context;

/**
* @brief Options for the MQTT 5 connection.
Expand Down Expand Up @@ -191,7 +191,7 @@ AZ_NODISCARD az_result az_mqtt5_connection_init(
az_mqtt5* mqtt_client,
az_mqtt5_connection_callback event_callback,
az_mqtt5_connection_options* options,
const void* event_callback_context);
void* event_callback_context);

/**
* @brief Opens the connection to the broker.
Expand Down
4 changes: 2 additions & 2 deletions sdk/samples/core/mosquitto_multiple_rpc_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ az_result check_for_commands_to_execute();
az_result copy_execution_event_data(
az_mqtt5_rpc_server_execution_req_event_data* destination,
az_mqtt5_rpc_server_execution_req_event_data source);
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, const void* callback_context);
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context);
void handle_response(az_span response_payload);
az_result invoke_stop_module();
az_result invoke_start_module();
Expand Down Expand Up @@ -252,7 +252,7 @@ void handle_response(az_span response_payload)
* @brief MQTT client callback function for all clients
* @note If you add other clients, you can add handling for their events here
*/
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, const void* callback_context)
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context)
{
(void)client;
(void)callback_context;
Expand Down
4 changes: 2 additions & 2 deletions sdk/samples/core/mosquitto_rpc_client_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static az_mqtt5_rpc_client_codec rpc_client_codec;

volatile bool sample_finished = false;

az_result mqtt_callback(az_mqtt5_connection* client, az_event event, const void* callback_context);
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context);
void handle_response(az_span response_payload);
az_result invoke_begin(az_span invoke_command_name, az_span payload);
void remove_expired_commands();
Expand All @@ -76,7 +76,7 @@ void handle_response(az_span response_payload)
* @brief MQTT client callback function for all clients
* @note If you add other clients, you can add handling for their events here
*/
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, const void* callback_context)
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context)
{
(void)client;
(void)callback_context;
Expand Down
4 changes: 2 additions & 2 deletions sdk/samples/core/mosquitto_rpc_server_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ az_result check_for_commands();
az_result copy_execution_event_data(
az_mqtt5_rpc_server_execution_req_event_data* destination,
az_mqtt5_rpc_server_execution_req_event_data source);
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, const void* callback_context);
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context);

void az_platform_critical_error()
{
Expand Down Expand Up @@ -236,7 +236,7 @@ az_result copy_execution_event_data(
* @brief MQTT client callback function for all clients
* @note If you add other clients, you can add handling for their events here
*/
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, const void* callback_context)
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context)
{
(void)client;
(void)callback_context;
Expand Down
7 changes: 4 additions & 3 deletions sdk/samples/core/paho_multiple_rpc_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ az_result check_for_commands_to_execute();
az_result copy_execution_event_data(
az_mqtt5_rpc_server_execution_req_event_data* destination,
az_mqtt5_rpc_server_execution_req_event_data source);
az_result mqtt_callback(az_mqtt5_connection* client, az_event event);
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context);
void handle_response(az_span response_payload);
az_result invoke_stop_module();
az_result invoke_start_module();
Expand Down Expand Up @@ -252,9 +252,10 @@ void handle_response(az_span response_payload)
* @brief MQTT client callback function for all clients
* @note If you add other clients, you can add handling for their events here
*/
az_result mqtt_callback(az_mqtt5_connection* client, az_event event)
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context)
{
(void)client;
(void)callback_context;
az_app_log_callback(event.type, AZ_SPAN_FROM_STR("APP/callback"));
switch (event.type)
{
Expand Down Expand Up @@ -492,7 +493,7 @@ int main(int argc, char* argv[])
connection_options.client_certificates[0] = primary_credential;

LOG_AND_EXIT_IF_FAILED(az_mqtt5_connection_init(
&mqtt_connection, &connection_context, &mqtt5, mqtt_callback, &connection_options));
&mqtt_connection, &connection_context, &mqtt5, mqtt_callback, &connection_options, NULL));

LOG_AND_EXIT_IF_FAILED(az_platform_mutex_init(&pending_server_command_mutex));

Expand Down
7 changes: 4 additions & 3 deletions sdk/samples/core/paho_rpc_client_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static az_mqtt5_rpc_client_codec rpc_client_codec;

volatile bool sample_finished = false;

az_result mqtt_callback(az_mqtt5_connection* client, az_event event);
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context);
void handle_response(az_span response_payload);
az_result invoke_begin(az_span invoke_command_name, az_span payload);
void remove_expired_commands();
Expand All @@ -76,9 +76,10 @@ void handle_response(az_span response_payload)
* @brief MQTT client callback function for all clients
* @note If you add other clients, you can add handling for their events here
*/
az_result mqtt_callback(az_mqtt5_connection* client, az_event event)
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context)
{
(void)client;
(void)callback_context;
az_app_log_callback(event.type, AZ_SPAN_FROM_STR("APP/callback"));
switch (event.type)
{
Expand Down Expand Up @@ -251,7 +252,7 @@ int main(int argc, char* argv[])
connection_options.client_certificates[0] = primary_credential;

LOG_AND_EXIT_IF_FAILED(az_mqtt5_connection_init(
&mqtt_connection, &connection_context, &mqtt5, mqtt_callback, &connection_options));
&mqtt_connection, &connection_context, &mqtt5, mqtt_callback, &connection_options, NULL));

az_mqtt5_property_bag property_bag;
MQTTProperties prop = MQTTProperties_initializer;
Expand Down
7 changes: 4 additions & 3 deletions sdk/samples/core/paho_rpc_server_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ az_result check_for_commands();
az_result copy_execution_event_data(
az_mqtt5_rpc_server_execution_req_event_data* destination,
az_mqtt5_rpc_server_execution_req_event_data source);
az_result mqtt_callback(az_mqtt5_connection* client, az_event event);
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context);

void az_platform_critical_error()
{
Expand Down Expand Up @@ -236,9 +236,10 @@ az_result copy_execution_event_data(
* @brief MQTT client callback function for all clients
* @note If you add other clients, you can add handling for their events here
*/
az_result mqtt_callback(az_mqtt5_connection* client, az_event event)
az_result mqtt_callback(az_mqtt5_connection* client, az_event event, void* callback_context)
{
(void)client;
(void)callback_context;
az_app_log_callback(event.type, AZ_SPAN_FROM_STR("APP/callback"));
switch (event.type)
{
Expand Down Expand Up @@ -341,7 +342,7 @@ int main(int argc, char* argv[])
connection_options.client_certificates[0] = primary_credential;

LOG_AND_EXIT_IF_FAILED(az_mqtt5_connection_init(
&mqtt_connection, &connection_context, &mqtt5, mqtt_callback, &connection_options));
&mqtt_connection, &connection_context, &mqtt5, mqtt_callback, &connection_options, NULL));

LOG_AND_EXIT_IF_FAILED(az_platform_mutex_init(&pending_command_mutex));

Expand Down
2 changes: 1 addition & 1 deletion sdk/src/azure/core/az_mqtt5_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AZ_NODISCARD az_result az_mqtt5_connection_init(
az_mqtt5* mqtt_client,
az_mqtt5_connection_callback event_callback,
az_mqtt5_connection_options* options,
const void* event_callback_context)
void* event_callback_context)
{
_az_PRECONDITION_NOT_NULL(client);
_az_PRECONDITION_NOT_NULL(mqtt_client);
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/core/test_az_mqtt5_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static az_result test_subclient_policy_2_root(az_event_policy* me, az_event even
return AZ_OK;
}

static az_result test_mqtt_connection_callback(az_mqtt5_connection* client, az_event event, const void* callback_context)
static az_result test_mqtt_connection_callback(az_mqtt5_connection* client, az_event event, void* callback_context)
{
(void)client;
(void)callback_context;
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/core/test_az_mqtt5_rpc_client_hfsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static az_result test_subclient_policy_1_root(az_event_policy* me, az_event even
return AZ_OK;
}

static az_result test_mqtt_connection_callback(az_mqtt5_connection* client, az_event event, const void* event_callback_context)
static az_result test_mqtt_connection_callback(az_mqtt5_connection* client, az_event event, void* event_callback_context)
{
(void)client;
(void)event_callback_context;
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/core/test_az_mqtt5_rpc_server_hfsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static az_result test_subclient_policy_1_root(az_event_policy* me, az_event even
return AZ_OK;
}

static az_result test_mqtt_connection_callback(az_mqtt5_connection* client, az_event event, const void* event_callback_context)
static az_result test_mqtt_connection_callback(az_mqtt5_connection* client, az_event event, void* event_callback_context)
{
(void)client;
(void)event_callback_context;
Expand Down

0 comments on commit 41cbb0b

Please sign in to comment.