diff --git a/Controllers/EspurnaController/EspurnaController.cpp b/Controllers/EspurnaController/EspurnaController.cpp index b65323e8..f3a79ede 100644 --- a/Controllers/EspurnaController/EspurnaController.cpp +++ b/Controllers/EspurnaController/EspurnaController.cpp @@ -46,11 +46,17 @@ void EspurnaController::Initialize(char* ledstring) void EspurnaController::InitializeEspurna(char * clientname, char * port, char * apikey) { - strcpy(client_name, clientname); - strcpy(port_name, port); + client_name = clientname; + port_name = port; + strcpy(espurna_apikey, apikey); tcpport = new net_port; - tcpport->tcp_client(client_name, port_name); + tcpport->tcp_client(client_name.c_str(), port_name.c_str()); +} + +std::string EspurnaController::GetLocation() +{ + return("TCP: " + client_name + ":" + port_name); } void EspurnaController::SetLEDs(std::vector colors) @@ -60,7 +66,7 @@ void EspurnaController::SetLEDs(std::vector colors) RGBColor color = colors[0]; char get_request[1024]; - snprintf(get_request, 1024, "GET /api/rgb?apikey=%s&value=%%23%02X%02X%02X HTTP/1.1\r\nHost: %s\r\n\r\n", espurna_apikey, RGBGetRValue(color), RGBGetGValue(color), RGBGetBValue(color), client_name); + snprintf(get_request, 1024, "GET /api/rgb?apikey=%s&value=%%23%02X%02X%02X HTTP/1.1\r\nHost: %s\r\n\r\n", espurna_apikey, RGBGetRValue(color), RGBGetGValue(color), RGBGetBValue(color), client_name.c_str()); tcpport->tcp_client_connect(); tcpport->tcp_client_write(get_request, strlen(get_request)); tcpport->tcp_close(); diff --git a/Controllers/EspurnaController/EspurnaController.h b/Controllers/EspurnaController/EspurnaController.h index 7cb5d4e5..3027ea63 100644 --- a/Controllers/EspurnaController/EspurnaController.h +++ b/Controllers/EspurnaController/EspurnaController.h @@ -28,16 +28,19 @@ public: EspurnaController(); ~EspurnaController(); - void Initialize(char* ledstring); - void InitializeEspurna(char* clientname, char* port, char * apikey); - void SetLEDs(std::vector colors); + void Initialize(char* ledstring); + void InitializeEspurna(char* clientname, char* port, char * apikey); + + std::string GetLocation(); + + void SetLEDs(std::vector colors); private: int baud_rate; char led_string[1024]; - char port_name[128]; - char client_name[1024]; + std::string port_name; + std::string client_name; char espurna_apikey[128]; net_port *tcpport; diff --git a/Controllers/EspurnaController/RGBController_Espurna.cpp b/Controllers/EspurnaController/RGBController_Espurna.cpp index ab6d5158..5e1f066d 100644 --- a/Controllers/EspurnaController/RGBController_Espurna.cpp +++ b/Controllers/EspurnaController/RGBController_Espurna.cpp @@ -15,6 +15,7 @@ RGBController_Espurna::RGBController_Espurna(EspurnaController* espurna_ptr) name = "Espurna"; type = DEVICE_TYPE_LIGHT; description = "Espurna Device"; + location = espurna->GetLocation(); mode Direct; Direct.name = "Direct"; diff --git a/Controllers/LEDStripController/LEDStripController.cpp b/Controllers/LEDStripController/LEDStripController.cpp index f817ec51..2f0fa17e 100644 --- a/Controllers/LEDStripController/LEDStripController.cpp +++ b/Controllers/LEDStripController/LEDStripController.cpp @@ -86,21 +86,37 @@ void LEDStripController::Initialize(char* ledstring) void LEDStripController::InitializeSerial(char* portname, int baud) { portname = strtok(portname, "\r"); - strcpy(port_name, portname); + port_name = portname; baud_rate = baud; - serialport = new serial_port(port_name, baud_rate); + serialport = new serial_port(port_name.c_str(), baud_rate); udpport = NULL; } void LEDStripController::InitializeUDP(char * clientname, char * port) { - strcpy(client_name, clientname); - strcpy(port_name, port); + client_name = clientname; + port_name = port; - udpport = new net_port(client_name, port_name); + udpport = new net_port(client_name.c_str(), port_name.c_str()); serialport = NULL; } +std::string LEDStripController::GetLocation() +{ + if(serialport != NULL) + { + return("COM: " + port_name); + } + else if(udpport != NULL) + { + return("UDP: " + client_name + ":" + port_name); + } + else + { + return(""); + } +} + char* LEDStripController::GetLEDString() { return(led_string); @@ -143,4 +159,4 @@ void LEDStripController::SetLEDs(std::vector colors) } delete[] serial_buf; -} \ No newline at end of file +} diff --git a/Controllers/LEDStripController/LEDStripController.h b/Controllers/LEDStripController/LEDStripController.h index ff56b569..691a6bd6 100644 --- a/Controllers/LEDStripController/LEDStripController.h +++ b/Controllers/LEDStripController/LEDStripController.h @@ -36,11 +36,14 @@ public: LEDStripController(); ~LEDStripController(); - void Initialize(char* ledstring); - void InitializeSerial(char* portname, int baud); - void InitializeUDP(char* clientname, char* port); - char* GetLEDString(); - void SetLEDs(std::vector colors); + void Initialize(char* ledstring); + void InitializeSerial(char* portname, int baud); + void InitializeUDP(char* clientname, char* port); + + char* GetLEDString(); + std::string GetLocation(); + + void SetLEDs(std::vector colors); int num_leds; @@ -48,8 +51,8 @@ private: int baud_rate; char led_string[1024]; - char port_name[128]; - char client_name[1024]; + std::string port_name; + std::string client_name; serial_port *serialport; net_port *udpport; }; diff --git a/Controllers/LEDStripController/RGBController_LEDStrip.cpp b/Controllers/LEDStripController/RGBController_LEDStrip.cpp index 355acaf8..083c5690 100644 --- a/Controllers/LEDStripController/RGBController_LEDStrip.cpp +++ b/Controllers/LEDStripController/RGBController_LEDStrip.cpp @@ -17,6 +17,7 @@ RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr) name = "LED Strip"; type = DEVICE_TYPE_LEDSTRIP; description = "Keyboard Visualizer Arduino LED Strip Device"; + location = strip->GetLocation(); mode Direct; Direct.name = "Direct"; diff --git a/Controllers/NZXTHuePlusController/NZXTHuePlusController.cpp b/Controllers/NZXTHuePlusController/NZXTHuePlusController.cpp index 6989629b..0f7757bc 100644 --- a/Controllers/NZXTHuePlusController/NZXTHuePlusController.cpp +++ b/Controllers/NZXTHuePlusController/NZXTHuePlusController.cpp @@ -24,17 +24,17 @@ HuePlusController::~HuePlusController() void HuePlusController::Initialize(char* port) { - strcpy(port_name, port); + port_name = port; - serialport = new serial_port(port_name, HUE_PLUS_BAUD); + serialport = new serial_port(port_name.c_str(), HUE_PLUS_BAUD); channel_leds[HUE_PLUS_CHANNEL_1_IDX] = GetLEDsOnChannel(HUE_PLUS_CHANNEL_1); channel_leds[HUE_PLUS_CHANNEL_2_IDX] = GetLEDsOnChannel(HUE_PLUS_CHANNEL_2); } -char* HuePlusController::GetLocation() +std::string HuePlusController::GetLocation() { - return(port_name); + return("COM: " + port_name); } unsigned int HuePlusController::GetLEDsOnChannel(unsigned int channel) diff --git a/Controllers/NZXTHuePlusController/NZXTHuePlusController.h b/Controllers/NZXTHuePlusController/NZXTHuePlusController.h index eba52794..5b2bbfb5 100644 --- a/Controllers/NZXTHuePlusController/NZXTHuePlusController.h +++ b/Controllers/NZXTHuePlusController/NZXTHuePlusController.h @@ -71,7 +71,7 @@ public: ~HuePlusController(); void Initialize(char* port); - char* GetLocation(); + std::string GetLocation(); unsigned int GetLEDsOnChannel(unsigned int channel); void SetChannelEffect @@ -94,7 +94,7 @@ public: unsigned int channel_leds[HUE_PLUS_NUM_CHANNELS]; private: - char port_name[128]; + std::string port_name; serial_port *serialport; void SendPacket