diff --git a/protocol/enttec/dmx-usb-pro/widget.cpp b/protocol/enttec/dmx-usb-pro/widget.cpp index d069765..1c01c2e 100644 --- a/protocol/enttec/dmx-usb-pro/widget.cpp +++ b/protocol/enttec/dmx-usb-pro/widget.cpp @@ -33,7 +33,7 @@ Widget::Widget() , tx_break_intervals(17) // 181.4 us by default , tx_mab_intervals(10) // 106.7 us by default , tx_rate(40) // 40 packets/s, by default - , usb_mode_(USBunknown) + , usb_mode(USBunknown) , rx_update_mode_(Pro::RxNotifyAlways) , token_data_changed_(nullptr) { @@ -42,7 +42,7 @@ Widget::Widget() Widget::~Widget() { - switch (usb_mode_) { + switch (usb_mode) { case USBdevice: Widget::halt(); break; @@ -64,7 +64,7 @@ void Widget::init() { { std::scoped_lock lock(mtx_metadata_); - usb_mode_ = USBdevice; + usb_mode = USBdevice; } setModeBridge(); } @@ -78,7 +78,7 @@ void Widget::init() void Widget::halt() { std::scoped_lock lock(mtx_metadata_); - usb_mode_ = USBunknown; + usb_mode = USBunknown; } @@ -93,7 +93,7 @@ void Widget::open() { { std::scoped_lock lock(mtx_metadata_); - usb_mode_ = USBhost; // note connected state + usb_mode = USBhost; // note connected state } setModeBridge(); getParameters(0, 500); // retrieve widget metadata @@ -109,7 +109,7 @@ void Widget::open() void Widget::close() { std::scoped_lock lock(mtx_metadata_); - usb_mode_ = USBunknown; + usb_mode = USBunknown; } @@ -309,7 +309,7 @@ void Widget::routeRxMessage(std::shared_ptr msg) break; case Pro::OpProgramFlashPage: { - switch (usb_mode_) { + switch (usb_mode) { case USBdevice: { auto data = std::static_pointer_cast(msg); @@ -329,7 +329,7 @@ void Widget::routeRxMessage(std::shared_ptr msg) break; case Pro::OpGetWidgetParameters: { - switch (usb_mode_) { + switch (usb_mode) { case USBdevice: { auto data = std::static_pointer_cast(msg); @@ -385,7 +385,7 @@ void Widget::routeRxMessage(std::shared_ptr msg) break; case Pro::OpGetWidgetSerial: { - switch (usb_mode_) { + switch (usb_mode) { case USBdevice: { auto data = std::static_pointer_cast(msg); @@ -434,7 +434,7 @@ void Widget::sendMessage(std::shared_ptr msg) const */ void Widget::rebootBootloader() { - switch (usb_mode_) { + switch (usb_mode) { case USBhost: { auto msg = std::make_shared(); @@ -547,7 +547,7 @@ void Widget::sendDmx(bool trimmed) const */ void Widget::rxMsgHello(std::shared_ptr msg) { - switch (usb_mode_) { + switch (usb_mode) { case USBdevice: sendMessage(msg); // mirror the message back to the host break; diff --git a/protocol/enttec/dmx-usb-pro/widget.h b/protocol/enttec/dmx-usb-pro/widget.h index 0a04ce9..11b5dc8 100644 --- a/protocol/enttec/dmx-usb-pro/widget.h +++ b/protocol/enttec/dmx-usb-pro/widget.h @@ -53,7 +53,7 @@ public: * @brief isConnected * @return */ - bool isConnected() const { return usb_mode_ != USBunknown; } + bool isConnected() const { return usb_mode != USBunknown; } virtual void setModeController(); virtual void setModeBridge(Pro::DMX_RX_MODE = Pro::RxNotifyAlways); @@ -74,6 +74,13 @@ public: bool writeFirmware(const uint8_t *, const size_t); + /// @brief The OperatingMode enum + enum OperatingMode { + USBunknown, + USBhost, + USBdevice + }; + protected: void routeRxMessage(std::shared_ptr); @@ -99,6 +106,7 @@ protected: uint8_t tx_mab_intervals; //!< DMX_MAB_INTERVAL count of the DMX MARK AFTER BREAK uint8_t tx_rate; //!< DMX packet transmit Rate std::vector user_configuration; //!< User defined configuration data. + OperatingMode usb_mode; //!< The side of the USB the widget is acting on. private: void rxMsgHello(std::shared_ptr); @@ -117,11 +125,6 @@ private: void rxMsgGetWidgetSerialReply(std::shared_ptr); void rxMsgSendRDMDiscovery(std::shared_ptr); - enum OperatingModes { - USBunknown, - USBhost, - USBdevice - } usb_mode_; Pro::DMX_RX_MODE rx_update_mode_; mutable std::mutex mtx_metadata_;