private void SendSensorPresentation(Sensor sensor) { if (!IsConnected()) return; Message message = new Message { nodeId = node.nodeId, sensorId = sensor.sensorId, messageType = MessageType.C_PRESENTATION, ack = false, subType = (int)sensor.type, payload = sensor.description }; if (OnDebugNodeStateMessage != null) OnDebugNodeStateMessage("Sending sensor "+sensor.sensorId+" presentation"); if (OnDebugTxRxMessage != null) OnDebugTxRxMessage(message.ToString()); client.SendMessage(message); }
private void SendNodePresentation() { if (!IsConnected()) return; Message message = new Message { nodeId = node.nodeId, sensorId = 255, messageType = MessageType.C_PRESENTATION, ack = false, subType = (int)SensorType.S_ARDUINO_NODE, //payload = dateTime = DateTime.Now }; if (OnDebugNodeStateMessage != null) OnDebugNodeStateMessage("Sending node presentation"); if (OnDebugTxRxMessage != null) OnDebugTxRxMessage(message.ToString()); client.SendMessage(message); }
private void SendNodeVersion() { if (!IsConnected()) return; Message message = new Message { nodeId = node.nodeId, sensorId = 255, messageType = MessageType.C_INTERNAL, ack = false, subType = (int)InternalDataType.I_SKETCH_VERSION, payload = node.version, }; if (OnDebugNodeStateMessage != null) OnDebugNodeStateMessage("Sending node version"); if (OnDebugTxRxMessage != null) OnDebugTxRxMessage(message.ToString()); client.SendMessage(message); }
private void SendIdRequest() { Message message = new Message { nodeId = 255, sensorId = 255, messageType = MessageType.C_INTERNAL, ack = false, subType = (int)InternalDataType.I_ID_REQUEST }; if (OnDebugNodeStateMessage != null) OnDebugNodeStateMessage("Sending ID request"); if (OnDebugTxRxMessage != null) OnDebugTxRxMessage(message.ToString()); client.SendMessage(message); }
private void OnClientReceivedMessage(Message message) { if (message.nodeId == node.nodeId) { if (OnDebugTxRxMessage != null) OnDebugTxRxMessage(message.ToString()); //if ID_RESPONSE if (message.messageType == MessageType.C_INTERNAL && message.subType == (int)InternalDataType.I_ID_RESPONSE) { node.nodeId = Int32.Parse(message.payload); if (OnDebugNodeStateMessage != null) OnDebugNodeStateMessage("Received new ID: "+ node.nodeId); if (OnIdResponseReceived != null) OnIdResponseReceived(node.nodeId); SendPresentation(); } if (OnReceivedMessage != null) OnReceivedMessage(message); } }
public void SendSensorData(int sensorId, SensorData data) { if (!IsConnected() || !IsPresentationCompleted()) return; Message message = new Message { nodeId = node.nodeId, sensorId = sensorId, messageType = MessageType.C_SET, ack = false, subType = (int)data.dataType, payload = data.state }; if (OnDebugTxRxMessage != null) OnDebugTxRxMessage(message.ToString()); client.SendMessage(message); }
public void SendMessage(Message message) { message.incoming = false; if (OnMessageSendEvent != null) OnMessageSendEvent(message); DebugTxRx(String.Format("TX: {0}", message.ToString())); string mes = String.Format("{0};{1};{2};{3};{4};{5}\n", message.nodeId, message.sensorId, (int)message.messageType, (message.ack) ? "1" : "0", message.subType, message.payload); SendMessage(mes); if (storeMessages) messagesLog.AddNewMessage(message); }
public void OnMessageSendEvent(Message message) { Clients.Others.onMessageSendEvent(message.ToString()); }