diff --git a/src/controller/c/CMakeLists.txt b/src/controller/c/CMakeLists.txt index c3ae48b..e0b9d1c 100644 --- a/src/controller/c/CMakeLists.txt +++ b/src/controller/c/CMakeLists.txt @@ -88,6 +88,7 @@ add_library(webots-controller::webots_controller ALIAS webots_controller) if(WIN32) set_target_properties(webots_controller PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + target_link_libraries(webots_controller PRIVATE ws2_32) endif() target_include_directories(webots_controller diff --git a/src/controller/c/no_plugins_stubs.c b/src/controller/c/no_plugins_stubs.c index f4ebfd0..69bea45 100644 --- a/src/controller/c/no_plugins_stubs.c +++ b/src/controller/c/no_plugins_stubs.c @@ -1,8 +1,15 @@ #include +#include +#include +#include +#include #include "html_robot_window_private.h" #include "remote_control_private.h" #include "robot_window_private.h" +#include "device_private.h" + +#include #include @@ -108,3 +115,200 @@ void *wb_remote_control_custom_function(void *arg) { (void)arg; return NULL; } + +static void radio_plugins_disabled(const char *function_name) { + fprintf(stderr, "Error: %s(): radio support is unavailable because plugins are disabled.\n", function_name); +} + +typedef struct { + int length; + char *body; + char *destination; +} NoPluginsRadioMessage; + +void wb_radio_init(WbDevice *d) { + (void)d; +} + +WbRadioMessage wb_radio_message_new(int length, const char *body, const char *destination) { + if (length < 0 || (length > 0 && body == NULL) || destination == NULL) { + fprintf(stderr, "Error: %s(): invalid argument.\n", __FUNCTION__); + return NULL; + } + + NoPluginsRadioMessage *msg = malloc(sizeof(NoPluginsRadioMessage)); + if (msg == NULL) + return NULL; + + msg->length = length; + msg->body = NULL; + msg->destination = NULL; + + if (length > 0) { + msg->body = malloc((size_t)length); + if (msg->body == NULL) { + free(msg); + return NULL; + } + memcpy(msg->body, body, (size_t)length); + } + + msg->destination = malloc(strlen(destination) + 1); + if (msg->destination == NULL) { + free(msg->body); + free(msg); + return NULL; + } + strcpy(msg->destination, destination); + return msg; +} + +void wb_radio_message_delete(WbRadioMessage msg) { + NoPluginsRadioMessage *message = (NoPluginsRadioMessage *)msg; + if (message == NULL) + return; + free(message->body); + free(message->destination); + free(message); +} + +const char *wb_radio_message_get_destination(WbRadioMessage msg) { + const NoPluginsRadioMessage *message = (const NoPluginsRadioMessage *)msg; + return message ? message->destination : NULL; +} + +int wb_radio_message_get_length(WbRadioMessage msg) { + const NoPluginsRadioMessage *message = (const NoPluginsRadioMessage *)msg; + return message ? message->length : 0; +} + +const char *wb_radio_message_get_body(WbRadioMessage msg) { + const NoPluginsRadioMessage *message = (const NoPluginsRadioMessage *)msg; + return message ? message->body : NULL; +} + +void wb_radio_enable(WbDeviceTag tag, int sampling_period) { + (void)tag; + (void)sampling_period; + radio_plugins_disabled(__FUNCTION__); +} + +void wb_radio_disable(WbDeviceTag tag) { + (void)tag; + radio_plugins_disabled(__FUNCTION__); +} + +void wb_radio_set_address(WbDeviceTag tag, const char *address) { + (void)tag; + (void)address; + radio_plugins_disabled(__FUNCTION__); +} + +const char *wb_radio_get_address(WbDeviceTag tag) { + (void)tag; + radio_plugins_disabled(__FUNCTION__); + return NULL; +} + +void wb_radio_set_frequency(WbDeviceTag tag, double hz) { + (void)tag; + (void)hz; + radio_plugins_disabled(__FUNCTION__); +} + +double wb_radio_get_frequency(WbDeviceTag tag) { + (void)tag; + radio_plugins_disabled(__FUNCTION__); + return NAN; +} + +void wb_radio_set_channel(WbDeviceTag tag, int channel) { + (void)tag; + (void)channel; + radio_plugins_disabled(__FUNCTION__); +} + +int wb_radio_get_channel(WbDeviceTag tag) { + (void)tag; + radio_plugins_disabled(__FUNCTION__); + return -1; +} + +void wb_radio_set_bitrate(WbDeviceTag tag, int bits_per_second) { + (void)tag; + (void)bits_per_second; + radio_plugins_disabled(__FUNCTION__); +} + +int wb_radio_get_bitrate(WbDeviceTag tag) { + (void)tag; + radio_plugins_disabled(__FUNCTION__); + return 0; +} + +void wb_radio_set_rx_sensitivity(WbDeviceTag tag, double dBm) { + (void)tag; + (void)dBm; + radio_plugins_disabled(__FUNCTION__); +} + +double wb_radio_get_rx_sensitivity(WbDeviceTag tag) { + (void)tag; + radio_plugins_disabled(__FUNCTION__); + return NAN; +} + +void wb_radio_set_tx_power(WbDeviceTag tag, double dBm) { + (void)tag; + (void)dBm; + radio_plugins_disabled(__FUNCTION__); +} + +double wb_radio_get_tx_power(WbDeviceTag tag) { + (void)tag; + radio_plugins_disabled(__FUNCTION__); + return NAN; +} + +void wb_radio_set_callback(WbDeviceTag tag, void (*callback)(const WbRadioEvent)) { + (void)tag; + (void)callback; + radio_plugins_disabled(__FUNCTION__); +} + +WbDeviceTag wb_radio_event_get_radio(const WbRadioEvent event) { + (void)event; + radio_plugins_disabled(__FUNCTION__); + return 0; +} + +char *wb_radio_event_get_data(const WbRadioEvent event) { + (void)event; + radio_plugins_disabled(__FUNCTION__); + return NULL; +} + +int wb_radio_event_get_data_size(const WbRadioEvent event) { + (void)event; + radio_plugins_disabled(__FUNCTION__); + return 0; +} + +char *wb_radio_event_get_emitter(const WbRadioEvent event) { + (void)event; + radio_plugins_disabled(__FUNCTION__); + return NULL; +} + +double wb_radio_event_get_rssi(const WbRadioEvent event) { + (void)event; + radio_plugins_disabled(__FUNCTION__); + return NAN; +} + +void wb_radio_send(WbDeviceTag tag, const WbRadioMessage msg, double delay) { + (void)tag; + (void)msg; + (void)delay; + radio_plugins_disabled(__FUNCTION__); +}