Mistake on this page? Email us
pt_client_api.h
Go to the documentation of this file.
1 /*
2  * ----------------------------------------------------------------------------
3  * Copyright 2019 ARM Ltd.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ----------------------------------------------------------------------------
19  */
20 
21 #ifndef PT_API_VERSION
22 #define PT_API_VERSION 2
23 #endif
24 #if PT_API_VERSION != 2
25 #error "Including mixed versions of Protocol API"
26 #endif
27 
28 #ifndef PT_CLIENT_API_H
29 #define PT_CLIENT_API_H
30 
33 
52 int pt_api_init();
53 
65 typedef void (*pt_response_handler)(void *userdata);
66 
75 typedef void (*pt_connection_ready_cb)(connection_id_t connection_id, const char *name, void *userdata);
76 
84 typedef void (*pt_disconnected_cb)(connection_id_t connection_id, void *userdata);
85 
93 typedef void (*pt_connection_shutdown_cb)(connection_id_t connection_id, void *userdata);
94 
98 typedef struct protocol_translator_callbacks {
99  pt_connection_ready_cb connection_ready_cb;
100  pt_disconnected_cb disconnected_cb;
101  pt_connection_shutdown_cb connection_shutdown_cb;
102  pt_certificate_renewal_notification_handler certificate_renewal_notifier_cb;
103  pt_device_certificate_renew_request_handler device_certificate_renew_request_cb;
105 
114 pt_client_t *pt_client_create(const char *socket_path,
115  const protocol_translator_callbacks_t *pt_cbs);
116 
122 void pt_client_free(pt_client_t *client);
123 
131 connection_id_t pt_client_get_connection_id(pt_client_t *client);
132 
152 int pt_client_start(pt_client_t *client,
153  pt_response_handler success_handler,
154  pt_response_handler failure_handler,
155  const char *name,
156  void *userdata);
157 
166 pt_status_t pt_client_shutdown(pt_client_t *client);
167 
173 #endif
void(* pt_connection_ready_cb)(connection_id_t connection_id, const char *name, void *userdata)
A function prototype for calling the client code when the connection is ready for passing messages...
Definition: pt_client_api.h:75
struct protocol_translator_callbacks protocol_translator_callbacks_t
A structure to hold the callbacks of the protocol translator.
void pt_client_free(pt_client_t *client)
Frees the PT API client.
void(* pt_certificate_renewal_notification_handler)(const connection_id_t connection_id, const char *name, int32_t initiator, int32_t status, const char *description, void *userdata)
Type definition for certificate renewal notification. This callback will be called to notify the stat...
Definition: pt_certificate_api.h:123
void(* pt_disconnected_cb)(connection_id_t connection_id, void *userdata)
A function prototype for calling the client code when the connection is disconnected.
Definition: pt_client_api.h:84
pt_status_t pt_client_shutdown(pt_client_t *client)
Gracefully shuts down the protocol translator client.
Contains common structures and definitions for the protocol translator client.
API for subscribing certificate renewal notications and renewing certificates.
connection_id_t pt_client_get_connection_id(pt_client_t *client)
May be used to get the connection ID from the client.
A structure to hold the callbacks of the protocol translator.
Definition: pt_api.h:344
pt_status_t(* pt_device_certificate_renew_request_handler)(const connection_id_t connection_id, const char *device_id, const char *name, void *userdata)
Type definition for certificate renewal request handler for device certificate. This callback will be...
Definition: pt_certificate_api.h:164
void(* pt_connection_shutdown_cb)(connection_id_t connection_id, void *userdata)
A function prototype for calling the client code when the connection is shutting down.
Definition: pt_client_api.h:93
int pt_client_start(pt_client_t *client, pt_response_handler success_handler, pt_response_handler failure_handler, const char *name, void *userdata)
Starts the protocol translator client event loop and tries to connect to a local instance of Device M...
int pt_api_init()
Use this function to initialize the PT API.
void(* pt_response_handler)(void *userdata)
A function pointer type definition for callbacks given in the protocol translator API functions as an...
Definition: pt_client_api.h:65
pt_client_t * pt_client_create(const char *socket_path, const protocol_translator_callbacks_t *pt_cbs)
Creates an instance of a PT API client.