Remote Vehicle Interaction C API
rvi.h
Go to the documentation of this file.
1 /* Copyright (c) 2016, Jaguar Land Rover. All Rights Reserved.
2  *
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, you can obtain one at http://mozilla.org/MPL/2.0.
6  */
7 
8 #ifndef _RVI_H
9 #define _RVI_H
10 
11 #include <stddef.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
50 // **********
51 // DATA TYPES
52 // **********
53 
55 typedef void *TRviHandle;
56 
58 typedef void (*TRviCallback) ( int fd,
59  void* serviceData,
60  const char *parameters
61  );
62 
64 typedef enum {
66  RVI_OK = 0,
72  RVI_ERR_JSON = 1002,
82  RVI_ERR_NOCRED = 1007,
84  RVI_ERR_NOCMD = 1008,
89 } ERviStatus;
90 
91 // ***************************
92 // INITIALIZATION AND TEARDOWN
93 // ***************************
94 
123 extern TRviHandle rviInit(char *configFilename);
124 
137 extern int rviCleanup(TRviHandle handle);
138 
139 // *************************
140 // RVI CONNECTION MANAGEMENT
141 // *************************
142 
168 extern int rviConnect(TRviHandle handle, const char *addr, const char *port);
169 
178 extern int rviDisconnect(TRviHandle handle, int fd);
179 
198 extern int rviGetConnections(TRviHandle handle, int *conn, int *connSize);
199 
200 // **********************
201 // RVI SERVICE MANAGEMENT
202 // **********************
203 
226 extern int rviRegisterService( TRviHandle handle, const char *serviceName,
227  TRviCallback callback,
228  void* serviceData );
229 
246 extern int rviUnregisterService( TRviHandle handle,
247  const char *serviceName );
248 
265 extern int rviGetServices( TRviHandle handle, char **result, int* len );
266 
287 extern int rviInvokeService( TRviHandle handle,
288  const char *serviceName,
289  const char *parameters );
290 
291 
292 // ******************
293 // RVI I/O MANAGEMENT
294 // ******************
295 
318 extern int rviProcessInput(TRviHandle handle, int* fdArr, int fdLen);
319 
320 #ifdef __cplusplus
321 }
322 #endif
323 
324 #endif /* _RVI_H */
Definition: rvi.h:76
Definition: rvi.h:80
Definition: rvi.h:72
Definition: rvi.h:66
Definition: rvi.h:74
int rviCleanup(TRviHandle handle)
Tear down the API.
ERviStatus
Definition: rvi.h:64
Definition: rvi.h:82
Definition: rvi.h:78
int rviDisconnect(TRviHandle handle, int fd)
Disconnect from a remote node with a specified file descriptor.
int rviInvokeService(TRviHandle handle, const char *serviceName, const char *parameters)
Invoke a remote service.
int rviGetConnections(TRviHandle handle, int *conn, int *connSize)
Return all file descriptors in the RVI context.
Definition: rvi.h:86
int rviGetServices(TRviHandle handle, char **result, int *len)
Get list of services available.
Definition: rvi.h:88
TRviHandle rviInit(char *configFilename)
Initialize the RVI library. Call before using any other functions.
Definition: rvi.h:84
Definition: rvi.h:70
int rviProcessInput(TRviHandle handle, int *fdArr, int fdLen)
Handle input on remote connection(s).
int rviRegisterService(TRviHandle handle, const char *serviceName, TRviCallback callback, void *serviceData)
Register a service with a callback function.
void(* TRviCallback)(int fd, void *serviceData, const char *parameters)
Definition: rvi.h:58
int rviConnect(TRviHandle handle, const char *addr, const char *port)
Connect to a remote node at a specified address and port.
Definition: rvi.h:68
int rviUnregisterService(TRviHandle handle, const char *serviceName)
Unregister a previously registered service.
void * TRviHandle
Definition: rvi.h:55