playersd.h
/*
* Player - One Hell of a Robot Server
* Copyright (C) 2007
* Brian Gerkey
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
* Player - One Hell of a Robot Server
* Copyright (C) 2007
* Brian Gerkey
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Interface to libplayersd
*
* $Id: playersd.h 8004 2009-07-13 14:03:44Z thjc $
*/
#ifndef _PLAYER_SD_H
#define _PLAYER_SD_H
#ifdef __cplusplus
extern "C" {
#endif
#include <libplayerinterface/player.h>
#define PLAYER_SD_SERVICENAME "_player21._tcp"
#define PLAYER_SD_DEVICE_TXTNAME "device"
#define PLAYER_SD_NAME_MAXLEN 256
#define PLAYER_SD_TXT_MAXLEN 256
typedef struct player_sd_dev
{
// Is this entry valid?
uint8_t valid;
// Name of the device
char name[PLAYER_SD_NAME_MAXLEN];
// Is the address valid?
uint8_t addr_valid;
// Did address resolution fail?
uint8_t addr_fail;
// Player address components
char hostname[PLAYER_SD_NAME_MAXLEN];
uint32_t robot;
uint16_t interf;
uint16_t index;
} player_sd_dev_t;
typedef struct player_sd
{
void* sdRef;
player_sd_dev_t* devs;
size_t devs_len;
} player_sd_t;
player_sd_t* player_sd_init(void);
void player_sd_fini(player_sd_t* sd);
void player_sd_lock(player_sd_t* sd);
void player_sd_unlock(player_sd_t* sd);
int player_sd_register(player_sd_t* sd,
const char* name,
player_devaddr_t addr);
int player_sd_unregister(player_sd_t* sd,
const char* name);
typedef void (*player_sd_browse_callback_fn_t)(player_sd_t* sd,
player_sd_dev_t* dev);
int player_sd_browse(player_sd_t* sd,
double timeout,
int keepalive,
player_sd_browse_callback_fn_t cb);
int player_sd_update(player_sd_t* sd, double timeout);
int player_sd_browse_stop(player_sd_t* sd);
// Common functions, implemented in playersd.c
player_sd_dev_t* player_sd_get_device(player_sd_t* sd, const char* name);
int player_sd_find_devices(player_sd_t* sd,
player_sd_dev_t* result,
size_t result_len,
const char* name,
const char* hostname,
int robot,
int interf,
int index);
player_sd_dev_t* _player_sd_add_device(player_sd_t* sd, const char* name);
void player_sd_printcache(player_sd_t* sd);
#ifdef __cplusplus
}
#endif
#endif
player_sd_lock
void player_sd_lock(player_sd_t *sd)
Lock access to playersd structures, such as the local device cache.
player_sd_browse_callback_fn_t
void(* player_sd_browse_callback_fn_t)(player_sd_t *sd, player_sd_dev_t *dev)
Prototype for a callback function that can be invoked when devices are added or removed.
Definition: playersd.h:128
player_sd::devs
player_sd_dev_t * devs
List of devices discovered by browsing.
Definition: playersd.h:97
player_sd_find_devices
int player_sd_find_devices(player_sd_t *sd, player_sd_dev_t *result, size_t result_len, const char *name, const char *hostname, int robot, int interf, int index)
Find a device in the local cache that matches the given criteria.
player_devaddr
A device address.
Definition: player.h:141
player_sd
Service discovery object.
Definition: playersd.h:91
player_sd_register
int player_sd_register(player_sd_t *sd, const char *name, player_devaddr_t addr)
Register the named device.
player_sd_browse_stop
int player_sd_browse_stop(player_sd_t *sd)
Stop browsing. Returns 0 on success, non-zero on error.
player_sd_get_device
player_sd_dev_t * player_sd_get_device(player_sd_t *sd, const char *name)
Look up a device by name.
player_sd_dev_t
struct player_sd_dev player_sd_dev_t
A device, represented by its name and address.
player_sd_update
int player_sd_update(player_sd_t *sd, double timeout)
Check for new device updates, waiting for timeout s.
player_sd_browse
int player_sd_browse(player_sd_t *sd, double timeout, int keepalive, player_sd_browse_callback_fn_t cb)
Browse for player devices.
player_sd_t
struct player_sd player_sd_t
Service discovery object.
player_sd::devs_len
size_t devs_len
Number of devices discovered.
Definition: playersd.h:99
player_sd::sdRef
void * sdRef
Opaque pointer to underlying zeroconf client object.
Definition: playersd.h:95
_player_sd_add_device
player_sd_dev_t * _player_sd_add_device(player_sd_t *sd, const char *name)
Add a device to the local cache.
player_sd_unlock
void player_sd_unlock(player_sd_t *sd)
Unlock access to playersd structures, such as the local device cache.
player_sd_dev
A device, represented by its name and address.
Definition: playersd.h:73
player_sd_printcache
void player_sd_printcache(player_sd_t *sd)
Print the contents of the local device cache to the console.
player_sd_init
player_sd_t * player_sd_init(void)
Initialize service discovery, passing back a pointer that will be passed into all future calls...
PLAYER_SD_NAME_MAXLEN
#define PLAYER_SD_NAME_MAXLEN
A device, represented by its name and address.
Definition: playersd.h:69
player_sd_fini
void player_sd_fini(player_sd_t *sd)
Finalize service discovery, freeing associated resources.
player_sd_unregister
int player_sd_unregister(player_sd_t *sd, const char *name)
Unregister (terminate) the named device.

Last updated 12 September 2005 21:38:45