]> pilppa.org Git - nws-w1.git/blob - src_client/NetworkServiceClient_W1.cc
fixed the latest data return for device list method
[nws-w1.git] / src_client / NetworkServiceClient_W1.cc
1 /*
2  * test_client.cc
3  *
4  *  Created on: Jun 9, 2010
5  *      Author: lamikr
6  */
7
8 #include <plp/log.h>
9 #include <plp/retval.h>
10 #include <plp/bus/BusServer.hh>
11 #include <plp/bus/BusClient.hh>
12 #include <plp/bus/BusMessage.hh>
13
14 #include <plp/devicebus/client/ClientListenerImpl.hh>
15 #include <plp/devicebus/client/DeviceManagerClient.hh>
16 #include <plp/devicebus/client/DeviceManagerController.hh>
17
18 using namespace std;
19 using namespace plpbus;
20 using namespace plp;
21 using namespace plpdevicebus;
22
23 int main(int argc, char** argv)
24 {
25         DeviceManagerController         *controller;
26         const list<Device *>            *dev_lst;
27         list<Device *>::iterator        dev_iter;
28         Device                          *device;
29         string                          id;
30         int                             err_flg;
31
32         controller      = new DeviceManagerController();
33         if (controller != NULL) {
34                 dev_lst = controller->get_device_list(&err_flg);
35                 if (err_flg == PLP_OK) {
36                         if (dev_lst != NULL) {
37                                 for (dev_iter = ((list<Device *> *)dev_lst)->begin(); dev_iter != ((list<Device *> *)dev_lst)->end(); dev_iter++) {
38                                         device  = (Device *)*dev_iter;
39                                         id      = device->get_id();
40                                         device->printout();
41                                 }
42                         }
43                         else {
44                                 log_error("Could not get device list, device list NULL");
45                         }
46                 }
47                 else {
48                         log_error("Could not get device list, error code: %d", err_flg);
49                 }
50                 delete(controller);
51                 sleep(3);
52         }
53         return 0;
54 }