owlps/libowlps-resultreader-udp/owlps-resultreader-udp.h

71 lines
1.8 KiB
C
Raw Normal View History

/*
* This library provides functions to read results sent on UDP by OwlPS
* Positioning.
* See the example program owlps-resultreader-udp.c.
*/
#ifndef _LIBOWLPS_RESULTREADER_CSV_
#define _LIBOWLPS_RESULTREADER_CSV_
#include <owlps.h>
#include <stdio.h>
#include <inttypes.h>
/* Maximum size of a result CSV string sent by OwlPS Positioning.
* Request's information:
* = 18 (MAC) + 2 (type) + 22 (timestamp) = 42
* Plus, for each algorithm, about 60 characters (say 100, as the length
* of the algorithm and area names can vary).
* Let's keep room for 10 algorithms :
* 10×100 + 42 = 1042 characters + '\0' = 1043.
*/
#define OWL_CSV_RESULT_STRLEN 1043
/* Linked list of algorithms' results.
* Each structure is the result of a single algorithm.
*/
typedef struct _owl_algorithm_result
{
char *algorithm ;
float x ;
float y ;
float z ;
float error ;
char *area ;
struct _owl_algorithm_result *next ;
} owl_algorithm_result ;
/* Results for a request. Includes the request's data, and the
* list of algorithms' results.
*/
typedef struct _owl_result
{
char *mobile_mac_addr ;
uint8_t request_type ;
owl_timestamp mobile_timestamp ;
owl_algorithm_result *results ;
} owl_result ;
void owl_receive_position(int sockfd, owl_result **result) ;
void owl_fill_result(owl_result **result, char *csv) ;
void owl_fprint_result(FILE *stream, owl_result *result) ;
void owl_fprint_algorithm_result(FILE *stream,
owl_algorithm_result *algo) ;
#define owl_print_result(RESULT) \
(owl_fprint_result(stdout, (RESULT)))
#define owl_print_algorithm_result(ALGO) \
(owl_fprint_algorithm_result(stdout, (ALGO)))
void owl_free_result(owl_result *result) ;
void owl_free_algorithm_result(owl_algorithm_result *algo) ;
#endif // _LIBOWLPS_RESULTREADER_CSV_