Advertisement
Guest User

Untitled

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