Пример #1
0
        public void SendData(string param, string value, string url)
        {
            if (!wifi_RS21.Interface.IsLinkConnected)
                return;
            //Create parameters and get the string body
            Param[] parameters = new Param[1];
            parameters[0] = new Param(param, value);
            string postData = this.GetPostData(parameters);

            //Get the byte[]
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            byte[][] buffers = new byte[1][];
            buffers[0] = encoding.GetBytes(postData);

            SendHttp(buffers, url);
        }
Пример #2
0
        public void SendGasData(double value)
        {
            if (!wifi_RS21.Interface.IsLinkConnected)
                return;
            //Create parameters and get the string body
            Param[] parameters = new Param[2];
            parameters[0] = new Param("gas", value.ToString());
            parameters[1] = new Param("device", GetMACAddress(wifi_RS21.NetworkSettings.PhysicalAddress));
            string postData = this.GetPostData(parameters);

            //Get the byte[]
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            byte[][] buffers = new byte[1][];
            buffers[0] = encoding.GetBytes(postData);

            SendHttp(buffers, "sendGas");
        }
Пример #3
0
 private string GetPostData(Param[] parameters)
 {
     string requestBody = "";
     foreach (Param param in parameters)
     {
         requestBody += param.Key + "=";
         if (param.Value != string.Empty)
         {
             requestBody += param.Value + ";";
         }
     }
     return requestBody;
 }
Пример #4
0
        public void SendPictureData(byte[] picture, string type)
        {
            if (!wifi_RS21.Interface.IsLinkConnected)
                return;

            //Create parameters and get the string body
            Param[] parameters = new Param[4];
            parameters[0] = new Param("filename", Guid.NewGuid() + ".bmp");
            parameters[1] = new Param("type", type);
            parameters[2] = new Param("device", GetMACAddress(wifi_RS21.NetworkSettings.PhysicalAddress));
            parameters[3] = new Param("file");
            string postData = this.GetPostData(parameters);

            //Get the byte[]
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            byte[][] buffers = new byte[2][];
            buffers[0] = encoding.GetBytes(postData);
            buffers[1] = picture;

            SendHttp(buffers, "uploadFile");
        }