2022-06-09 16:41:55 -04:00
|
|
|
/*
|
|
|
|
device.cpp
|
|
|
|
|
|
|
|
Copyright (c) 2022 Kevin Matz (kevin.matz@gmail.com)
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "device.h"
|
|
|
|
|
|
|
|
namespace ARTNET {
|
|
|
|
|
2023-05-20 13:35:37 -04:00
|
|
|
/**
|
|
|
|
* @brief Device::Device
|
2023-05-21 12:41:39 -04:00
|
|
|
* @param style
|
2023-05-20 13:35:37 -04:00
|
|
|
*
|
|
|
|
* \note A ArtPollReply packet is required to be broadcast to the Directed Broadcast address by
|
|
|
|
* all Art-Net devices on power up. Since information in that packet requres a fully configured
|
|
|
|
* device, it must be specifically sent later.
|
|
|
|
*/
|
2023-05-21 12:41:39 -04:00
|
|
|
Device::Device(Style style)
|
|
|
|
: styleCode(style)
|
|
|
|
, diagnostic_reporting_threshold(DpCritial)
|
2023-05-21 13:58:16 -04:00
|
|
|
, device_status {.rdm_capable=true, .authority=AuthorityUnused}
|
2023-05-21 11:12:41 -04:00
|
|
|
, _shortName("OpenLCP Device")
|
|
|
|
, _longName("Generic OpenLCP Art-Net Device")
|
2023-05-21 13:46:35 -04:00
|
|
|
, _report_code(RcPowerOk)
|
|
|
|
, _poll_reply_count(0)
|
|
|
|
, _report_text("initialized")
|
2022-06-09 16:41:55 -04:00
|
|
|
{
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:40:10 -04:00
|
|
|
* @brief Device::receive
|
|
|
|
* @param buffer
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:40:10 -04:00
|
|
|
void Device::receive(ACN::PDU::Stream buffer)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:40:10 -04:00
|
|
|
auto packet = std::make_shared<Packet>();
|
|
|
|
packet->iStream(buffer);
|
2023-05-21 13:46:35 -04:00
|
|
|
if (buffer->fail() || buffer->bad())
|
|
|
|
{
|
|
|
|
_report_code = RcParseFail;
|
|
|
|
_report_text = "unable to read packet";
|
|
|
|
}
|
2023-05-20 14:15:12 -04:00
|
|
|
receive(packet);
|
2023-05-20 13:40:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::receive
|
|
|
|
* @param packet
|
|
|
|
*/
|
|
|
|
void Device::receive(std::shared_ptr<Packet> packet)
|
|
|
|
{
|
|
|
|
switch (packet->opcode()) {
|
|
|
|
case OpPoll:
|
|
|
|
rxArtPoll(std::static_pointer_cast<ArtPoll>(packet));
|
|
|
|
break;
|
2023-05-20 14:15:12 -04:00
|
|
|
case OpPollReply:
|
|
|
|
rxArtPollReply(std::static_pointer_cast<ArtPollReply>(packet));
|
|
|
|
break;
|
|
|
|
case OpDiagData:
|
|
|
|
rxArtDiagData(std::static_pointer_cast<ArtDiagData>(packet));
|
|
|
|
break;
|
|
|
|
case OpCommand:
|
|
|
|
rxArtCommand(std::static_pointer_cast<ArtCommand>(packet));
|
|
|
|
break;
|
|
|
|
case OpDmx:
|
|
|
|
rxArtDmx(std::static_pointer_cast<ArtDmx>(packet));
|
|
|
|
break;
|
|
|
|
case OpNzs:
|
|
|
|
rxArtNzs(std::static_pointer_cast<ArtNzs>(packet));
|
|
|
|
break;
|
|
|
|
case OpSync:
|
|
|
|
rxArtSync(std::static_pointer_cast<ArtSync>(packet));
|
|
|
|
break;
|
|
|
|
case OpAddress:
|
|
|
|
rxArtAddress(std::static_pointer_cast<ArtAddress>(packet));
|
|
|
|
break;
|
|
|
|
case OpInput:
|
|
|
|
rxArtInput(std::static_pointer_cast<ArtInput>(packet));
|
|
|
|
break;
|
|
|
|
case OpTodRequest:
|
|
|
|
rxArtTodRequest(std::static_pointer_cast<ArtTodRequest>(packet));
|
|
|
|
break;
|
|
|
|
case OpTodData:
|
|
|
|
rxArtTodData(std::static_pointer_cast<ArtTodData>(packet));
|
|
|
|
break;
|
|
|
|
case OpTodControl:
|
|
|
|
rxArtTodControl(std::static_pointer_cast<ArtTodControl>(packet));
|
|
|
|
break;
|
|
|
|
case OpRdm:
|
|
|
|
rxArtRdm(std::static_pointer_cast<ArtRdm>(packet));
|
|
|
|
break;
|
|
|
|
case OpRdmSub:
|
|
|
|
rxArtRdmSub(std::static_pointer_cast<ArtRdmSub>(packet));
|
|
|
|
break;
|
|
|
|
case OpFirmwareMaster:
|
|
|
|
rxArtFirmwareMaster(std::static_pointer_cast<ArtFirmwareMaster>(packet));
|
|
|
|
break;
|
|
|
|
case OpFirmwareReply:
|
|
|
|
rxArtFirmwareReply(std::static_pointer_cast<ArtFirmwareReply>(packet));
|
|
|
|
break;
|
|
|
|
case OpIpProg:
|
|
|
|
rxArtIpProg(std::static_pointer_cast<ArtIpProg>(packet));
|
|
|
|
break;
|
|
|
|
case OpIpProgReply:
|
|
|
|
rxArtIpProgReply(std::static_pointer_cast<ArtIpProgReply>(packet));
|
|
|
|
break;
|
|
|
|
case OpTimeCode:
|
|
|
|
rxArtTimeCode(std::static_pointer_cast<ArtTimeCode>(packet));
|
|
|
|
break;
|
|
|
|
case OpTrigger:
|
|
|
|
rxArtTrigger(std::static_pointer_cast<ArtTrigger>(packet));
|
|
|
|
break;
|
2023-05-20 13:40:10 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:39:03 -04:00
|
|
|
* @brief Device::setSender
|
|
|
|
* @param sender
|
|
|
|
* @return
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:39:03 -04:00
|
|
|
std::shared_ptr<void> Device::setSender(const std::function<void(std::shared_ptr<bufferstream>,
|
|
|
|
ipAddress)> sender)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:39:03 -04:00
|
|
|
// wrap the callback with a shared pointer
|
|
|
|
auto sp = std::make_shared<std::function<void(std::shared_ptr<bufferstream>,
|
|
|
|
ipAddress)>>(std::move(sender));
|
|
|
|
// store sender function (as a weak pointer)
|
|
|
|
_sender = sp;
|
|
|
|
// return token that caller must keep throughout it's scope
|
|
|
|
return sp;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:39:03 -04:00
|
|
|
* @brief Device::send
|
|
|
|
* @param packet
|
|
|
|
* @param address
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:39:03 -04:00
|
|
|
void Device::send(const std::shared_ptr<Packet> packet, const ipAddress &address) const
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:39:03 -04:00
|
|
|
auto buffer = std::vector<uint8_t>(packet->streamSize());
|
|
|
|
auto stream = std::make_shared<bufferstream>(buffer.data(), buffer.size());
|
|
|
|
packet->oStream(stream);
|
|
|
|
if (auto sp = _sender.lock()) // the owner is still holding the token
|
|
|
|
(*sp)(stream, address);
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-21 13:46:35 -04:00
|
|
|
/**
|
|
|
|
* @brief Device::setStatus
|
|
|
|
* @param status
|
|
|
|
* @param text
|
|
|
|
*/
|
|
|
|
void Device::setReport(const NodeReport status, const std::string &text)
|
|
|
|
{
|
|
|
|
_report_code = status;
|
|
|
|
_report_text = text.substr(Node_Report_Length-8-1); // less required chars and null terminator
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-15 11:42:27 -05:00
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtPoll
|
|
|
|
* @param packet
|
|
|
|
*/
|
|
|
|
void Device::rxArtPoll(std::shared_ptr<ArtPoll> packet)
|
|
|
|
{
|
|
|
|
auto data_opt = packet->data<poll_data>();
|
|
|
|
if (!data_opt.has_value())
|
|
|
|
return;
|
|
|
|
auto data = data_opt.value();
|
2023-05-20 14:55:31 -04:00
|
|
|
|
|
|
|
/// \bug The specification details resolution of diagostice behavior from multiple simultanious
|
|
|
|
/// controllers. However, the spec does not provide a mechanism for differentiating between
|
|
|
|
/// controllers. Until OSI layer 3 data is available, LTP the reporting settings.
|
2023-05-20 13:34:46 -04:00
|
|
|
diagnostic_reporting_behavior = data->talk_to_me;
|
|
|
|
diagnostic_reporting_threshold = data->diagnostic_level;
|
|
|
|
|
|
|
|
/// All device types send an ArtPollReply in response to receiving an ArtPoll.
|
|
|
|
txArtPollReply();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::rxArtPollReply
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtPollReply(std::shared_ptr<ArtPollReply> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtDiagData
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtDiagData(std::shared_ptr<ArtDiagData> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::rxArtCommand
|
2023-05-20 13:34:46 -04:00
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtCommand(std::shared_ptr<ArtCommand> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtDmx
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtDmx(std::shared_ptr<ArtDmx> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtNzs
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtNzs(std::shared_ptr<ArtNzs> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
if (packet->isVLC())
|
|
|
|
rxArtVlc(packet);
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtVlc
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtVlc(std::shared_ptr<ArtNzs> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
auto data_opt = packet->data<nzs_data>();
|
|
|
|
if (!data_opt.has_value())
|
|
|
|
return;
|
|
|
|
auto data = std::make_shared<vlc_data>(data_opt.value().get());
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtSync
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtSync(std::shared_ptr<ArtSync> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtAddress
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtAddress(std::shared_ptr<ArtAddress> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtInput
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtInput(std::shared_ptr<ArtInput> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtTodRequest
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtTodRequest(std::shared_ptr<ArtTodRequest> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtTodData
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtTodData(std::shared_ptr<ArtTodData> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtTodControl
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtTodControl(std::shared_ptr<ArtTodControl> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::rxArtRdm
|
2023-05-20 13:34:46 -04:00
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtRdm(std::shared_ptr<ArtRdm> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtRdmSub
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtRdmSub(std::shared_ptr<ArtRdmSub> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtFirmwareMaster
|
|
|
|
* @param packet
|
|
|
|
*/
|
|
|
|
void Device::rxArtFirmwareMaster(std::shared_ptr<ArtFirmwareMaster> packet)
|
|
|
|
{
|
|
|
|
(void)packet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::rxArtFirmwareReply
|
|
|
|
* @param packet
|
|
|
|
*/
|
|
|
|
void Device::rxArtFirmwareReply(std::shared_ptr<ArtFirmwareReply> packet)
|
|
|
|
{
|
|
|
|
(void)packet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::rxArtIpProg
|
|
|
|
* @param packet
|
|
|
|
*/
|
|
|
|
void Device::rxArtIpProg(std::shared_ptr<ArtIpProg> packet)
|
|
|
|
{
|
|
|
|
(void)packet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::rxArtIpProgReply
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtIpProgReply(std::shared_ptr<ArtIpProgReply> packet)
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
(void)packet;
|
2022-11-15 11:42:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-05-20 13:34:46 -04:00
|
|
|
* @brief Device::rxArtTimeCode
|
|
|
|
* @param packet
|
|
|
|
*/
|
|
|
|
void Device::rxArtTimeCode(std::shared_ptr<ArtTimeCode> packet)
|
|
|
|
{
|
|
|
|
(void)packet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::rxArtTrigger
|
|
|
|
* @param packet
|
2022-11-15 11:42:27 -05:00
|
|
|
*/
|
2023-05-20 13:34:46 -04:00
|
|
|
void Device::rxArtTrigger(std::shared_ptr<ArtTrigger> packet)
|
|
|
|
{
|
|
|
|
(void)packet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::txArtPollReply
|
2023-05-21 14:05:19 -04:00
|
|
|
* @param reply
|
2023-05-20 13:34:46 -04:00
|
|
|
*/
|
2023-05-21 14:05:19 -04:00
|
|
|
void Device::txArtPollReply(std::shared_ptr<pollreply_data> reply)
|
2023-05-20 13:34:46 -04:00
|
|
|
{
|
2023-05-21 14:05:19 -04:00
|
|
|
if (!reply)
|
|
|
|
reply = std::make_shared<pollreply_data>();
|
|
|
|
|
2023-05-21 12:48:42 -04:00
|
|
|
/// \todo complete data field population of ArtPollReply
|
2023-05-21 14:18:24 -04:00
|
|
|
reply->my_ip = deviceIp().address.ipv4.value;
|
2023-05-21 14:18:47 -04:00
|
|
|
reply->fw_version = LIB_VERSION >> 16; // only able to send 16 bits, use the highest
|
2023-05-21 12:48:42 -04:00
|
|
|
// reply->net_sub_switch = ;
|
2023-05-21 13:58:16 -04:00
|
|
|
reply->status = device_status;
|
2023-05-21 12:48:42 -04:00
|
|
|
reply->short_name = _shortName;
|
|
|
|
reply->long_name = _longName;
|
2023-05-21 13:46:35 -04:00
|
|
|
reply->set_report(_report_code, _poll_reply_count, _report_text);
|
2023-05-21 12:48:42 -04:00
|
|
|
// reply->num_ports = ;
|
|
|
|
// reply->port_types = ;
|
|
|
|
// reply->good_input = ;
|
|
|
|
// reply->good_output = ;
|
|
|
|
// reply->SwIn = ;
|
|
|
|
// reply->SwOut = ;
|
|
|
|
// reply->SwMacro = ;
|
|
|
|
// reply->SwRemote = ;
|
|
|
|
reply->style = styleCode;
|
|
|
|
const auto mac = deviceMac();
|
|
|
|
std::copy(mac.cbegin(), mac.cend(), reply->mac_address);
|
2023-05-21 14:18:24 -04:00
|
|
|
// reply->bind_ip = reply->my_ip;
|
2023-05-21 12:48:42 -04:00
|
|
|
// reply->bind_index = ;
|
|
|
|
|
|
|
|
auto packet = std::make_shared<ArtPollReply>(reply);
|
2023-05-20 14:39:50 -04:00
|
|
|
send(packet, broadcastIp());
|
2023-05-21 13:46:35 -04:00
|
|
|
|
|
|
|
// reset report components
|
|
|
|
_report_code = RcPowerOk;
|
|
|
|
_poll_reply_count++;
|
|
|
|
_report_text = "nominal";
|
2023-05-20 13:34:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::txArtDiagData
|
|
|
|
*/
|
|
|
|
void Device::txArtDiagData()
|
2022-11-15 11:42:27 -05:00
|
|
|
{
|
2023-05-20 13:34:46 -04:00
|
|
|
/// \todo impliment txArtDiagData
|
2022-06-09 16:41:55 -04:00
|
|
|
}
|
|
|
|
|
2023-05-21 11:12:41 -04:00
|
|
|
|
2023-05-21 12:48:16 -04:00
|
|
|
/**
|
|
|
|
* @brief Device::deviceMac
|
|
|
|
* @return
|
|
|
|
*
|
|
|
|
* The default implimentation is to return an invalid MAC
|
|
|
|
* \note Platform aware device types should return a valid MAC address.
|
|
|
|
*/
|
|
|
|
std::array<uint8_t, 6> Device::deviceMac() const
|
|
|
|
{
|
|
|
|
return std::array<uint8_t, 6>({0});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-21 12:47:47 -04:00
|
|
|
/**
|
|
|
|
* @brief Device::deviceIp
|
|
|
|
* @return
|
|
|
|
*
|
|
|
|
* The default implimentation is to return an invalid IP.
|
|
|
|
* \note Platform aware device types must return a valid IP address.
|
|
|
|
*/
|
|
|
|
ipAddress Device::deviceIp() const
|
|
|
|
{
|
|
|
|
ipAddress addr;
|
|
|
|
addr.type = 1; // ACN::SDT::SDT_ADDR_IPV4
|
|
|
|
addr.port = UDP_PORT;
|
|
|
|
addr.address.ipv4.value = 0;
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::broadcastIp
|
|
|
|
* @return
|
|
|
|
*
|
|
|
|
* The default implimentation is to return the limited broadcast address.
|
|
|
|
* \note Platform aware device types must return their directed broadcast address.
|
|
|
|
*/
|
|
|
|
ipAddress Device::broadcastIp() const
|
|
|
|
{
|
|
|
|
ipAddress addr;
|
|
|
|
addr.type = 1; // ACN::SDT::SDT_ADDR_IPV4
|
|
|
|
addr.port = UDP_PORT;
|
|
|
|
addr.address.ipv4.value = 0xFFFFFFFF;
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-21 11:12:41 -04:00
|
|
|
/**
|
|
|
|
* @brief Device::shortName
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
std::string Device::shortName() const
|
|
|
|
{
|
|
|
|
return _shortName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::setShortName
|
|
|
|
* @param newShortName
|
|
|
|
*/
|
|
|
|
void Device::setShortName(const std::string &newShortName)
|
|
|
|
{
|
|
|
|
_shortName = newShortName.substr(0, Short_Name_Length-1); // leave room for null terminator
|
2023-05-21 13:46:35 -04:00
|
|
|
_report_code = RcShNameOk;
|
|
|
|
if (newShortName.length() == _shortName.length())
|
|
|
|
_report_text = "short name accepted";
|
|
|
|
else
|
|
|
|
_report_text = "short name truncated";
|
2023-05-21 11:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::longName
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
std::string Device::longName() const
|
|
|
|
{
|
|
|
|
return _longName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device::setLongName
|
|
|
|
* @param newLongName
|
|
|
|
*/
|
|
|
|
void Device::setLongName(const std::string &newLongName)
|
|
|
|
{
|
|
|
|
_longName = newLongName.substr(0, Long_Name_Length-1); // leave room for null terminator
|
2023-05-21 13:46:35 -04:00
|
|
|
_report_code = RcLoNameOk;
|
|
|
|
if (newLongName.length() == _longName.length())
|
|
|
|
_report_text = "long name accepted";
|
|
|
|
else
|
|
|
|
_report_text = "long name truncated";
|
2023-05-21 11:12:41 -04:00
|
|
|
}
|
|
|
|
|
2022-06-09 16:41:55 -04:00
|
|
|
} // namespace ARTNET
|