Advertisement
Guest User

Untitled

a guest
Feb 5th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. /*
  2. * Send an ArtPollReply message
  3. */
  4. bool ArtNetNodeImpl::SendPollReply(const IPV4Address &destination) {
  5. artnet_packet packet;
  6. PopulatePacketHeader(&packet, ARTNET_REPLY);
  7. memset(&packet.data.reply, 0, sizeof(packet.data.reply));
  8.  
  9. m_interface.ip_address.Get(packet.data.reply.ip);
  10. packet.data.reply.port = HostToLittleEndian(ARTNET_PORT);
  11. packet.data.reply.net_address = m_net_address;
  12. packet.data.reply.subnet_address = m_input_ports[0].universe_address >> 4;
  13. packet.data.reply.oem = HostToNetwork(OEM_CODE);
  14. packet.data.reply.status1 = 0xd2; // normal indicators, rdm enabled
  15. packet.data.reply.esta_id = HostToLittleEndian(OPEN_LIGHTING_ESTA_CODE);
  16. strncpy(packet.data.reply.short_name,
  17. m_short_name.data(),
  18. ARTNET_SHORT_NAME_LENGTH);
  19. strncpy(packet.data.reply.long_name,
  20. m_long_name.data(),
  21. ARTNET_LONG_NAME_LENGTH);
  22.  
  23. std::stringstream str;
  24. str << "#0001 [" << m_unsolicited_replies << "] OLA";
  25. strncpy(packet.data.reply.node_report,
  26. str.str().data(),
  27. ARTNET_REPORT_LENGTH);
  28. packet.data.reply.number_ports[1] = ARTNET_MAX_PORTS;
  29. for (unsigned int i = 0; i < ARTNET_MAX_PORTS; i++) {
  30. packet.data.reply.port_types[i] = 0xc0; // input and output DMX
  31. packet.data.reply.good_input[i] = m_input_ports[i].enabled ? 0x0 : 0x8;
  32. packet.data.reply.sw_in[i] = m_input_ports[i].universe_address;
  33. packet.data.reply.good_output[i] = (
  34. (m_output_ports[i].enabled ? 0x80 : 0x00) |
  35. (m_output_ports[i].merge_mode == ARTNET_MERGE_LTP ? 0x2 : 0x0) |
  36. (m_output_ports[i].is_merging ? 0x8 : 0x0));
  37. packet.data.reply.sw_out[i] = m_output_ports[i].universe_address;
  38. }
  39. packet.data.reply.style = NODE_CODE;
  40. memcpy(packet.data.reply.mac,
  41. m_interface.hw_address,
  42. ola::network::MAC_LENGTH);
  43. m_interface.ip_address.Get(packet.data.reply.bind_ip);
  44. // maybe set status2 here if the web UI is enabled
  45. packet.data.reply.status2 = 0x08; // node supports 15 bit port addresses
  46. if (!SendPacket(packet, sizeof(packet.data.reply), destination)) {
  47. OLA_INFO << "Failed to send ArtPollReply";
  48. return false;
  49. }
  50. return true;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement