Esempio n. 1
0
    /// <summary>
    /// Scans the dveice.
    /// </summary>
    void ScanDveice()
    {
        var               mBluetoothLeScanner = bluetoothAdapter.Call <AndroidJavaObject>("getBluetoothLeScanner");
        ScanCallback      scanCallback        = new ScanCallback();
        AndroidJavaObject wfzScanCallback     = new AndroidJavaObject("com.ridk.unityextension.RidkScanCallback");

        scanCallback.onScanResultDelegate = (t, r) =>
        {
            if (r == null)
            {
                return;
            }
            var bluetoothDevice = r.Call <AndroidJavaObject>("getDevice");
            var deviceName      = bluetoothDevice.Call <string>("getName");
            var deviceAddress   = bluetoothDevice.Call <string>("getAddress");
            Debug.Log("扫描到设备:" + deviceName + "地址:" + deviceAddress);

            if (deviceName == "CAD")
            {
                if (buetoothGatt == null)
                {
                    ConnectGatt(bluetoothDevice);
                    mBluetoothLeScanner.Call("stopScan", wfzScanCallback);
                }
            }
        };

        wfzScanCallback.Call("AddUnityCallback", scanCallback);
        mBluetoothLeScanner.Call("startScan", wfzScanCallback);
    }
Esempio n. 2
0
        void InitializeScanner()
        {
            if (_adapter == null)
            {
                return;
            }

            // initialize scanner
            var sb = new ScanSettings.Builder()
                     .SetCallbackType(ScanCallbackType.AllMatches)
                     .SetScanMode(ScanMode.LowLatency);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
            {
                sb = sb.SetMatchMode(BluetoothScanMatchMode.Aggressive).SetNumOfMatches(1);
            }

            _scanSettings = sb.Build();
            sb.SetReportDelay(1000);
            _scanSettingsBatch = sb.Build();

            _scanner           = _adapter.BluetoothLeScanner;
            _scanCallback      = new ScanCallbackImpl(this);
            _scanCallbackBatch = new BatchScanCallbackImpl();
        }
Esempio n. 3
0
        public void StartScanning(Context context, TracingInformation tracingInformation)
        {
            if (!Initialized)
            {
                _logger.LogError("Scanner - Starting failed - not initialized.");
                return;
            }

            try
            {
                _tracingInformation = tracingInformation;

                _logger.LogDebug($"Scanner - Starting for service {_tracingInformation.ServiceId}.");

                if (_scanCallback == null)
                {
                    _scanCallback = new BtScanCallback(context, _manager, tracingInformation);
                }
                System.Threading.Tasks.Task.Run(() =>
                {
                    _leScanner.StartScan(BuildScanFilters(_tracingInformation), BuildScanSettings(), _scanCallback);
                }).FireAndForget();
                Covi.Features.BluetoothTracing.TracingState.Instance.SetScanningState(true);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Scanner - Starting failed.");
            }
        }
Esempio n. 4
0
        private void InitScanner()
        {
            if (IsAfterLollipop && !(Filters?.Any() ?? false))
            {
                if (Filters == null)
                {
                    Filters = new List <ScanFilter>();
                }
                else
                {
                    Filters.Clear();
                }
                Filters.Add(new ScanFilter.Builder().SetServiceUuid(BcoreUuid.BcoreScanUuid).Build());
            }

            if (IsAfterLollipop && ScanSettings == null)
            {
                ScanSettings = new ScanSettings.Builder().SetScanMode(ScanMode.Balanced).Build();
            }

            if (IsAfterLollipop && Callback == null)
            {
                Callback = new ScanCallback(this);
            }

            if (!IsAfterLollipop && LeCallback == null)
            {
                LeCallback = new LeScanCallback(this);
            }
        }
