private REM_DEV_INFO CreateREM_DEV_INFO(string name, BluetoothAddress addr)
        {
            var dev = new REM_DEV_INFO();

            if (name != null)
            {
                dev.bd_name = Encoding.UTF8.GetBytes(name + "\0");
            }
            if (addr != null)
            {
                dev.bda = WidcommUtils.FromBluetoothAddress(addr);
            }
            return(dev);
        }
 private REM_DEV_INFO_RETURN_CODE ReturnRememberedDevice(ref REM_DEV_INFO remDevInfo, bool firstGet)
 {
     if (_RememberedDevices == null)
     {
         Debug.Assert(_RememberedDevicesResultIndex == null);
         if (firstGet)
         {
             return(REM_DEV_INFO_RETURN_CODE.EOF);
         }
         else
         {
             throw new InvalidOperationException("Not in progress.");
         }
     }
     // In progress?  Must NOT for Get, MUST for Next.
     if (firstGet)
     {
         if (_RememberedDevicesResultIndex != null)
         {
             throw new InvalidOperationException("In progress.");
         }
         _RememberedDevicesResultIndex = 0;
     }
     else
     {
         if (_RememberedDevicesResultIndex == null)
         {
             return(REM_DEV_INFO_RETURN_CODE.ERROR);
         }
     }
     // At end?
     if (_RememberedDevicesResultIndex.Value > _RememberedDevices.Length)
     {
         throw new InvalidOperationException("Test infrastructure error -- out of range somehow.");
     }
     if (_RememberedDevicesResultIndex.Value == _RememberedDevices.Length)
     {
         _RememberedDevicesResultIndex = null;
         return(REM_DEV_INFO_RETURN_CODE.EOF);
     }
     Debug.Assert(_RememberedDevicesResultIndex.Value < _RememberedDevices.Length);
     // Success
     remDevInfo = _RememberedDevices[(int)_RememberedDevicesResultIndex++];
     return(REM_DEV_INFO_RETURN_CODE.SUCCESS);
 }
 public REM_DEV_INFO_RETURN_CODE GetNextRemoteDeviceInfo(ref REM_DEV_INFO remDevInfo, IntPtr p_rem_dev_info, int cb)
 {
     //throw new NotImplementedException();
     return(ReturnRememberedDevice(ref remDevInfo, false));
 }
 public REM_DEV_INFO_RETURN_CODE GetRemoteDeviceInfo(ref REM_DEV_INFO remDevInfo, IntPtr p_rem_dev_info, int cb)
 {
     //return REM_DEV_INFO_RETURN_CODE.EOF;
     return(ReturnRememberedDevice(ref remDevInfo, true));
 }