Beispiel #1
0
        private static SDBConnection EstablishConnection(string serialNumber)
        {
            SDBConnection sdbConnection = SDBConnection.Create();

            if (sdbConnection == null)
            {
                Debug.WriteLine("Failed to establish SDB connection.");
                return(null);
            }

            string      msgForConnection = "host:transport:" + serialNumber;
            SDBRequest  request          = SDBConnection.MakeRequest(msgForConnection);
            SDBResponse response         = sdbConnection.Send(request);

            if (response.IOSuccess && response.Okay)
            {
                return(sdbConnection);
            }
            else
            {
                Debug.WriteLine($"Failed to get SDB response. {response.Message}");
                sdbConnection.Close();
                return(null);
            }
        }
Beispiel #2
0
        private static bool SendMsg(SDBConnection sdbConnection, string protocol, string cmd, string[] args)
        {
            string msg = protocol + SDBProtocol.delemeter + cmd;

            foreach (string arg in args)
            {
                msg += (SDBProtocol.delemeter + arg);
            }

            SDBRequest  request  = SDBConnection.MakeRequest(msg);
            SDBResponse response = sdbConnection.Send(request);

            if (!response.IOSuccess || !response.Okay)
            {
                Debug.WriteLine($"Failed to get SDB response. {response.Message}");
                sdbConnection.Close();
                return(false);
            }

            return(true);
        }