示例#1
0
        //----
        tBT_CONN_STATS GetConnectionStats()
        {
            tBT_CONN_STATS         stats = new tBT_CONN_STATS();
            SPP_CLIENT_RETURN_CODE ret   = _singleThreader.AddCommand(
                new WidcommPortSingleThreader.MiscReturnCommand <SPP_CLIENT_RETURN_CODE>(
                    () => NativeMethods.SppClient_GetConnectionStats(_pSppCli,
                                                                     out stats, Marshal.SizeOf(stats))
                    )).WaitCompletion();

            if (ret != SPP_CLIENT_RETURN_CODE.SUCCESS)
            {
                throw WidcommSppSocketExceptions.Create(ret, "GetConnectionStats");
            }
            return(stats);
        }
示例#2
0
        public int GetRssi(byte[] bd_addr)
        {
            Debug.Assert(bd_addr.Length == WidcommStructs.BD_ADDR_LEN, "bd_addr.Length: " + bd_addr.Length);
            tBT_CONN_STATS stats   = new tBT_CONN_STATS();
            bool           success = NativeMethods.BtIf_GetConnectionStats(m_pBtIf, bd_addr,
                                                                           out stats, Marshal.SizeOf(stats));

            if (!success)
            {
                // Occurs mostly.  Apparently a connection must exist for Rssi to
                // be read, both from observation and from the Widcomm docs:
                //   "TRUE, if a connection attempt has been initiated; FALSE, if
                //    a connection attempt has not been initiated"
                return(int.MinValue);
            }
            else
            {
                return(stats.rssi);
            }
        }
示例#3
0
 internal static extern SPP_CLIENT_RETURN_CODE SppClient_GetConnectionStats(
     IntPtr pObj, out tBT_CONN_STATS pStats, int cb);
示例#4
0
 internal static extern bool BtIf_GetConnectionStats(IntPtr pObj,
                                                     byte[] bdAddr, out tBT_CONN_STATS pStats, int cb);