/// <summary> /// Send a value and a context to Ubidots API and save it. /// </summary> /// <param name="Value">The value to be saved</param> /// <param name="Context">The context to be saved</param> public IEnumerator SaveValue(int Value, ServerBridge.contextData Context, System.Action <Value> values) { var outputMessage = ""; ServerBridge.JsonData Data = new ServerBridge.JsonData() { value = Value, timestamp = GetTimestamp(), context = Context }; //Dictionary<string, object> Data = new Dictionary<string, object>(); //Data.Add("value", Value); //Data.Add("context", Context); //Data.Add("timestamp", GetTimestamp()); string Json = JsonUtility.ToJson(Data); yield return(Extender.Instance.StartCoroutine(Bridge.Post("variables/" + GetId() + "/values", Json, result => outputMessage = result))); ServerBridge.JsonData RawValues = JsonUtility.FromJson <ServerBridge.JsonData>(outputMessage); Value Values = new Value(new ServerBridge.JsonData() { value = RawValues.value, timestamp = RawValues.timestamp, created_at = RawValues.created_at }, Api); values(Values); }
/// <summary> /// Send a value and a context to Ubidots API and save it. /// </summary> /// <param name="Value">The value to be saved</param> /// <param name="Context">The context to be saved</param> public IEnumerator SaveValue(double Value, ServerBridge.contextData Context, System.Action <Value> values) { yield return(Extender.Instance.StartCoroutine(SaveValue((int)Value, Context, values))); }