Example program for last update function
[bcusdk.git] / eibd / examples / groupcachelastupdates.c
blobe06fc827a5fa2a307f74955c3782630064f19eae
1 /*
2 EIB Demo program
3 Copyright (C) 2005-2010 Martin Koegler <mkoegler@auto.tuwien.ac.at>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "common.h"
21 int
22 main (int ac, char *ag[])
24 int len;
25 EIBConnection *con;
26 int i;
27 int start;
28 int timeout;
29 uint16_t end;
30 uchar buf[300];
32 if (ac != 4)
33 die ("usage: %s url start-position timeout", ag[0]);
34 con = EIBSocketURL (ag[1]);
35 if (!con)
36 die ("Open failed");
37 start = atoi (ag[2]);
38 timeout = atoi (ag[3]);
40 len = EIB_Cache_LastUpdates (con, start, timeout, sizeof (buf), buf, &end);
41 if (len == -1)
42 die ("Read failed");
44 printf ("new position: %d\n", end);
45 for (i = 0; i < len; i += 2)
47 eibaddr_t a = (buf[i] << 8) | buf[i + 1];
48 printGroup (a);
49 printf ("\n");
51 printf ("\n");
53 EIBClose (con);
54 return 0;