-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocket.h
More file actions
102 lines (78 loc) · 2.19 KB
/
socket.h
File metadata and controls
102 lines (78 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef SOCKET_H_INCLUDED
#define SOCKET_H_INCLUDED
#include <stdint.h>
#define DEVICE_ID_INVALID 0
#define DEVICE_ID_SAIL 1
#define DEVICE_ID_HELM 2
#define DEVICE_ID_GPS 3
#define DEVICE_ID_ROLL 4
#define DEVICE_ID_WINDDIR 5
#define DEVICE_ID_COMPASS 6
#define DEVICE_ID_BATTERY 7
#define DEVICE_ID_TURNSPEED 8
struct __attribute__((packed)) Event{
uint8_t id;
uint64_t data[2];
};
/**
@brief Cette fonction est appelée quand un event est reçu
@warning DOIT être réécrite dans le .c
*/
void SocketOnEventReceived(struct Event ev);
/**
@brief Initialisation de la socket
@return 0 si tout c'est bien passé, code d'erreur négatif sinon
**/
int SocketInit(const char* server);
/**
@brief Ferme proprement la socket
*/
void SocketClose();
/**
@brief Demarre la gestion parallèle des données recues par le serveur
*/
void SocketStart();
/**
@brief Envoi un évènement à l'intelligence
*/
void SocketSendEvent(struct Event ev);
/**
@brief Envoi une commande de tension voile (de 0 à 255)
*/
void SocketSendSail(unsigned short value);
/**
@brief Envoi une commande d'orientation barre (de -45° à 45°)
*/
void SocketSendHelm(float value);
struct GpsCoord{
double lat;//Degres
double lon;//Degres
};
/**
@brief Convertit les données réseau en position GPS (2x IEEE-754 64 bit floating point)
*/
struct GpsCoord ConvertToGpsValue(uint64_t data[2]);
/**
@brief Convertit les données réseau en roulis (IEEE-754 64 bit floating point)
@return angle Entre -180° et 180°. 0=bateau droit. 180° étant un cas très fâcheux...
*/
double ConvertToRollValue(uint64_t data[2]);
/**
@brief Convertit les données réseau en direction du vent (IEEE-754 64 bit floating point)
@return angle Entre -180° et 180°. 0=vent de face
*/
double ConvertToWindDirValue(uint64_t data[2]);
/**
@brief Convertit les données réseau en direction du compas (IEEE-754 64 bit floating point)
@return angle Entre 0° et 360°. 0=Nord
*/
double ConvertToCompassValue(uint64_t data[2]);
/**
@return voltage Entre 0 et 18 volts
**/
float ConvertToBatteryValue(uint64_t data[2]);
/**
@return Vitesse de rotation entre -360 et 360 degrés
**/
float ConvertToTurnSpeedValue(uint64_t data[2]);
#endif // SOCKET_H_INCLUDED