protected SendCommand BuildCommandForMqttMessage(MqttMsgPublishEventArgs mqttEventArgs) { var topicMessageCommand = new SendCommandMeasurable((int)Commands.TopicMessage); topicMessageCommand.AddArgument(mqttEventArgs.Topic); topicMessageCommand.AddArgument(Encoding.GetString(mqttEventArgs.Message)); if (IsCommandTooBig(topicMessageCommand)) { throw new InvalidOperationException("Command too big"); } return(topicMessageCommand); }
/// <summary> /// This is unfortunate, but it looks like the arduino C++ lib /// limits the size of commands. /// </summary> private bool IsCommandTooBig(SendCommandMeasurable command) { return(command.CommandStringLength >= 64); }