Esempio n. 5
0
 public Bluetooth(Context context)
 {
     _manager      = (BluetoothManager)context.GetSystemService(Class.FromType(typeof(BluetoothManager)));
     _scanner      = _manager.Adapter.BluetoothLeScanner;
     _scanCallback = new ScanCallback(this);
     _identifier   = Injection.GetDeviceId(context);
 }
Esempio n. 6
0
        /// <summary>
        /// Scan the CEC bus and get active devices.
        /// </summary>
        public List <CecLogicalAddress> Scan()
        {
            List <CecLogicalAddress> devices = new List <CecLogicalAddress>(10);
            ScanCallback             cb      = i => devices.Add(i);

            CecManager_Scan(ptr, cb);
            return(devices);
        }
        public async Task Cancel()
        {
            LastScanResult = null;

            await StopScanningAsync();

            ScanCallback?.Invoke(null);
        }
Esempio n. 8
0
        public BES( )
        {
            var btManager = (BluetoothManager)Application.Context.GetSystemService(Context.BluetoothService);

            _btadapter  = btManager.Adapter;
            _filt       = Pega_filtros();
            _sets       = new ScanSettings.Builder().SetScanMode(ScanMode.LowLatency).Build();
            _btcallback = new BLECallback(_btd, _filt, _sets);
            _error      = "-";
        }
Esempio n. 9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
            ScanCallback = new ScanCallbackClass()
            {
                OnSuccess = OnSuccess
            };
            ActivateMiBand();
        }
Esempio n. 10
0
 public BluetoothConnector()
 {
     this.context      = Android.App.Application.Context;
     bluetoothManager  = (BluetoothManager)context.GetSystemService(Context.BluetoothService);
     bluetoothAdapter  = bluetoothManager.Adapter;
     bluetoothScanner  = bluetoothManager.Adapter.BluetoothLeScanner;
     bluetoothReceiver = new BluetoothReceiver(devicesResults, macAddressMapping);
     context.RegisterReceiver(bluetoothReceiver, new IntentFilter(BluetoothDevice.ActionFound));
     context.RegisterReceiver(bluetoothReceiver, new IntentFilter(BluetoothDevice.ExtraRssi));
     this.scanThread   = new Thread(Scan);
     this.scanCallback = new BluetoothScanCallback(devicesResults, macAddressMapping);
 }
Esempio n. 11
0
        public void StopScanning()
        {
            if (!Initialized)
            {
                return;
            }

            _leScanner.StopScan(_scanCallback);
            _scanCallback?.Dispose();
            _scanCallback = null;
            Covi.Features.BluetoothTracing.TracingState.Instance.SetScanningState(false);
        }
Esempio n. 12
0
 public ScanCommand
 (
     ScanPolicy policy,
     string ns,
     string setName,
     ScanCallback callback,
     string[] binNames,
     ulong taskId
 ) : base(true)
 {
     this.policy   = policy;
     this.ns       = ns;
     this.setName  = setName;
     this.callback = callback;
     this.binNames = binNames;
     this.taskId   = taskId;
 }
Esempio n. 13
0
        public ScanCommand(
			Node node, 
			ScanPolicy policy,
			string ns,
			string setName,
			ScanCallback callback,
			string[] binNames,
			long taskId
		)
            : base(node, true)
        {
            this.policy = policy;
            this.ns = ns;
            this.setName = setName;
            this.callback = callback;
            this.binNames = binNames;
            this.taskId = taskId;
        }
 public ScanCommand
 (
     ScanPolicy policy,
     string ns,
     string setName,
     ScanCallback callback,
     string[] binNames,
     ulong taskId,
     ulong clusterKey,
     bool first
 ) : base(ns, clusterKey, first)
 {
     this.policy   = policy;
     this.setName  = setName;
     this.callback = callback;
     this.binNames = binNames;
     this.taskId   = taskId;
 }
