Esempio n. 1
0
        /// <summary>
        /// Accept incomming TCP connection
        /// [UNTESTED]
        /// </summary>
        /// <param name="SocketNo">Socket Number (1-6)</param>
        /// <param name="CommandMode">True to return to IDLE state after connect</param>
        /// <returns>True on succes</returns>
        public bool SocketAccept(int SocketNo, bool CommandMode)
        {
            // Check if GPRS functions has been initialized
            if (!_gprs_initialized)
            {
                throw new GM862Exception(GM862Exception.WRONGARGUMENT);
            }

            // Used when executing commands
            string responseBody;

            // Select witch response code to expect
            AT_Interface.ResponseCodes expectedResponse = (CommandMode) ? AT_Interface.ResponseCodes.OK : AT_Interface.ResponseCodes.CONNECT;

            // Accept socket connection
            if (_device.ExecuteCommand(
                    "AT#SA=" + SocketNo.ToString() + "," + (CommandMode ? "1" : "0"),
                    out responseBody,
                    60000) != expectedResponse)
            {
                return(false);
            }

            // Succes
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Open connection trough TCP or UDP
        /// </summary>
        /// <param name="SocketNo">Socket Number (1-6)</param>
        /// <param name="Protocol">Protocol (UDP/TCP)</param>
        /// <param name="EndPointAddr">Endpoint address (IP or DNS)</param>
        /// <param name="EndPointPort">Endpoint Port</param>
        /// <param name="CloseOnDisconnect">Close On Disconect</param>
        /// <param name="OnlineMode">True to return to IDLE state after connect</param>
        /// <returns>True on succes</returns>
        public bool SocketDail(int SocketNo, SocketProtocols Protocol, string EndPointAddr, int EndPointPort, bool CloseOnDisconnect, bool CommandMode)
        {
            // Check if GPRS functions has been initialized
            if (!_gprs_initialized)
            {
                throw new GM862Exception(GM862Exception.WRONGARGUMENT);
            }

            // Used when executing commands
            string responseBody;

            // Select witch response code to expect
            AT_Interface.ResponseCodes expectedResponse = (CommandMode) ? AT_Interface.ResponseCodes.OK : AT_Interface.ResponseCodes.CONNECT;

            // Dail socket
            if (_device.ExecuteCommand(
                    "AT#SD=" + SocketNo.ToString() + "," + ((int)Protocol).ToString() + "," + EndPointPort.ToString() + ",\"" + EndPointAddr + "\"," + (CloseOnDisconnect ? "0" : "255") + "," + EndPointPort.ToString() + "," + (CommandMode ? "1" : "0"),
                    out responseBody,
                    60000) != expectedResponse)
            {
                return(false);
            }

            // Succes
            return(true);
        }