Beispiel #1
0
        private void setTemprature()
        {
            intentFilter  = new IntentFilter(Intent.ActionBatteryChanged);
            batteryIntent = RegisterReceiver(null, intentFilter);
            var rval = batteryIntent.GetIntExtra(BatteryManager.ExtraTemperature, -1);
            var temp = (rval * .1 - 1);

            iOTMesage = new IOTMesage()
            {
                DeviceId = deviceID, Type = MessageType.Temperature.ToString(), Value = temp
            };
            publishMessage(getJsonSrting(iOTMesage));
        }
Beispiel #2
0
        private void client_MqttMsgPublishReceived(MqttApplicationMessage e)
        {
            txtDeviceId.Text = "Device Id : " + deviceID;
            string    result    = System.Text.Encoding.UTF8.GetString(e.Payload);
            IOTMesage IOTMesage = getObject <IOTMesage>(result);

            RunOnUiThread(() =>
            {
                txtUpdatedTime.Text = "Last reading taken on : " + DateTime.Now.ToLongTimeString();
                if (IOTMesage.DeviceId == deviceID)
                {
                    if (IOTMesage.Type == MessageType.Temperature.ToString())
                    {
                        txtTemp.Text = result;
                    }
                    else if (IOTMesage.Type == MessageType.Location.ToString())
                    {
                        txtLocation.Text = result;
                    }
                }
            });
        }