예제 #1
0
 internal BluetopiaFactory(IBluetopiaApi api)
     : this(api, null)
 {
 }
예제 #2
0
        internal BluetopiaFactory(IBluetopiaApi api, IBluetopiaSecurity optionalSecurityInstance)
        {
            if (api == null)
            {
                throw new ArgumentNullException("api");
            }
            _api = api;
            //
            _inquiryHandler       = new BluetopiaInquiry(this);
            _inquiryEventCallback = _inquiryHandler.HandleInquiryEvent;
            _HandleNameLookup     = HandleNameLookup;
            //
            //int handle = _api.BSC_Initialize((byte[])InitData.Clone(), 0);
            Utils.MiscUtils.Trace_WriteLine(
                "Calling BSC_Initialize with:" + InitData2.ToString());
            int handle = _api.BSC_Initialize(ref InitData2, 0);
            //TEST--CheckStructBytes(ref InitData2, (byte[])InitData.Clone());
            var ret = (BluetopiaError)handle;

            if (!BluetopiaUtils.IsSuccessZeroIsIllegal(ret))
            {
                KillBtExplorerExe();  // Since one app at a time!
                // _Quickly_ try to init, as BTExplorer.exe restarts automatically!
                handle = _api.BSC_Initialize(ref InitData2, 0);
                ret    = (BluetopiaError)handle;
            }
            if (!BluetopiaUtils.IsSuccessZeroIsIllegal(ret))
            {
                Utils.MiscUtils.Trace_WriteLine("Stonestreet One Bluetopia failed to init: "
                                                + BluetopiaUtils.ErrorToString(ret));
            }
            BluetopiaUtils.CheckAndThrowZeroIsIllegal(ret, "BSC_Initialize");
            _stackId = checked ((uint)handle);
            //
            if (optionalSecurityInstance != null)
            {
                _sec = optionalSecurityInstance;
            }
            else
            {
                _sec = new BluetopiaSecurity(this);
            }
            _sec.InitStack();
            //
            //
            var packetDebug = false;
            var eap         = BluetoothFactoryConfig.GetEntryAssemblyPath();

            if (eap != null)   // null if we're under unit-test or...
            {
                var dir      = Path.GetDirectoryName(eap);
                var filename = Path.Combine(dir, "DoPacketDebug.txt");
                if (File.Exists(filename))
                {
                    packetDebug = true;
                }
            }
            if (packetDebug)
            {
                _pdebug = new BluetopiaPacketDebug(this);
            }
            //
            InitApiVersion();
        }
예제 #3
0
 //----
 internal static void HackAllowShutdownCall(IBluetopiaApi mockedApi)
 {
     Expect.Between(0, 1).On(mockedApi).Method("BSC_Shutdown").WithAnyArguments();
 }