12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124 |
-
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Runtime.InteropServices;
- namespace ANT_Managed_Library
- {
-
-
-
- public class ANT_Channel : IANT_Channel
- {
- #region variables
- readonly ANT_Device creatingDevice = null;
- IntPtr unmanagedANTFramerPointer = IntPtr.Zero;
- private byte channelNumber;
- private bool disposed = false;
- private object deviceNotificationLock = new object();
- private object channelResponseLock = new object();
- #endregion
- #region ChannelEventCallback Variables
- private event dRawChannelResponseHandler rawChannelResponse_internal;
-
-
-
-
- public event dRawChannelResponseHandler rawChannelResponse
- {
- add
- {
- lock (channelResponseLock)
- {
- rawChannelResponse_internal += value;
- }
- }
- remove
- {
- lock (channelResponseLock)
- {
- rawChannelResponse_internal -= value;
- }
- }
- }
- public event dDeviceNotificationHandler DeviceNotification_internal;
-
-
-
-
-
-
- public event dDeviceNotificationHandler DeviceNotification
- {
- add
- {
- lock (deviceNotificationLock)
- {
- DeviceNotification_internal += value;
- }
- }
- remove
- {
- lock (deviceNotificationLock)
- {
- DeviceNotification_internal -= value;
- }
- }
- }
- public event dChannelResponseHandler channelResponse_internal;
-
-
-
-
- public event dChannelResponseHandler channelResponse
- {
- add
- {
- lock (channelResponseLock)
- {
- channelResponse_internal += value;
- }
- }
- remove
- {
- lock (channelResponseLock)
- {
- channelResponse_internal -= value;
- }
- }
- }
- #endregion
- #region ANT_DLL Imports
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_GetChannelID(IntPtr FramerPtr, byte ucANTChannel_, ref UInt16 pusDeviceNumber_, ref byte pucDeviceType_, ref byte pucTransmitType_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, CallingConvention = CallingConvention.Cdecl)]
- private static extern int ANT_GetChannelStatus(IntPtr FramerPtr, byte ucANTChannel_, ref byte pucStatus_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_AssignChannel_RTO", CallingConvention = CallingConvention.Cdecl)]
- private static extern int ANT_AssignChannel(IntPtr FramerPtr, byte ucANTChannel, byte ucChanType, byte ucNetNumber, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_AssignChannelExt_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_AssignChannelExt(IntPtr FramerPtr, byte ucANTChannel, byte ucChanType, byte ucNetNumber, byte ucExtFlags, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_UnAssignChannel_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_UnAssignChannel(IntPtr FramerPtr, byte ucANTChannel, UInt32 ulResponseTime);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SetChannelId_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_SetChannelId(IntPtr FramerPtr, byte ucANTChannel, UInt16 usDeviceNumber, byte ucDeviceType, byte ucTransmissionType_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SetSerialNumChannelId_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_SetSerialNumChannelId_RTO(IntPtr FramerPtr, byte ucANTChannel_, byte ucDeviceType_, byte ucTransmissionType_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SetChannelPeriod_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_SetChannelPeriod(IntPtr FramerPtr, byte ucANTChannel_, UInt16 usMesgPeriod_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_RSSI_SetSearchThreshold_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_RSSI_SetSearchThreshold(IntPtr FramerPtr, byte ucANTChannel_, byte ucThreshold_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SetChannelRFFreq_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_SetChannelRFFreq(IntPtr FramerPtr, byte ucANTChannel_, byte ucRFFreq_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SetChannelTxPower_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_SetChannelTxPower(IntPtr FramerPtr, byte ucANTChannel_, byte ucTransmitPower_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SetChannelSearchTimeout_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_SetChannelSearchTimeout(IntPtr FramerPtr, byte ucANTChannel_, byte ucSearchTimeout_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_OpenChannel_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_OpenChannel(IntPtr FramerPtr, byte ucANTChannel, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_CloseChannel_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_CloseChannel(IntPtr FramerPtr, byte ucANTChannel, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_SendBroadcastData(IntPtr FramerPtr, byte ucANTChannel, byte[] pucData);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SendAcknowledgedData_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern byte ANT_SendAcknowledgedData(IntPtr FramerPtr, byte ucANTChannel, byte[] pucData, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SendBurstTransfer_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern byte ANT_SendBurstTransfer(IntPtr FramerPtr, byte ucANTChannel_, byte[] pucData_, UInt32 usNumBytes, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SendAdvancedBurstTransfer_RTO", CallingConvention = CallingConvention.Cdecl)]
- private static extern byte ANT_SendAdvancedBurstTransfer(IntPtr FramerPtr, byte ucANTChannel_, byte[] pucData_, UInt32 usNumBytes, byte numStdPcktsPerSerialMsg_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_SendExtBroadcastData(IntPtr FramerPtr, byte ucANTChannel, UInt16 usDeviceNumber, byte ucDeviceType, byte ucTransmissionType_, byte[] pucData);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SendExtAcknowledgedData_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern byte ANT_SendExtAcknowledgedData(IntPtr FramerPtr, byte ucANTChannel, UInt16 usDeviceNumber, byte ucDeviceType, byte ucTransmissionType_, byte[] pucData, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SendExtBurstTransfer_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern byte ANT_SendExtBurstTransfer(IntPtr FramerPtr, byte ucANTChannel_, UInt16 usDeviceNumber, byte ucDeviceType, byte ucTransmissionType_, byte[] pucData_, UInt32 usNumBytes, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_SetLowPriorityChannelSearchTimeout_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_SetLowPriorityChannelSearchTimeout(IntPtr FramerPtr, byte ucANTChannel_, byte ucSearchTimeout_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_AddChannelID_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_AddChannelID(IntPtr FramerPtr, byte ucANTChannel_, UInt16 usDeviceNumber_, byte ucDeviceType_, byte ucTransmissionType_, byte ucListIndex_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_ConfigList_RTO", CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_ConfigList(IntPtr FramerPtr, byte ucANTChannel_, byte ucListSize_, byte ucExclude_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_EncryptedChannelEnable_RTO", CallingConvention = CallingConvention.Cdecl)]
- private static extern int ANT_EncryptedChannelEnable(IntPtr FramerPtr, byte ucANTChannel, byte ucMode, byte ucVolatileKeyIndex, byte ucDecimationRate, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_AddCryptoID_RTO", CallingConvention = CallingConvention.Cdecl)]
- private static extern int ANT_AddCryptoID(IntPtr FramerPtr, byte ucANTChannel, byte[] pucData, byte ucListIndex, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, EntryPoint = "ANT_ConfigCryptoList_RTO", CallingConvention = CallingConvention.Cdecl)]
- private static extern int ANT_ConfigCryptoList(IntPtr FramerPtr, byte ucANTChannel, byte ucListSize, byte ucBlacklist, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_SetProximitySearch(IntPtr FramerPtr, byte ucANTChannel_, byte ucSearchThreshold_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, CallingConvention=CallingConvention.Cdecl)]
- private static extern int ANT_ConfigFrequencyAgility(IntPtr FramerPtr, byte ucANTChannel_, byte ucFreq1_, byte ucFreq2_, byte ucFreq3_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, CallingConvention = CallingConvention.Cdecl)]
- private static extern int ANT_ConfigSelectiveDataUpdate(IntPtr FramerPtr, byte ucANTChannel_, byte ucSduConfig_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, CallingConvention = CallingConvention.Cdecl)]
- private static extern int ANT_SetSearchSharingCycles(IntPtr FramerPtr, byte ucANTChannel_, byte ucSearchSharingCycles_, UInt32 ulResponseTime_);
- [DllImport(ANT_Common.ANT_UNMANAGED_WRAPPER, CallingConvention = CallingConvention.Cdecl)]
- private static extern int ANT_SetChannelSearchPriority(IntPtr FramerPty, byte ucANTChannel_, byte ucPriorityLevel_, UInt32 ulResponseTime_);
- #endregion
- #region Constructor
-
- internal ANT_Channel(ANT_Device creatingDevice, byte ucChannelNumber)
- {
- this.creatingDevice = creatingDevice;
- this.unmanagedANTFramerPointer = creatingDevice.getFramerPtr();
- channelNumber = ucChannelNumber;
- }
- #endregion
- #region non-ANTdll Functions
-
-
-
- public ANT_Device getParentDevice()
- {
- return creatingDevice;
- }
-
-
-
-
- public IntPtr getUnmgdFramer()
- {
- return creatingDevice.getFramerPtr();
- }
-
-
-
- public byte getChannelNum()
- {
- return channelNumber;
- }
- internal void NotifyDeviceEvent(ANT_Device.DeviceNotificationCode notification, object notificationInfo)
- {
- lock (deviceNotificationLock)
- {
- if (DeviceNotification_internal != null)
- {
- DeviceNotification_internal(notification, notificationInfo);
- }
- }
- }
- internal void MessageReceived(ANT_Device.ANTMessage newMessage, ushort messageSize)
- {
- lock (channelResponseLock)
- {
- if (channelResponse_internal != null)
- {
- channelResponse_internal(new ANT_Response(this, channelNumber, DateTime.Now, newMessage.msgID, newMessage.ucharBuf.Take(messageSize).ToArray()));
- }
- if (rawChannelResponse_internal != null)
- {
- rawChannelResponse_internal(newMessage, messageSize);
- }
- }
- }
-
-
-
- public void Dispose()
- {
-
-
-
-
- creatingDevice.channelDisposed(channelNumber);
- disposed = true;
- GC.SuppressFinalize(this);
- }
-
-
-
-
-
- public ANT_ChannelStatus requestStatus(UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- byte statusByte = 0;
- if (ANT_GetChannelStatus(unmanagedANTFramerPointer, channelNumber, ref statusByte, responseWaitTime) == 1)
- {
- return new ANT_ChannelStatus((ANT_ReferenceLibrary.BasicChannelStatusCode)(statusByte & 0x03), (byte)((statusByte & 0x0C) >> 2), (ANT_ReferenceLibrary.ChannelType)(statusByte & 0xF0));
- }
- else
- {
- throw new ANT_Exception("Timed out waiting for requested message");
- }
- }
-
-
-
-
-
-
- public ANT_ChannelID requestID(UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- ushort deviceNumber = 0;
- byte deviceType = 0;
- byte transmitType = 0;
- if (ANT_GetChannelID(unmanagedANTFramerPointer, channelNumber, ref deviceNumber, ref deviceType, ref transmitType, responseWaitTime) == 1)
- {
- return new ANT_ChannelID(deviceNumber, deviceType, transmitType);
- }
- else
- {
- throw new ANT_Exception("Timed out waiting for requested message");
- }
- }
- #endregion
- #region ANT Channel Functions
-
-
-
-
-
-
-
-
-
- public bool assignChannel(ANT_ReferenceLibrary.ChannelType channelTypeByte, byte networkNumber, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- if (networkNumber > creatingDevice.getDeviceCapabilities().maxNetworks - 1)
- throw new ANT_Exception("Network number must be less than device's max networks - 1");
- return (ANT_AssignChannel(unmanagedANTFramerPointer, channelNumber, (byte)channelTypeByte, networkNumber, responseWaitTime) == 1);
- }
-
-
-
-
-
- public void assignChannel(ANT_ReferenceLibrary.ChannelType channelTypeByte, byte networkNumber) { assignChannel(channelTypeByte, networkNumber, 0); }
-
-
-
-
-
-
-
-
-
-
- public bool assignChannelExt(ANT_ReferenceLibrary.ChannelType channelTypeByte, byte networkNumber, ANT_ReferenceLibrary.ChannelTypeExtended extAssignByte, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- if (networkNumber > creatingDevice.getDeviceCapabilities().maxNetworks - 1)
- throw new ANT_Exception("Network number must be less than device's max networks - 1");
- return (ANT_AssignChannelExt(unmanagedANTFramerPointer, channelNumber, (byte)channelTypeByte, networkNumber, (byte)extAssignByte, responseWaitTime) == 1);
- }
-
-
-
-
-
-
-
- public void assignChannelExt(ANT_ReferenceLibrary.ChannelType channelTypeByte, byte networkNumber, ANT_ReferenceLibrary.ChannelTypeExtended extAssignByte) { assignChannelExt(channelTypeByte, networkNumber, extAssignByte, 0); }
-
-
-
-
-
-
- public bool unassignChannel(UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return (ANT_UnAssignChannel(unmanagedANTFramerPointer, channelNumber, responseWaitTime) == 1);
- }
-
-
-
- public void unassignChannel() { unassignChannel(0); }
-
-
-
-
-
-
-
-
-
-
-
- public bool setChannelID(UInt16 deviceNumber, bool pairingEnabled, byte deviceTypeID, byte transmissionTypeID, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- if (deviceTypeID > 127)
- throw new ANT_Exception("Device Type ID is larger than 127");
- if (pairingEnabled)
- deviceTypeID |= 0x80;
- return (ANT_SetChannelId(unmanagedANTFramerPointer, channelNumber, deviceNumber, deviceTypeID, transmissionTypeID, responseWaitTime) == 1);
- }
-
-
-
-
-
-
-
-
- public void setChannelID(UInt16 deviceNumber, bool pairingEnabled, byte deviceTypeID, byte transmissionTypeID) { setChannelID(deviceNumber, pairingEnabled, deviceTypeID, transmissionTypeID, 0); }
-
-
-
-
-
-
-
- public bool setChannelID_UsingSerial(bool pairingEnabled, byte deviceTypeID, byte transmissionTypeID, UInt32 waitResponseTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- if (deviceTypeID > 127)
- throw new ANT_Exception("Device Type ID is larger than 127");
- if (pairingEnabled)
- deviceTypeID |= 0x80;
- return (ANT_SetSerialNumChannelId_RTO(unmanagedANTFramerPointer, channelNumber, deviceTypeID, transmissionTypeID, waitResponseTime) == 1);
- }
-
-
-
- public void setChannelID_UsingSerial(bool pairingEnabled, byte deviceTypeID, byte transmissionTypeID) { setChannelID_UsingSerial(pairingEnabled, deviceTypeID, transmissionTypeID, 0); }
-
-
-
-
-
-
-
- public bool setChannelPeriod(UInt16 messagePeriod_32768unitspersecond, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return (ANT_SetChannelPeriod(unmanagedANTFramerPointer, channelNumber, messagePeriod_32768unitspersecond, responseWaitTime) == 1);
- }
-
-
-
-
- public void setChannelPeriod(UInt16 messagePeriod_32768unitspersecond) { setChannelPeriod(messagePeriod_32768unitspersecond, 0); }
-
-
-
-
-
-
-
- public bool setSearchThresholdRSSI(byte thresholdRSSI, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return (ANT_RSSI_SetSearchThreshold(unmanagedANTFramerPointer, channelNumber, thresholdRSSI, responseWaitTime) == 1);
- }
-
-
-
-
- public void setSearchThresholdRSSI(byte thresholdRSSI) { setSearchThresholdRSSI(thresholdRSSI, 0); }
-
-
-
-
-
-
-
-
- public bool setChannelFreq(byte RFFreqOffset, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return (ANT_SetChannelRFFreq(unmanagedANTFramerPointer, channelNumber, RFFreqOffset, responseWaitTime) == 1);
- }
-
-
-
-
-
- public void setChannelFreq(byte RFFreqOffset) { setChannelFreq(RFFreqOffset, 0); }
-
-
-
-
-
-
-
-
- public bool setChannelTransmitPower(ANT_ReferenceLibrary.TransmitPower transmitPower, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- if (!creatingDevice.getDeviceCapabilities().perChannelTransmitPower)
- throw new ANT_Exception("Device not capable of per-channel transmit power");
- return (ANT_SetChannelTxPower(unmanagedANTFramerPointer, channelNumber, (byte)transmitPower, responseWaitTime) == 1);
- }
-
-
-
-
- public void setChannelTransmitPower(ANT_ReferenceLibrary.TransmitPower transmitPower) { setChannelTransmitPower(transmitPower, 0); }
-
-
-
-
-
-
-
- public bool setChannelSearchTimeout(byte searchTimeout, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return (ANT_SetChannelSearchTimeout(unmanagedANTFramerPointer, channelNumber, searchTimeout, responseWaitTime) == 1);
- }
-
-
-
-
- public void setChannelSearchTimeout(byte searchTimeout) { setChannelSearchTimeout(searchTimeout, 0); }
-
-
-
-
-
-
- public bool openChannel(UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return (ANT_OpenChannel(unmanagedANTFramerPointer, channelNumber, responseWaitTime) == 1);
- }
-
-
-
- public void openChannel() { openChannel(0); }
-
-
-
-
-
-
- public bool sendBroadcastData(byte[] data)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- int padNum = 8 - data.Length;
- if (padNum < 0)
- throw new ANT_Exception("Send data must not be greater than 8 bytes");
- data = data.Concat(new byte[padNum]).ToArray();
- return ANT_SendBroadcastData(unmanagedANTFramerPointer, channelNumber, data) == 1;
- }
-
-
-
-
-
-
-
-
- public ANT_ReferenceLibrary.MessagingReturnCode sendAcknowledgedData(byte[] data, UInt32 ackWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- int padNum = 8 - data.Length;
- if (padNum < 0)
- throw new ANT_Exception("Send data must not be greater than 8 bytes");
- data = data.Concat(new byte[padNum]).ToArray();
- return (ANT_ReferenceLibrary.MessagingReturnCode)ANT_SendAcknowledgedData(unmanagedANTFramerPointer, channelNumber, data, ackWaitTime);
- }
-
-
-
-
-
- public void sendAcknowledgedData(byte[] data) { sendAcknowledgedData(data, 0); }
-
-
-
-
-
-
-
- public ANT_ReferenceLibrary.MessagingReturnCode sendBurstTransfer(byte[] data, UInt32 completeWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- int padNum = 8 - (data.Length % 8);
- if(padNum != 8)
- data = data.Concat(new byte[padNum]).ToArray();
- return (ANT_ReferenceLibrary.MessagingReturnCode)ANT_SendBurstTransfer(unmanagedANTFramerPointer, channelNumber, data, (uint)data.Length, completeWaitTime);
- }
-
-
-
-
- public void sendBurstTransfer(byte[] data) { sendBurstTransfer(data, 0); }
-
-
-
-
-
-
-
-
-
- public bool sendExtBroadcastData(UInt16 deviceNumber, byte deviceTypeID, byte transmissionTypeID, byte[] data)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- int padNum = 8 - data.Length;
- if (padNum < 0)
- throw new ANT_Exception("Send data must not be greater than 8 bytes");
- data = data.Concat(new byte[padNum]).ToArray();
- return ANT_SendExtBroadcastData(unmanagedANTFramerPointer, channelNumber, deviceNumber, deviceTypeID, transmissionTypeID, data) == 1;
- }
-
-
-
-
-
-
-
-
-
-
-
- public ANT_ReferenceLibrary.MessagingReturnCode sendExtAcknowledgedData(UInt16 deviceNumber, byte deviceTypeID, byte transmissionTypeID, byte[] data, UInt32 ackWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- int padNum = 8 - data.Length;
- if (padNum < 0)
- throw new ANT_Exception("Send data must not be greater than 8 bytes");
- data = data.Concat(new byte[padNum]).ToArray();
- return (ANT_ReferenceLibrary.MessagingReturnCode)ANT_SendExtAcknowledgedData(unmanagedANTFramerPointer, channelNumber, deviceNumber, deviceTypeID, transmissionTypeID, data, ackWaitTime);
- }
-
-
-
-
-
-
-
-
- public void sendExtAcknowledgedData(UInt16 deviceNumber, byte deviceTypeID, byte transmissionTypeID, byte[] data) { sendExtAcknowledgedData(deviceNumber, deviceTypeID, transmissionTypeID, data, 0); }
-
-
-
-
-
-
-
-
-
-
- public ANT_ReferenceLibrary.MessagingReturnCode sendExtBurstTransfer(UInt16 deviceNumber, byte deviceTypeID, byte transmissionTypeID, byte[] data, UInt32 completeWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
-
- int padNum = 8 - (data.Length % 8);
- if(padNum != 8)
- data = data.Concat(new byte[padNum]).ToArray();
- return (ANT_ReferenceLibrary.MessagingReturnCode)ANT_SendExtBurstTransfer(unmanagedANTFramerPointer, channelNumber, deviceNumber, deviceTypeID, transmissionTypeID, data, (uint)data.Length, completeWaitTime);
- }
-
-
-
-
-
-
-
- public void sendExtBurstTransfer(UInt16 deviceNumber, byte deviceTypeID, byte transmissionTypeID, byte[] data) { sendExtBurstTransfer(deviceNumber, deviceTypeID, transmissionTypeID, data, 0); }
-
-
-
-
-
-
- public bool closeChannel(UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return (ANT_CloseChannel(unmanagedANTFramerPointer, channelNumber, responseWaitTime) == 1);
- }
-
-
-
- public void closeChannel() { closeChannel(0); }
-
-
-
-
-
-
-
-
-
- public bool setLowPrioritySearchTimeout(byte lowPriorityTimeout, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return ANT_SetLowPriorityChannelSearchTimeout(unmanagedANTFramerPointer, channelNumber, lowPriorityTimeout, responseWaitTime) == 1;
- }
-
-
-
-
-
- public void setLowPrioritySearchTimeout(byte lowPriorityTimeout) { setLowPrioritySearchTimeout(lowPriorityTimeout, 0); }
-
-
-
-
-
-
-
-
-
-
-
-
- public bool includeExcludeList_addChannel(UInt16 deviceNumber, byte deviceTypeID, byte transmissionTypeID, byte listIndex, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- if (listIndex > 3)
- throw new ANT_Exception("listIndex must be 0..3");
- return ANT_AddChannelID(unmanagedANTFramerPointer, channelNumber, deviceNumber, deviceTypeID, transmissionTypeID, listIndex, responseWaitTime) == 1;
- }
-
-
-
-
-
-
-
-
-
- public void includeExcludeList_addChannel(UInt16 deviceNumber, byte deviceTypeID, byte transmissionTypeID, byte listIndex)
- {
- includeExcludeList_addChannel(deviceNumber, deviceTypeID, transmissionTypeID, listIndex, 0);
- }
-
-
-
-
-
-
-
-
-
-
- public bool includeExcludeList_Configure(byte listSize, bool isExclusionList, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- if (listSize > 4)
- throw new ANT_Exception("Inclusion Exclusion List has a maximum size of 4");
- return ANT_ConfigList(unmanagedANTFramerPointer, channelNumber, listSize, Convert.ToByte(isExclusionList), responseWaitTime) == 1;
- }
-
-
-
-
-
-
-
- public void includeExcludeList_Configure(byte listSize, bool isExclusionList) { includeExcludeList_Configure(listSize, isExclusionList, 0); }
-
-
-
-
-
-
-
-
-
-
- public bool encryptedChannelEnable(ANT_ReferenceLibrary.EncryptedChannelMode encryptionMode, byte volatileKeyIndex, byte decimationRate, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return ANT_EncryptedChannelEnable(unmanagedANTFramerPointer, channelNumber, (byte)encryptionMode, volatileKeyIndex,
- decimationRate, responseWaitTime) == 1;
- }
-
-
-
-
-
-
-
- public void encryptedChannelEnable(ANT_ReferenceLibrary.EncryptedChannelMode encryptionMode,
- byte volatileKeyIndex, byte decimationRate)
- {
- encryptedChannelEnable(encryptionMode, volatileKeyIndex, decimationRate, 0);
- }
-
-
-
-
-
-
-
-
- public bool encryptionIDList_AddID(byte[] encryptionID, byte listIndex, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- if (listIndex > 3)
- throw new ANT_Exception("listIndex must be 0..3");
- return ANT_AddCryptoID(unmanagedANTFramerPointer, channelNumber, encryptionID, listIndex, responseWaitTime) == 1;
- }
-
-
-
-
-
- public void encryptionIDList_AddID(byte[] encryptionID, byte listIndex)
- {
- encryptionIDList_AddID(encryptionID, listIndex, 0);
- }
-
-
-
-
-
-
-
-
-
-
- public bool encryptionIDList_Configure(byte listSize, bool isBlacklist, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- if (listSize > 4)
- throw new ANT_Exception("Blacklist Whitelist has a maximum size of 4");
- return ANT_ConfigCryptoList(unmanagedANTFramerPointer, channelNumber, listSize, Convert.ToByte(isBlacklist), responseWaitTime) == 1;
- }
-
-
-
-
-
-
-
- public void encryptionIDList_Configure(byte listSize, bool isBlacklist)
- {
- encryptionIDList_Configure(listSize, isBlacklist, 0);
- }
-
-
-
-
-
-
-
-
-
-
- public bool setProximitySearch(byte thresholdBin, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- if (thresholdBin > 10)
- throw new ANT_Exception("Threshold bin must be 0-10");
- return ANT_SetProximitySearch(unmanagedANTFramerPointer, channelNumber, thresholdBin, responseWaitTime) == 1;
- }
-
-
-
-
-
-
- public void setProximitySearch(byte thresholdBin) { setProximitySearch(thresholdBin, 0);}
-
-
-
-
-
-
-
-
-
-
-
-
- public bool configFrequencyAgility(byte freq1, byte freq2, byte freq3, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return ANT_ConfigFrequencyAgility(unmanagedANTFramerPointer, channelNumber, freq1, freq2, freq3, responseWaitTime) == 1;
- }
-
-
-
-
-
-
-
-
- public void configFrequencyAgility(byte freq1, byte freq2, byte freq3) { configFrequencyAgility(freq1, freq2, freq3, 0); }
-
-
-
-
-
-
-
- public bool configSdu(byte sduConfig, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return ANT_ConfigSelectiveDataUpdate(unmanagedANTFramerPointer, channelNumber, sduConfig, responseWaitTime) == 1;
- }
-
-
-
-
- public void configSdu(byte sduConfig) { configSdu(sduConfig, 0); }
-
-
-
-
-
-
-
-
-
-
-
- public bool setSearchSharingCycles(byte searchSharingCycles, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return ANT_SetSearchSharingCycles(unmanagedANTFramerPointer, channelNumber, searchSharingCycles, responseWaitTime) == 1;
- }
-
-
-
-
-
-
-
-
- public void setSearchSharingCycles(byte searchSharingCycles)
- {
- setSearchSharingCycles(searchSharingCycles, 0);
- }
-
-
-
-
- public void setChannelSearchPriority(byte priorityLevel)
- {
- setChannelSearchPriority(priorityLevel, 0);
- }
-
-
-
-
-
-
-
- public bool setChannelSearchPriority(byte priorityLevel, UInt32 responseWaitTime)
- {
- if (disposed)
- throw new ObjectDisposedException("This ANTChannel object has been disposed");
- return ANT_SetChannelSearchPriority(unmanagedANTFramerPointer, channelNumber, priorityLevel, responseWaitTime) == 1;
- }
- #endregion
- }
- }
|