gusimplewhiteboard
wb_location.c File Reference
#include "wb_location.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
Include dependency graph for wb_location.c:

Go to the source code of this file.

Macros

#define htonll(x)   bswap_64(x)
 
#define ntohll(x)   bswap_64(x)
 
#define htonl(x)   bswap_32(x)
 
#define ntohl(x)   bswap_32(x)
 
#define htons(x)   bswap_16(x)
 
#define ntohs(x)   bswap_16(x)
 

Functions

const char * wb_location_description (const struct wb_location *self, char *descString, size_t bufferSize)
 Convert to a description string. More...
 
const char * wb_location_to_string (const struct wb_location *self, char *toString, size_t bufferSize)
 Convert to a string. More...
 
struct wb_locationwb_location_from_string (struct wb_location *self, const char *str)
 Convert from a string. More...
 
size_t wb_location_to_network_serialised (const struct wb_location *self, char *dst)
 Convert to a compressed, serialised, network byte order byte stream. More...
 
size_t wb_location_from_network_serialised (const char *src, struct wb_location *dst)
 Convert from a compressed, serialised, network byte order byte stream. More...
 
struct wb_location rr_coord_to_wb_location (const gu_relative_coordinate coord, const uint8_t confidence, const uint32_t distanceVariance, const uint32_t directionVariance)
 WHITEBOARD_POSTER_STRING_CONVERSION. More...
 
struct gu_relative_coordinate wb_location_to_rr_coord (const struct wb_location location)
 Converts a wb_location to a gu_relative_coordinate. More...
 
struct gu_optional_relative_coordinate wb_location_to_opt_rr_coord (const struct wb_location location, const uint8_t confidence)
 Converts a wb_location to a gu_optional_relative_coordinate. More...
 

Macro Definition Documentation

◆ htonl

#define htonl (   x)    bswap_32(x)

Definition at line 97 of file wb_location.c.

◆ htonll

#define htonll (   x)    bswap_64(x)

Definition at line 93 of file wb_location.c.

◆ htons

#define htons (   x)    bswap_16(x)

Definition at line 101 of file wb_location.c.

◆ ntohl

#define ntohl (   x)    bswap_32(x)

Definition at line 98 of file wb_location.c.

◆ ntohll

#define ntohll (   x)    bswap_64(x)

Definition at line 94 of file wb_location.c.

◆ ntohs

#define ntohs (   x)    bswap_16(x)

Definition at line 102 of file wb_location.c.

Function Documentation

◆ rr_coord_to_wb_location()

struct wb_location rr_coord_to_wb_location ( const gu_relative_coordinate  coord,
const uint8_t  confidence,
const uint32_t  distanceVariance,
const uint32_t  directionVariance 
)

WHITEBOARD_POSTER_STRING_CONVERSION.

Converts a gu_relative_coordinate to a wb_location.

Parameters
[in]coordThe gu_relative_coordinate which is being converted.
[in]confidenceThe confidence value for the new location.
[in]distanceVarianceThe distanceVariance value for the new location.
[in]directionVarianceThe directionVariance value for the new location.
Returns
A wb_location containing the values of coord having performed the necessary conversions.

Definition at line 511 of file wb_location.c.

References wb_location::confidence, wb_location::directionVariance, and wb_location::distanceVariance.

◆ wb_location_description()

const char * wb_location_description ( const struct wb_location self,
char *  descString,
size_t  bufferSize 
)

Convert to a description string.

Definition at line 125 of file wb_location.c.

Referenced by guWhiteboard::Location::description().

◆ wb_location_from_network_serialised()

size_t wb_location_from_network_serialised ( const char *  src,
struct wb_location dst 
)

Convert from a compressed, serialised, network byte order byte stream.

Network stream deserialisation.

Definition at line 426 of file wb_location.c.

References wb_location::confidence, wb_location::direction, wb_location::directionVariance, wb_location::distance, wb_location::distanceVariance, ntohl, and ntohs.

◆ wb_location_from_string()

struct wb_location * wb_location_from_string ( struct wb_location self,
const char *  str 
)

Convert from a string.

Definition at line 221 of file wb_location.c.

References LOCATION_DESC_BUFFER_SIZE.

◆ wb_location_to_network_serialised()

size_t wb_location_to_network_serialised ( const struct wb_location self,
char *  dst 
)

Convert to a compressed, serialised, network byte order byte stream.

Network stream serialisation.

Definition at line 345 of file wb_location.c.

References htonl, and htons.

◆ wb_location_to_opt_rr_coord()

struct gu_optional_relative_coordinate wb_location_to_opt_rr_coord ( const struct wb_location  location,
const uint8_t  confidence 
)

Converts a wb_location to a gu_optional_relative_coordinate.

Parameters
[in]locationThe wb_location which is being converted.
[in]confidenceThe minimum confidence value that location needs to be in order for the returning gu_optional_relative_coordinate to contain a value. If the locations confidence is less than this value then this function returns a gu_optional_realtive_coordinate where gu_optional_relative_coordinate::has_value is false.
Returns
A gu_optional_relative_coordinate containing the values of coord having performed the necessary conversions. If locations confidence value is less than confidence then the gu_optional_realtive_coordinate::has_value is false;

Definition at line 532 of file wb_location.c.

References wb_location_to_rr_coord().

Referenced by guWhiteboard::Location::optionalRelativeCoordinate().

◆ wb_location_to_rr_coord()

struct gu_relative_coordinate wb_location_to_rr_coord ( const struct wb_location  location)

Converts a wb_location to a gu_relative_coordinate.

Parameters
[in]locationThe wb_location which is being converted.
Returns
A gu_relative_coordinate containing the values of coord having performed the necessary conversions.
Attention
The confidence of the location is discarded since gu_relative_coordinate has no notion of a confidence.

Definition at line 523 of file wb_location.c.

Referenced by guWhiteboard::Location::relativeCoordinate(), and wb_location_to_opt_rr_coord().

◆ wb_location_to_string()

const char * wb_location_to_string ( const struct wb_location self,
char *  toString,
size_t  bufferSize 
)

Convert to a string.

Definition at line 173 of file wb_location.c.

Referenced by guWhiteboard::Location::to_string().