diff -r 000000000000 -r 29b1cd4cb562 bluetoothcommsprofiles/btpan/refBnepPacketNotifier/src/refBnepPacketNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothcommsprofiles/btpan/refBnepPacketNotifier/src/refBnepPacketNotifier.cpp Fri Jan 15 08:13:17 2010 +0200 @@ -0,0 +1,117 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include "refBnepPacketNotifier.h" + +EXPORT_C MBnepPacketNotifierBase* CRefBnepPacketNotifier::NewL() + { + MBnepPacketNotifierBase* self = new(ELeave) CRefBnepPacketNotifier; + return self; + } + + + +CRefBnepPacketNotifier::CRefBnepPacketNotifier():iCounter(8) // 8 is the current maximum number of PAN connections, so is a good number to set the granularity to. + { + } + +CRefBnepPacketNotifier::~CRefBnepPacketNotifier() + { + iCounter.Close(); + } + +void CRefBnepPacketNotifier::MbpnSetLinkControl(MPanLinkControlBase& aPanLinkControl) + { + iPanLinkControl=(MPanLinkControl*) aPanLinkControl.MplcbGetInterface(KUidPanLinkControlV1); + } + +void CRefBnepPacketNotifier::MbpnBnepDataTransferred(const TArray & aBnepBytesTransferred) + { + for (TInt dev=0;devMplcRequestSniff(curAddr); // Sniff if under KMaxBytesToSniff + + } + else + { + iPanLinkControl->MplcRequestActive(curAddr); // Otherwise active + } + iCounter[index].iByteCount=0; // Reset byte count + } + } + if (aBnepBytesTransferred[dev].iBytesSent + aBnepBytesTransferred[dev].iBytesReceived > KMinBytesToUnSniff && iPanLinkControl) + { + iPanLinkControl->MplcRequestActive(curAddr); // If data in one tick is enough, bring out of sniff + } + } + } + } + } + +void CRefBnepPacketNotifier::MbpnDeviceAdded(const TBTDevAddr& aAddr) + { + TByteCount devByteCount; + devByteCount.iByteCount=0; + devByteCount.iTickCount=0; + devByteCount.iAddr=aAddr; + iCounter.Append(devByteCount); + } + +void CRefBnepPacketNotifier::MbpnDeviceRemoved(const TBTDevAddr& aAddr) + { + for (TUint dataIndex=0; dataIndex < iCounter.Count(); ++dataIndex) + { + if (iCounter[dataIndex].iAddr==aAddr) + { + iCounter.Remove(dataIndex); + } + } + + } + +MBnepPacketNotifier* CRefBnepPacketNotifier::Interface() + { + return this; + } + +TAny* CRefBnepPacketNotifier::MbpnbGetInterface(const TUid & aInterface) + { + if (aInterface==KUidBnepPacketNotifierV1) + { + return Interface(); + } + return NULL; + } + +void CRefBnepPacketNotifier::MbpnbRelease() + { + delete this; + }