public void checkReceiveMessage(byte[] udpPayload) { SomeIPMessage temp = new SomeIPMessage(udpPayload); Log.MessageSent("RECEIVING..."); Log.MessageSent("MessageID: " + temp.MessageID.ToString()); Log.MessageSent("RequestID: " + temp.RequestID.ToString()); Log.MessageSent("Lenght: " + temp.GetLength.ToString()); if (temp.MessageID == Convert.ToUInt32(SomeIPMessage.SOMEIP_MessageID.PICTURE)) { ImageConverter converter = new ImageConverter(); pictureBox1.Image = (Image)converter.ConvertFrom(temp.Payload); Log.MessageSent("---PICTURE---"); PlayBtn.Enabled = false; textBox1.Text = null; pictureBox1.Refresh(); } else if (temp.MessageID == Convert.ToUInt32(SomeIPMessage.SOMEIP_MessageID.TEXT)) { Log.MessageSent("---TEXT---"); textBox1.Text = System.Text.Encoding.Default.GetString(temp.Payload); PlayBtn.Enabled = false; pictureBox1.Image = null; } else if (temp.MessageID == Convert.ToUInt32(SomeIPMessage.SOMEIP_MessageID.SOUND)) { Log.MessageSent("---SOUND---"); File.WriteAllBytes(@"C:\Temp\WriteSound\Temp.wav", temp.Payload); textBox1.Text = @"C:\Temp\WriteSound\Temp.wav"; PlayBtn.Enabled = true; pictureBox1.Image = null; } else { SomeIPServiceDiscoveryMessage SDtemp = new SomeIPServiceDiscoveryMessage(udpPayload); uint a = SDtemp.GetLength - 3; //pomaknuti računanje payloada ili oduzeti sve sa options da znamo koliko ima. moze i tako pa pomaknuti //kod uzimanja entrya } WriteLog(); }
private void btn_Publish_Click(object sender, EventArgs e) { SomeIPServiceDiscoveryMessage ServiceDiscovery; SomeIPServiceDiscoveryMessage.ServiceDiscoveryEntry Entry = new SomeIPServiceDiscoveryMessage.ServiceDiscoveryEntry(); byte[] OptionsArray = new byte[16] { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF }; byte[] ReservedHeader = new byte[3] { 0x00, 0x00, 0x00 }; //ostavlja se u 0 byte[] EntryArray = new byte[] { 0x01, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x14, 0xFF, 0xFF, 0xFF, 0xFF }; // , 0x00, 0x11, 0x00, 0x11 }; //Convert.ToByte(0x00110011) }; //0x14 je TTL u hex = dekadski 20 sec ServiceDiscovery = new SomeIPServiceDiscoveryMessage(0xFFFF8100, 0, Convert.ToByte(SomeIPMessage.SOMEIP_MessageType.NOTIFICATION), Convert.ToByte(SomeIPMessage.SOMEIP_ReturnCode.E_OK), 1, ReservedHeader, EntryArray, OptionsArray); ServiceDiscovery.Payload = ReservedHeader.Concat(EntryArray).Concat(OptionsArray).ToArray(); Client.Send(ServiceDiscovery.FullMessagePayload); }