Esempio n. 15
0
        public static void stopScan(ScanCallback callback)
        {
            BluetoothAdapter adapter = BluetoothAdapter.DefaultAdapter;

            if (adapter == null)
            {
                Log.Debug(tag, "BluetoothAdapter is null");
            }

            BluetoothLeScanner scaner = adapter.BluetoothLeScanner;

            if (scaner == null)
            {
                Log.Debug(tag, "BluetoothLeScanner is null");
            }

            scaner.StopScan(callback);
        }
 public ScanCommand
 (
     Cluster cluster,
     Node node,
     ScanPolicy scanPolicy,
     string ns,
     string setName,
     string[] binNames,
     ScanCallback callback,
     ulong taskId,
     ulong clusterKey,
     bool first
 ) : base(cluster, scanPolicy, node, ns, clusterKey, first)
 {
     this.scanPolicy = scanPolicy;
     this.setName    = setName;
     this.binNames   = binNames;
     this.callback   = callback;
     this.taskId     = taskId;
 }
 public ScanPartitionCommand
 (
     Cluster cluster,
     ScanPolicy scanPolicy,
     string ns,
     string setName,
     string[] binNames,
     ScanCallback callback,
     ulong taskId,
     PartitionTracker tracker,
     NodePartitions nodePartitions
 ) : base(cluster, scanPolicy, nodePartitions.node, ns, tracker.socketTimeout, tracker.totalTimeout)
 {
     this.scanPolicy     = scanPolicy;
     this.setName        = setName;
     this.binNames       = binNames;
     this.callback       = callback;
     this.taskId         = taskId;
     this.tracker        = tracker;
     this.nodePartitions = nodePartitions;
 }
 public WifiScanConnectWrap(NativeWifiManager wifiManager)
 {
     nativeWifiManager = wifiManager;
     mScanCallback     = new ScanCallback();
 }
        //-------------------------------------------------------
        // Scan Operations
        //-------------------------------------------------------
        /// <summary>
        /// Read all records in specified namespace and set.  If the policy's 
        /// concurrentNodes is specified, each server node will be read in
        /// parallel.  Otherwise, server nodes are read in series.
        /// <para>
        /// This call will block until the scan is complete - callbacks are made
        /// within the scope of this call.
        /// </para>
        /// </summary>
        /// <param name="policy">scan configuration parameters, pass in null for defaults</param>
        /// <param name="ns">namespace - equivalent to database name</param>
        /// <param name="setName">optional set name - equivalent to database table</param>
        /// <param name="callback">read callback method - called with record data</param>
        /// <param name="binNames">
        /// optional bin to retrieve. All bins will be returned if not specified.
        /// Aerospike 2 servers ignore this parameter.
        /// </param>
        /// <exception cref="AerospikeException">if scan fails</exception>
        public void ScanAll(ScanPolicy policy, string ns, string setName, ScanCallback callback, params string[] binNames)
        {
            if (policy == null)
            {
                policy = scanPolicyDefault;
            }

            Node[] nodes = cluster.Nodes;

            if (nodes.Length == 0)
            {
                throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Scan failed because cluster is empty.");
            }

            if (policy.concurrentNodes)
            {
                Executor executor = new Executor(nodes.Length);
                ulong taskId = RandomShift.ThreadLocalInstance.NextLong();

                foreach (Node node in nodes)
                {
                    ScanCommand command = new ScanCommand(node, policy, ns, setName, callback, binNames, taskId);
                    executor.AddCommand(command);
                }

                executor.Execute(policy.maxConcurrentNodes);
            }
            else
            {
                foreach (Node node in nodes)
                {
                    ScanNode(policy, node, ns, setName, callback, binNames);
                }
            }
        }
 /// <summary>
 /// Read all records in specified namespace and set for one node only.
 /// The node is specified by name.
 /// <para>
 /// This call will block until the scan is complete - callbacks are made
 /// within the scope of this call.
 /// </para>
 /// </summary>
 /// <param name="policy">scan configuration parameters, pass in null for defaults</param>
 /// <param name="nodeName">server node name</param>
 /// <param name="ns">namespace - equivalent to database name</param>
 /// <param name="setName">optional set name - equivalent to database table</param>
 /// <param name="callback">read callback method - called with record data</param>
 /// <param name="binNames">
 /// optional bin to retrieve. All bins will be returned if not specified.
 /// Aerospike 2 servers ignore this parameter.
 /// </param>
 /// <exception cref="AerospikeException">if scan fails</exception>
 public void ScanNode(ScanPolicy policy, string nodeName, string ns, string setName, ScanCallback callback, params string[] binNames)
 {
     Node node = cluster.GetNode(nodeName);
     ScanNode(policy, node, ns, setName, callback, binNames);
 }
 static BluetoothLEScanner()
 {
     Current       = new BluetoothLEScanner();
     _scanCallback = new BluetoothLEScannerScanCallback(Current);
 }
        /// <summary>
        /// Read all records in specified namespace and set for one node only.
        /// <para>
        /// This call will block until the scan is complete - callbacks are made
        /// within the scope of this call.
        /// </para>
        /// </summary>
        /// <param name="policy">scan configuration parameters, pass in null for defaults</param>
        /// <param name="node">server node</param>
        /// <param name="ns">namespace - equivalent to database name</param>
        /// <param name="setName">optional set name - equivalent to database table</param>
        /// <param name="callback">read callback method - called with record data</param>
        /// <param name="binNames">
        /// optional bin to retrieve. All bins will be returned if not specified.
        /// Aerospike 2 servers ignore this parameter.
        /// </param>
        /// <exception cref="AerospikeException">if transaction fails</exception>
        public void ScanNode(ScanPolicy policy, Node node, string ns, string setName, ScanCallback callback, params string[] binNames)
        {
            if (policy == null)
            {
                policy = scanPolicyDefault;
            }
            ulong taskId = RandomShift.ThreadLocalInstance.NextLong();

            ScanCommand command = new ScanCommand(node, policy, ns, setName, callback, binNames, taskId);
            command.Execute();
        }
        public static void ScanPartitions(Cluster cluster, ScanPolicy policy, string ns, string setName, string[] binNames, ScanCallback callback, PartitionTracker tracker)
        {
            policy.Validate();

            while (true)
            {
                ulong taskId = RandomShift.ThreadLocalInstance.NextLong();

                try
                {
                    List <NodePartitions> list = tracker.AssignPartitionsToNodes(cluster, ns);

                    if (policy.concurrentNodes && list.Count > 1)
                    {
                        Executor executor = new Executor(list.Count);

                        foreach (NodePartitions nodePartitions in list)
                        {
                            ScanPartitionCommand command = new ScanPartitionCommand(cluster, policy, ns, setName, binNames, callback, taskId, tracker, nodePartitions);
                            executor.AddCommand(command);
                        }

                        executor.Execute(policy.maxConcurrentNodes);
                    }
                    else
                    {
                        foreach (NodePartitions nodePartitions in list)
                        {
                            ScanPartitionCommand command = new ScanPartitionCommand(cluster, policy, ns, setName, binNames, callback, taskId, tracker, nodePartitions);
                            command.Execute();
                        }
                    }
                }
                catch (AerospikeException ae)
                {
                    ae.Iteration = tracker.iteration;
                    throw ae;
                }

                if (tracker.IsComplete(policy))
                {
                    // Scan is complete.
                    return;
                }

                if (policy.sleepBetweenRetries > 0)
                {
                    // Sleep before trying again.
                    Util.Sleep(policy.sleepBetweenRetries);
                }
            }
        }
