コード例 #1
0
ファイル: BluetoothData.cs プロジェクト: yoowonyoung/TizenFX
        /// <summary>
        /// The default constructor. Initializes an object of the BluetoothHidReceivedData.
        /// </summary>
        /// <since_tizen> 6 </since_tizen>
        internal static BluetoothHidDeviceReceivedData Create(BluetoothHidDeviceReceivedDataStruct structInfo)
        {
            BluetoothHidDeviceReceivedData receivedData = new BluetoothHidDeviceReceivedData();

            receivedData.Address    = structInfo.RemoteAddress;
            receivedData.HeaderType = structInfo.headerType;
            receivedData.ParamType  = structInfo.paramType;
            if (structInfo.dataSize > 0)
            {
                receivedData.Data = new byte[structInfo.dataSize];
                Marshal.Copy(structInfo.data, receivedData.Data, 0, structInfo.dataSize);
            }
            return(receivedData);
        }
コード例 #2
0
        private void RegisterHidDataReceivedEvent()
        {
            Interop.Bluetooth.HidDeviceDataReceivedCallback _hidDeviceDataReceivedCallback = (ref BluetoothHidDeviceReceivedDataStruct receivedData, IntPtr userData) =>
            {
                _hidDeviceDataReceived?.Invoke(null, new HidDeviceDataReceivedEventArgs(BluetoothHidDeviceReceivedData.Create(receivedData)));
            };

            int ret = Interop.Bluetooth.SetHidDeviceDataReceivedCallback(_hidDeviceDataReceivedCallback, IntPtr.Zero);

            if (ret != (int)BluetoothError.None)
            {
                Log.Error(Globals.LogTag, "Failed to set data received callback, Error - " + (BluetoothError)ret);
                BluetoothErrorFactory.ThrowBluetoothException(ret);
            }
        }
コード例 #3
0
 internal HidDeviceDataReceivedEventArgs(BluetoothHidDeviceReceivedData receivedData)
 {
     ReceivedData = receivedData;
 }