File indexing completed on 2025-01-05 04:37:21
0001 /* 0002 SPDX-FileCopyrightText: 2009 Joris Guisson <joris.guisson@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #include "net/wakeuppipe.h" 0007 #include <util/functions.h> 0008 #include <util/log.h> 0009 0010 using namespace bt; 0011 0012 namespace net 0013 { 0014 WakeUpPipe::WakeUpPipe() 0015 : woken_up(false) 0016 { 0017 } 0018 0019 WakeUpPipe::~WakeUpPipe() 0020 { 0021 } 0022 0023 void WakeUpPipe::wakeUp() 0024 { 0025 QMutexLocker lock(&mutex); 0026 if (woken_up) 0027 return; 0028 0029 char data[] = "d"; 0030 if (bt::Pipe::write((const bt::Uint8 *)data, 1) != 1) 0031 Out(SYS_GEN | LOG_DEBUG) << "WakeUpPipe: wake up failed " << endl; 0032 else 0033 woken_up = true; 0034 } 0035 0036 void WakeUpPipe::handleData() 0037 { 0038 QMutexLocker lock(&mutex); 0039 bt::Uint8 buf[20]; 0040 int ret = bt::Pipe::read(buf, 20); 0041 if (ret < 0) 0042 Out(SYS_GEN | LOG_DEBUG) << "WakeUpPipe: read failed " << endl; 0043 0044 woken_up = false; 0045 } 0046 0047 void WakeUpPipe::reset() 0048 { 0049 // Do nothing 0050 } 0051 0052 }