Esempio n. 24
0
        public bool ScanDirectory(string DirPrefix, ScanCallback Callback, BuildDBInfo UserData)
        {
            PInvoke.WIN32_FIND_DATA FindData;

            var DirIndice = (uint)Directories.Count - 1;

            var SearchString = DirPrefix + "*";

            var FindHandle = PInvoke.FindFirstFile(SearchString, out FindData);

            if (FindHandle == PInvoke.INVALID_HANDLE_VALUE)
            {
                return(false);
            }

            do
            {
                UInt64 FileSize = ((FindData.nFileSizeHigh << 32) | FindData.nFileSizeLow);

                FileInfo       Info   = new FileInfo(FindData.cFileName, DirIndice, FileSize, FindData.dwFileAttributes);
                SafeFileHandle Handle = null;

                // DonLL't ever include '.L' and '..'
                if (Info.Name == "." || Info.Name == "..")
                {
                    continue;
                }

                //Info.FullName = DirPrefix + Info.Name;

                Info.Clusters = 0;
                if (GetClusterInfo(Info, ref Handle))
                {
                    UInt64 TotalClusters = Info.Fragments.Aggregate <Extent, ulong>(0, (current, ext) => current + ext.Length);

                    Info.Clusters = TotalClusters;
                }
                else
                {
                    Info.Attributes.Unmovable = true;
                    Info.Attributes.Process   = false;
                }

                if (Info.Attributes.Process)
                {
                    Info.Attributes.Process = ShouldProcess(Info.Attributes);
                }

                // Run the user-defined callback function
                var CallbackResult = Callback(ref Info, ref Handle, ref UserData);

                if (!Handle.IsInvalid && !Handle.IsClosed)
                {
                    Handle.Close();
                }

                if (!CallbackResult)
                {
                    break;
                }

                // If directory, perform recursion
                if (Info.Attributes.Directory)
                {
                    var Dir = GetDBDir(Info.DirIndice);
                    Dir += Info.Name;
                    Dir += "\\";

                    Directories.Add(Dir);
                    ScanDirectory(Dir, Callback, UserData);
                }
            } while (PInvoke.FindNextFile(FindHandle, out FindData));

            PInvoke.FindClose(FindHandle);
            return(false);
        }
        public static void ScanNodes(Cluster cluster, ScanPolicy policy, string ns, string setName, string[] binNames, ScanCallback callback, Node[] nodes)
        {
            policy.Validate();

            // Detect cluster migrations when performing scan.
            ulong taskId     = RandomShift.ThreadLocalInstance.NextLong();
            ulong clusterKey = policy.failOnClusterChange ? QueryValidate.ValidateBegin(nodes[0], ns) : 0;
            bool  first      = true;

            if (policy.concurrentNodes && nodes.Length > 1)
            {
                Executor executor = new Executor(nodes.Length);

                foreach (Node node in nodes)
                {
                    ScanCommand command = new ScanCommand(cluster, node, policy, ns, setName, binNames, callback, taskId, clusterKey, first);
                    executor.AddCommand(command);
                    first = false;
                }
                executor.Execute(policy.maxConcurrentNodes);
            }
            else
            {
                foreach (Node node in nodes)
                {
                    ScanCommand command = new ScanCommand(cluster, node, policy, ns, setName, binNames, callback, taskId, clusterKey, first);
                    command.Execute();
                    first = false;
                }
            }
        }
