playersd.h

00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2007
00004  *     Brian Gerkey
00005  *                      
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 /*
00023  *  Player - One Hell of a Robot Server
00024  *  Copyright (C) 2007
00025  *     Brian Gerkey
00026  *                      
00027  *
00028  *  This library is free software; you can redistribute it and/or
00029  *  modify it under the terms of the GNU Lesser General Public
00030  *  License as published by the Free Software Foundation; either
00031  *  version 2.1 of the License, or (at your option) any later version.
00032  *
00033  *  This library is distributed in the hope that it will be useful,
00034  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00035  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00036  *  Lesser General Public License for more details.
00037  *
00038  *  You should have received a copy of the GNU Lesser General Public
00039  *  License along with this library; if not, write to the Free Software
00040  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00041  */
00042 
00043 /*
00044  * Interface to libplayersd
00045  *
00046  * $Id: playersd.h 4308 2007-12-13 20:23:08Z gerkey $
00047  */
00048 
00058 #ifndef _PLAYER_SD_H
00059 #define _PLAYER_SD_H
00060 
00061 #ifdef __cplusplus
00062 extern "C" {
00063 #endif
00064 
00065 #include <libplayercore/player.h>
00066 
00067 #define PLAYER_SD_SERVICENAME "_player21._tcp"
00068 #define PLAYER_SD_DEVICE_TXTNAME "device"
00069 #define PLAYER_SD_NAME_MAXLEN 256
00070 #define PLAYER_SD_TXT_MAXLEN 256
00071 
00073 typedef struct player_sd_dev
00074 {
00075   // Is this entry valid?
00076   uint8_t valid;
00077   // Name of the device
00078   char name[PLAYER_SD_NAME_MAXLEN];
00079   // Is the address valid?
00080   uint8_t addr_valid;
00081   // Did address resolution fail?
00082   uint8_t addr_fail;
00083   // Player address components
00084   char hostname[PLAYER_SD_NAME_MAXLEN];
00085   uint32_t robot;
00086   uint16_t interf;
00087   uint16_t index;
00088 } player_sd_dev_t;
00089 
00091 typedef struct player_sd
00092 {
00095   void* sdRef;
00097   player_sd_dev_t* devs;
00099   size_t devs_len;
00100 } player_sd_t;
00101 
00104 player_sd_t* player_sd_init(void);
00105 
00107 void player_sd_fini(player_sd_t* sd);
00108 
00110 void player_sd_lock(player_sd_t* sd);
00111 
00113 void player_sd_unlock(player_sd_t* sd);
00114 
00117 int player_sd_register(player_sd_t* sd, 
00118                        const char* name, 
00119                        player_devaddr_t addr);
00120 
00123 int player_sd_unregister(player_sd_t* sd, 
00124                          const char* name);
00125 
00128 typedef void (*player_sd_browse_callback_fn_t)(player_sd_t* sd,
00129                                                player_sd_dev_t* dev);
00130 
00143 int player_sd_browse(player_sd_t* sd,
00144                      double timeout, 
00145                      int keepalive,
00146                      player_sd_browse_callback_fn_t cb);
00147 
00157 int player_sd_update(player_sd_t* sd, double timeout);
00158 
00160 int player_sd_browse_stop(player_sd_t* sd);
00161 
00163 // Common functions, implemented in playersd.c
00164 
00167 player_sd_dev_t* player_sd_get_device(player_sd_t* sd, const char* name);
00168 
00184 int player_sd_find_devices(player_sd_t* sd, 
00185                            player_sd_dev_t* result,
00186                            size_t result_len,
00187                            const char* name,
00188                            const char* hostname,
00189                            int robot,
00190                            int interf,
00191                            int index);
00192 
00195 player_sd_dev_t* _player_sd_add_device(player_sd_t* sd, const char* name);
00196 
00198 void player_sd_printcache(player_sd_t* sd);
00199 
00200 #ifdef __cplusplus
00201 }
00202 #endif
00203 
00206 #endif

Last updated 12 September 2005 21:38:45