/// <summary> /// Command TLPT that sends a template with randomized data to the 4x4 chip, that will forward it to IoT Hub. /// The operation does not wait for an answer from the chip. /// </summary> /// <param name="templatePacket">TemplatePacket</param> /// <returns>true if the send operation succeeded</returns> public bool SendTemplateCommand(TemplatePacket templatePacket) { if (_UARTService == null) { return(false); } return(_UARTService.SendPacket(new SendTemplateCommand(templatePacket))); }
/// <summary> /// Returns a TemplatePacket based on a specific template /// </summary> /// <param name="templateModel">Template</param> /// <returns></returns> public static TemplatePacket GetTemplatePacketFromTemplate(Template templateModel) { TemplatePacket template = new TemplatePacket(); template.TemplateId = templateModel.Id; template.Properties = new Dictionary <string, dynamic>(); foreach (CustomProperty property in templateModel.Properties) { template.Properties.Add(property.Name, GetDynamicObjectFromCustomProperty(property)); } return(template); }
/// <summary> /// Callback of the Sending timer. Generate a new TemplatePacker and send it through UART /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Event_SendMessages(object sender, ElapsedEventArgs e) { if (!_SendingCosmosMessages) { _SendingCosmosMessages = true; TemplatePacket newPacket = TemplateInstanceHelper.GetTemplatePacketFromTemplate(_Template); newPacket.DemoId = _MessagesSent; newPacket.DemoInstanceId = _CurrentDemoInstanceId; LastTemplatePacketSent = newPacket; _FourByFourService.SendTemplateCommand(_LastTemplatePacketSent); SendFromMessage("Sending message '{0}' to the chip.", _MessagesSent); MessagesSent++; if (_MessagesSent == 100) { _TimerSending.Stop(); } _SendingCosmosMessages = false; } }
public SendTemplateCommand(TemplatePacket templatePacket) { _TemplatePacket = templatePacket; }