Esempio n. 26
0
 public bool startScan(ScanCallback callBack)
 {
     return(mWifiManager.startScan(callBack));
 }
Esempio n. 27
0
 internal static void Scan(string ct, int ct_begIdx, int ct_endIdxExcl, ScanCallback scanCallback)
 {
     if (ct == null)
     {
         throw new ArgumentNullException();
     }
     int iLast = ct_begIdx;
     while (true)
     {
         int i = ct.IndexOf('[', iLast, ct_endIdxExcl - iLast);
         if (i < 0)
         {
             break;
         }
         if (!scanCallback(iLast, i, 0))
         {
             return;
         }
         int ii = i + 1;
         ScanCallbackFlags flags = 0;
         while (true)
         {
             ii = ct.IndexOf(']', ii, ct_endIdxExcl - ii);
             if (ii < 0)
             {
                 throw new ArgumentException();
             }
             if (ii + 1 == ct.Length || ct[ii + 1] != ']')
             {
                 break;
             }
             flags |= ScanCallbackFlags.IsQuotedIdentifier_ContainsRightSquareBrackets;
         }
         if (!scanCallback(i + 1, ii, flags | ScanCallbackFlags.IsQuotedIdentifier))
         {
             return;
         }
         iLast = ii + 1;
     }
     scanCallback(iLast, ct.Length, 0);
 }
