private static void DoRpcCall() { TBRpcRequest rpcRequest = new TBRpcRequest("getTime"); var asdsdaa = rpcRequest.ToJson(); thingsBoard.SendRPCRequest(rpcRequest); }
public static void GetValue(TBRpcRequest rpcRequest) { TBRpcResponse rpcResponse = new TBRpcResponse(rpcRequest.RpcRequestId); rpcResponse.Add(someDeviceValue); thingsBoard.SendRPCReply(rpcResponse); }
public static void GetGpioStatus(TBRpcRequest rpcRequest) { TBRpcResponse rpcResponse = new TBRpcResponse(rpcRequest.RpcRequestId); rpcResponse.Add(pins); thingsBoard.SendRPCReply(rpcResponse); Debug.WriteLine("Get Gpio Status: " + rpcResponse.ToJson()); }
public static void GetValue(TBRpcRequest rpcRequest) { Console.WriteLine("Get Value: " + someDeviceValue); TBRpcResponse rpcResponse = new TBRpcResponse(rpcRequest.RpcRequestId); rpcResponse.Add(someDeviceValue); thingsBoard.SendRPCReply(rpcResponse); }
public static void InvokeRpcMethod(TBRpcRequest rpcRequest) { string ssss = rpcRequest.RpcMethod; string rpcMethod = (string)calledMethods[(object)rpcRequest.RpcMethod]; if (rpcMethod != null) { calledType.GetMethod(rpcMethod).Invoke(null, new object[] { rpcRequest }); } }
void Client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) { string topic = e.Topic; string message = Encoding.UTF8.GetString(e.Message, 0, e.Message.Length); string[] splitTopic = topic.Split('/'); int rpcActionId = int.Parse(splitTopic[splitTopic.Length - 1]); Hashtable deserializedObject = JsonSerializer.DeserializeString(message) as Hashtable; if (topic.StartsWith(RPC_REQUEST_TOPIC)) { TBRpcRequest rpcRequest = new TBRpcRequest((string)deserializedObject["method"], deserializedObject["params"], rpcActionId); if (OnRpcRequestTopic != null) { OnRpcRequestTopic(this, new RpcEventArgs(rpcRequest)); } } else if (topic.StartsWith(RPC_RESPONSE_TOPIC)) { string error = (string)deserializedObject["error"]; if (error != null) { RpcError rpcError = new RpcError(error, rpcActionId); if (OnRpcError != null) { OnRpcError(this, new RpcEventArgs(rpcError)); } } else if (OnRpcResponseTopic != null) { TBRpcResponse rpcResponse = new TBRpcResponse(rpcActionId); OnRpcResponseTopic(this, new RpcEventArgs(rpcResponse)); } } else if (topic == ATTRIBUTES_TOPIC) { } else if (topic.StartsWith(ATTRIBUTES_TOPIC_RESPONSE)) { TBAttributesResponse tBAttributesResponse = new TBAttributesResponse(deserializedObject["client"], deserializedObject["shared"], rpcActionId); if (OnAttributesResponseTopic != null) { OnAttributesResponseTopic(this, new RpcEventArgs(tBAttributesResponse)); } } }
public static void SetGpioStatus(TBRpcRequest rpcRequest) { var pin = (Int64)(rpcRequest.RpcParams as Hashtable)["pin"]; var enabled = (Boolean)(rpcRequest.RpcParams as Hashtable)["enabled"]; pins[pin] = enabled; Debug.WriteLine("Set Gpio Pin:" + pin + " Value:" + enabled); TBRpcResponse rpcResponse = new TBRpcResponse(rpcRequest.RpcRequestId); rpcResponse.Add(pin, pins[pin]); thingsBoard.SendRPCReply(rpcResponse); }
public static void SetValue(TBRpcRequest rpcRequest) { someDeviceValue = (double)rpcRequest.RpcParams; Debug.WriteLine("Set Value: " + someDeviceValue); }
public static void SetValue(TBRpcRequest rpcRequest) { someDeviceValue = (double)rpcRequest.RpcParams; }
public RpcEventArgs(TBRpcRequest RpcRequest) { this.RpcRequest = RpcRequest; }
public void SendRPCRequest(TBRpcRequest rpcRequest) { tbRequestId++; rpcRequest.RpcRequestId = tbRequestId; client.Publish(RPC_REQUEST_TOPIC + tbRequestId, Encoding.UTF8.GetBytes(rpcRequest.ToJson()), QoS, false); }