/test/capture_test.c
C | 130 lines | 71 code | 21 blank | 38 comment | 6 complexity | 558cf7ae456f2d4b9967c59bb6292782 MD5 | raw file
1/* 2 * bdremoteng - helper daemon for Sony(R) BD Remote Control 3 * Based on bdremoted, written by Anton Starikov <antst@mail.ru>. 4 * 5 * Copyright (C) 2009 Michael Wojciechowski <wojci@wojci.dk> 6 * 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 * 22 */ 23 24/** \ingroup Test */ 25/*\@{*/ 26 27/*! \file capture_test.c 28 \brief Test bluetooth capture. 29 30 Test application which should print something when the remote 31 connects and sends data. 32 Notice the hardcoded destination address. 33*/ 34 35#include <globaldefs.h> 36#include <captureif.h> 37#include <stdio.h> 38#include <assert.h> 39#include <string.h> 40#include <l.h> 41 42unsigned int globalLogMask = 43 MODULEMASK_LIRC_THR | MODULEMASK_LIRC_SOCK | 44 MODULEMASK_LIRC_CB | MODULEMASK_BT_IF | MODULEMASK_BT_IMPL | 45 MODULEMASK_QUEUE | MODULEMASK_SPARE | MODULEMASK_MAIN; 46 47static const unsigned int moduleMask = MODULEMASK_MAIN; 48 49/** Capture interface implementation. */ 50void RemoteConnected(void* _p) 51{ 52 assert(_p); 53 printf("Remote connected.\n"); 54} 55 56/** Capture interface implementation. */ 57void DataInd(void* _p, const char* _data, const int _size) 58{ 59 assert(_p); 60 assert(_data); 61 printf("Remote data indication, %d bytes.\n", _size); 62} 63 64/** Capture interface implementation. */ 65void RemoteDisconnected(void* _p) 66{ 67 assert(_p); 68 printf("Remote disconnected.\n"); 69} 70 71void RemoteBatteryCharge(void* _p, int _val) 72{ 73 assert(_p); 74 printf("Battery charge %d %%.\n", _val); 75} 76 77/** Capture test. */ 78int main(int argc, char *argv[]) 79{ 80 /* Address of the remote. */ 81 const char* destinationAddress = "00:19:C1:58:C3:B7"; 82 configuration config; 83 captureData cd; 84 void* p = (void*)0x1; /* Unused here. */ 85 int res = BDREMOTE_FAIL; 86 int i = 0; 87 88 if (argc > 1) 89 { 90 printf("Arguments are not supported.\n"); 91 92 for (i = 1; i < argc; i++) 93 { 94 printf("Unhandled argument: %s.\n", argv[i]); 95 } 96 return -1; 97 } 98 99 setDefaultLog(); 100 memset(&config, 0, sizeof(config)); 101 memset(&cd, 0, sizeof(cd)); 102 103 setDefaults(&config); 104 setRemoteAddress(&config, destinationAddress); 105 106 InitCaptureData(&cd, 107 &config, 108 p); 109 110 res = InitcaptureLoop(&cd); 111 if (res == BDREMOTE_FAIL) 112 { 113 BDREMOTE_DBG(config.debug, "InitcaptureLoop failed."); 114 return BDREMOTE_FAIL; 115 } 116 117 /* Run capture loop. */ 118 res = captureLoop(&cd); 119 120 if (res == BDREMOTE_FAIL) 121 { 122 BDREMOTE_ERR("captureLoop failed."); 123 return BDREMOTE_FAIL; 124 } 125 126 return BDREMOTE_OK; 127} 128 129/*\@}*/ 130