Esempio n. 28
0
 private static extern void CecManager_Scan(IntPtr ptr, ScanCallback cb);
Esempio n. 29
0
        ///////////////////////////////////////////////////////////////////////////////
        // Public Functions, these are the essentials...
        ///////////////////////////////////////////////////////////////////////////////
        #region Public Functions...

        /// <summary>
        /// Our constructor...
        /// </summary>
        /// <param name="a_szManufacturer">Application manufacturer</param>
        /// <param name="a_szProductFamily">Application product family</param>
        /// <param name="a_szProductName">Name of the application</param>
        /// <param name="a_u16ProtocolMajor">TWAIN protocol major (doesn't have to match TWAINH.CS)</param>
        /// <param name="a_u16ProtocolMinor">TWAIN protocol minor (doesn't have to match TWAINH.CS)</param>
        /// <param name="a_u32SupportedGroups">Bitmask of DG_ flags</param>
        /// <param name="a_twcy">Country code for the application</param>
        /// <param name="a_szInfo">Info about the application</param>
        /// <param name="a_twlg">Language code for the application</param>
        /// <param name="a_u16MajorNum">Application's major version</param>
        /// <param name="a_u16MinorNum">Application's minor version</param>
        /// <param name="a_blUseLegacyDSM">Use the legacy DSM (like TWAIN_32.DLL)</param>
        /// <param name="a_blUseCallbacks">Use callbacks instead of Windows post message</param>
        /// <param name="a_deviceeventback">Function to receive device events</param>
        /// <param name="a_scancallback">Function to handle scanning</param>
        /// <param name="a_runinuithreaddelegate">Help us run in the GUI thread on Windows</param>
        /// <param name="a_intptrHwnd">window handle</param>
        public TWAIN
        (
            string a_szManufacturer,
            string a_szProductFamily,
            string a_szProductName,
            ushort a_u16ProtocolMajor,
            ushort a_u16ProtocolMinor,
            uint a_u32SupportedGroups,
            TWCY a_twcy,
            string a_szInfo,
            TWLG a_twlg,
            ushort a_u16MajorNum,
            ushort a_u16MinorNum,
            bool a_blUseLegacyDSM,
            bool a_blUseCallbacks,
            DeviceEventCallback a_deviceeventback,
            ScanCallback a_scancallback,
            RunInUiThreadDelegate a_runinuithreaddelegate,
            IntPtr a_intptrHwnd
        )
        {
            TW_IDENTITY twidentity;

            // Since we're using P/Invoke in this sample, the DLL
            // is implicitly loaded as we access it, so we can
            // never go lower than state 2...
            m_state = STATE.S2;

            // Register the caller's info...
            twidentity = default(TW_IDENTITY);
            twidentity.Manufacturer.Set(a_szManufacturer);
            twidentity.ProductFamily.Set(a_szProductFamily);
            twidentity.ProductName.Set(a_szProductName);
            twidentity.ProtocolMajor = a_u16ProtocolMajor;
            twidentity.ProtocolMinor = a_u16ProtocolMinor;
            twidentity.SupportedGroups = a_u32SupportedGroups;
            twidentity.Version.Country = a_twcy;
            twidentity.Version.Info.Set(a_szInfo);
            twidentity.Version.Language = a_twlg;
            twidentity.Version.MajorNum = a_u16MajorNum;
            twidentity.Version.MinorNum = a_u16MinorNum;
            m_twidentityApp = twidentity;
            m_twidentitylegacyApp = TwidentityToTwidentitylegacy(twidentity);
            m_twidentitymacosxApp = TwidentityToTwidentitymacosx(twidentity);
            m_deviceeventcallback = a_deviceeventback;
            m_scancallback = a_scancallback;
            m_runinuithreaddelegate = a_runinuithreaddelegate;
            m_intptrHwnd = a_intptrHwnd;

            // Placeholder for our DS identity...
            m_twidentityDs = default(TW_IDENTITY);
            m_twidentitylegacyDs = default(TW_IDENTITY_LEGACY);
            m_twidentitymacosxDs = default(TW_IDENTITY_MACOSX);

            // We'll normally do an automatic get of DAT.STATUS, but if we'd
            // like to turn it off, this is the variable to hit...
            m_blAutoDatStatus = true;

            // Our helper functions from the DSM...
            m_twentrypointdelegates = default(TW_ENTRYPOINT_DELEGATES);

            // Our events...
            m_autoreseteventCaller = new AutoResetEvent(false);
            m_autoreseteventThread = new AutoResetEvent(false);
            m_autoreseteventRollback = new AutoResetEvent(false);
            m_autoreseteventThreadStarted = new AutoResetEvent(false);
            m_lockTwain = new Object();

            // Windows only...
            if (ms_platform == Platform.WINDOWS)
            {
                m_blUseLegacyDSM = a_blUseLegacyDSM;
                m_blUseCallbacks = a_blUseCallbacks;
                m_windowsdsmentrycontrolcallbackdelegate = WindowsDsmEntryCallbackProxy;
            }

            // Linux only...
            else if (ms_platform == Platform.LINUX)
            {
                m_blUseLegacyDSM = false;
                m_blUseCallbacks = true;
                m_linuxdsmentrycontrolcallbackdelegate = LinuxDsmEntryCallbackProxy;
            }

            // Mac OS X only...
            else if (ms_platform == Platform.MACOSX)
            {
                m_blUseLegacyDSM = false;
                m_blUseCallbacks = true;
                m_macosxdsmentrycontrolcallbackdelegate = MacosxDsmEntryCallbackProxy;
            }

            // Uh-oh, Log will throw an exception for us...
            else
            {
                TWAINWorkingGroup.Log.Assert("Unsupported platform..." + ms_platform);
            }

            // Activate our thread...
            if (m_threadTwain == null)
            {
                m_twaincommand = new TwainCommand();
                m_threadTwain = new Thread(Main);
                m_threadTwain.Start();
                if (!m_autoreseteventThreadStarted.WaitOne(5000))
                {
                    try
                    {
                        m_threadTwain.Abort();
                        m_threadTwain = null;
                    }
                    catch
                    {
                        // Log will throw an exception for us...
                        TWAINWorkingGroup.Log.Assert("Failed to start the TWAIN background thread...");
                    }
                }
            }
        }
        /// <summary>
        /// Read all records in specified namespace and set for one node only.
        /// <para>
        /// This call will block until the scan is complete - callbacks are made
        /// within the scope of this call.
        /// </para>
        /// </summary>
        /// <param name="policy">scan configuration parameters, pass in null for defaults</param>
        /// <param name="node">server node</param>
        /// <param name="ns">namespace - equivalent to database name</param>
        /// <param name="setName">optional set name - equivalent to database table</param>
        /// <param name="callback">read callback method - called with record data</param>
        /// <param name="binNames">
        /// optional bin to retrieve. All bins will be returned if not specified.
        /// Aerospike 2 servers ignore this parameter.
        /// </param>
        /// <exception cref="AerospikeException">if transaction fails</exception>
        public void ScanNode(ScanPolicy policy, Node node, string ns, string setName, ScanCallback callback, params string[] binNames)
        {
            if (policy == null)
            {
                policy = scanPolicyDefault;
            }
            long taskId = Environment.TickCount;

            ScanCommand command = new ScanCommand(node, policy, ns, setName, callback, binNames, taskId);
            command.Execute();
        }