예제 #1
0
        private async Task <ERROR_CODE> BleConnect(DeviceList idx, string devName)
        {
            ERROR_CODE result = ERROR_CODE.NONE;

            switch (idx)
            {
            case DeviceList.BLE1:
                result = ble1.StartScan(devName, (d) => { });
                showmessage1(result.ToString());
                if (result.Equals(ERROR_CODE.BLE_FOUND_DEVICE))
                {
                    result = await ble1.OpenDevice(devName);

                    showmessage1($"Connection Result: {result}");
                }
                ;
                break;

            case DeviceList.BLE2:
                result = ble2.StartScan(devName, (d) => { });
                showmessage2(result.ToString());
                if (result.Equals(ERROR_CODE.BLE_FOUND_DEVICE))
                {
                    result = await ble2.OpenDevice(devName);

                    showmessage2($"Connection Result: {result}");
                }
                ;
                break;

            case DeviceList.BLE3:
                result = ble3.StartScan(devName, (d) => { });
                showmessage3(result.ToString());
                if (result.Equals(ERROR_CODE.BLE_FOUND_DEVICE))
                {
                    result = await ble3.OpenDevice(devName);

                    showmessage3($"Connection Result: {result}");
                }
                ;
                break;

            case DeviceList.BLE4:
                result = ble4.StartScan(devName, (d) => { });
                showmessage4(result.ToString());
                if (result.Equals(ERROR_CODE.BLE_FOUND_DEVICE))
                {
                    result = await ble4.OpenDevice(devName);

                    showmessage4($"Connection Result: {result}");
                }
                ;
                break;
            }
            return(result);
        }
예제 #2
0
        public async Task <ERROR_CODE> BleConnect(int index, string devName)
        {
            ERROR_CODE result = ERROR_CODE.NONE;

            result = ble[index].StartScan(devName, (d) => { });
            if (result.Equals(ERROR_CODE.BLE_FOUND_DEVICE))
            {
                result = await ble[index].OpenDevice(devName);
            }
            ;
            return(result);
        }