Initial E1.31 Unicast support, add ip parameter to E1.31 device to use Unicast mode
This commit is contained in:
parent
ca3c2ad541
commit
9bde1c282a
3 changed files with 66 additions and 25 deletions
|
|
@ -43,6 +43,7 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
|
|||
| Clear E1.31 device data |
|
||||
\*-------------------------------------------------*/
|
||||
dev.name = "";
|
||||
dev.ip = "";
|
||||
dev.type = ZONE_TYPE_SINGLE;
|
||||
dev.num_leds = 0;
|
||||
dev.rgb_order = E131_RGB_ORDER_RBG;
|
||||
|
|
@ -57,6 +58,11 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
|
|||
dev.name = e131_settings["devices"][device_idx]["name"];
|
||||
}
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("ip"))
|
||||
{
|
||||
dev.ip = e131_settings["devices"][device_idx]["ip"];
|
||||
}
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("num_leds"))
|
||||
{
|
||||
dev.num_leds = e131_settings["devices"][device_idx]["num_leds"];
|
||||
|
|
@ -188,40 +194,56 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
|
|||
\*---------------------------------------------------------*/
|
||||
bool device_added_to_existing_list = false;
|
||||
|
||||
for(unsigned int list_idx = 0; list_idx < device_lists.size(); list_idx++)
|
||||
/*---------------------------------------------------------*\
|
||||
| Only track grouping for multicast controllers. Unicast |
|
||||
| controllers are currently not grouped. |
|
||||
\*---------------------------------------------------------*/
|
||||
if(dev.ip == "")
|
||||
{
|
||||
for(unsigned int device_idx = 0; device_idx < device_lists[list_idx].size(); device_idx++)
|
||||
for(unsigned int list_idx = 0; list_idx < device_lists.size(); list_idx++)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Check if any universes used by this new device exist in |
|
||||
| the existing device. If so, add the new device to the |
|
||||
| existing list. |
|
||||
\*---------------------------------------------------------*/
|
||||
if(dev.start_universe == device_lists[list_idx][device_idx].start_universe)
|
||||
for(unsigned int device_idx = 0; device_idx < device_lists[list_idx].size(); device_idx++)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Check if any universes used by this new device exist in |
|
||||
| the existing device. If so, add the new device to the |
|
||||
| existing list. |
|
||||
\*---------------------------------------------------------*/
|
||||
if(dev.start_universe == device_lists[list_idx][device_idx].start_universe)
|
||||
{
|
||||
device_lists[list_idx].push_back(dev);
|
||||
device_added_to_existing_list = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(device_added_to_existing_list)
|
||||
{
|
||||
device_lists[list_idx].push_back(dev);
|
||||
device_added_to_existing_list = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(device_added_to_existing_list)
|
||||
/*---------------------------------------------------------*\
|
||||
| If the device did not overlap with existing devices, |
|
||||
| create a new list for it |
|
||||
\*---------------------------------------------------------*/
|
||||
if(!device_added_to_existing_list)
|
||||
{
|
||||
break;
|
||||
std::vector<E131Device> new_list;
|
||||
|
||||
new_list.push_back(dev);
|
||||
|
||||
device_lists.push_back(new_list);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If the device did not overlap with existing devices, |
|
||||
| create a new list for it |
|
||||
\*---------------------------------------------------------*/
|
||||
if(!device_added_to_existing_list)
|
||||
else
|
||||
{
|
||||
std::vector<E131Device> new_list;
|
||||
std::vector<E131Device> tmp_device_list;
|
||||
tmp_device_list.push_back(dev);
|
||||
|
||||
new_list.push_back(dev);
|
||||
|
||||
device_lists.push_back(new_list);
|
||||
RGBController_E131* rgb_controller;
|
||||
rgb_controller = new RGBController_E131(tmp_device_list);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ using namespace std::chrono_literals;
|
|||
|
||||
RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
|
||||
{
|
||||
bool multicast = false;
|
||||
|
||||
devices = device_list;
|
||||
|
||||
name = "E1.31 Device Group";
|
||||
|
|
@ -34,9 +36,17 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
|
|||
|
||||
/*-----------------------------------------*\
|
||||
| Append the destination address to the |
|
||||
| location field (multicast only for now) |
|
||||
| location field |
|
||||
\*-----------------------------------------*/
|
||||
location += "Multicast, ";
|
||||
if((devices.size() == 1) && (devices[0].ip != ""))
|
||||
{
|
||||
location += "Unicast " + devices[0].ip + ", ";
|
||||
}
|
||||
else
|
||||
{
|
||||
location += "Multicast, ";
|
||||
multicast = true;
|
||||
}
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Calculate universe list |
|
||||
|
|
@ -152,7 +162,15 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
|
|||
e131_addr_t dest_addr;
|
||||
|
||||
e131_pkt_init(&packet, universe, 512);
|
||||
e131_multicast_dest(&dest_addr, universe, E131_DEFAULT_PORT);
|
||||
|
||||
if(multicast)
|
||||
{
|
||||
e131_multicast_dest(&dest_addr, universe, E131_DEFAULT_PORT);
|
||||
}
|
||||
else
|
||||
{
|
||||
e131_unicast_dest(&dest_addr, devices[0].ip.c_str(), E131_DEFAULT_PORT);
|
||||
}
|
||||
|
||||
packets.push_back(packet);
|
||||
universes.push_back(universe);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ typedef unsigned int e131_matrix_order;
|
|||
struct E131Device
|
||||
{
|
||||
std::string name;
|
||||
std::string ip;
|
||||
unsigned int num_leds;
|
||||
unsigned int start_universe;
|
||||
unsigned int start_channel;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue