2011-08-18 23:10:49 +02:00
|
|
|
|
/*
|
|
|
|
|
* 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:
|
2011-08-19 17:14:20 +02:00
|
|
|
|
* = 18 (MAC) + 2 (type) + 22 (timestamp) = 42 + ';' = 43
|
2011-08-18 23:10:49 +02:00
|
|
|
|
* Plus, for each algorithm, about 60 characters (say 100, as the length
|
2011-08-19 17:14:20 +02:00
|
|
|
|
* of the algorithm and area names can vary, 101 with the ';').
|
2011-08-18 23:10:49 +02:00
|
|
|
|
* Let's keep room for 10 algorithms :
|
2011-08-19 17:14:20 +02:00
|
|
|
|
* 10×101 + 43 = 1053 characters.
|
2011-08-18 23:10:49 +02:00
|
|
|
|
*/
|
2011-08-19 17:14:20 +02:00
|
|
|
|
#define OWL_CSV_RESULT_REQUEST_STRLEN 43
|
|
|
|
|
#define OWL_CSV_ALGORITHM_RESULT_STRLEN 101
|
|
|
|
|
#define OWL_CSV_RESULT_STRLEN 1053
|
2011-08-18 23:10:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 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 ;
|
|
|
|
|
|
|
|
|
|
|
2011-08-20 08:57:29 +02:00
|
|
|
|
owl_result* owl_receive_position(int sockfd) ;
|
|
|
|
|
owl_result* owl_fill_result(char *csv) ;
|
2011-08-18 23:10:49 +02:00
|
|
|
|
|
2011-08-19 17:22:43 +02:00
|
|
|
|
void owl_result_to_csv(char dst[OWL_CSV_RESULT_STRLEN],
|
|
|
|
|
const owl_result *const src) ;
|
|
|
|
|
void
|
|
|
|
|
owl_algorithm_result_to_csv(char dst[OWL_CSV_ALGORITHM_RESULT_STRLEN],
|
|
|
|
|
const owl_algorithm_result *const src) ;
|
|
|
|
|
|
2011-08-19 17:10:05 +02:00
|
|
|
|
void owl_fprint_result(FILE *stream, const owl_result *const src) ;
|
2011-08-18 23:10:49 +02:00
|
|
|
|
void owl_fprint_algorithm_result(FILE *stream,
|
2011-08-19 17:10:05 +02:00
|
|
|
|
const owl_algorithm_result *const src) ;
|
|
|
|
|
#define owl_print_result(SRC) \
|
|
|
|
|
(owl_fprint_result(stdout, (SRC)))
|
|
|
|
|
#define owl_print_algorithm_result(SRC) \
|
|
|
|
|
(owl_fprint_algorithm_result(stdout, (SRC)))
|
2011-08-18 23:10:49 +02:00
|
|
|
|
|
|
|
|
|
void owl_free_result(owl_result *result) ;
|
|
|
|
|
void owl_free_algorithm_result(owl_algorithm_result *algo) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _LIBOWLPS_RESULTREADER_CSV_
|