Linking works
This commit is contained in:
parent
42d3600cd8
commit
0c826d24be
@ -1,8 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.13) # CMake version check
|
||||
|
||||
file(GLOB srcs
|
||||
*.cpp
|
||||
Things/*.cpp
|
||||
Messages/*.cpp
|
||||
Arduino/*.cpp
|
||||
Posix/*.cpp
|
||||
Windows/*.cpp
|
||||
EspIdf/*.cpp
|
||||
LinearAlgebra/*.cpp
|
||||
)
|
||||
|
||||
if(ESP_PLATFORM)
|
||||
idf_component_register(
|
||||
SRC_DIRS "." "LinearAlgebra"
|
||||
SRCS ${srcs}
|
||||
INCLUDE_DIRS "." "LinearAlgebra"
|
||||
REQUIRES esp_netif esp_wifi
|
||||
)
|
||||
else()
|
||||
project(RoboidControl)
|
||||
@ -28,14 +41,6 @@ else()
|
||||
.
|
||||
LinearAlgebra
|
||||
)
|
||||
file(GLOB srcs
|
||||
*.cpp
|
||||
Things/*.cpp
|
||||
Messages/*.cpp
|
||||
Arduino/*.cpp
|
||||
Posix/*.cpp
|
||||
Windows/*.cpp
|
||||
)
|
||||
add_library(RoboidControl STATIC ${srcs})
|
||||
|
||||
enable_testing()
|
||||
|
@ -1,21 +1,11 @@
|
||||
#include "EspIdfParticipant.h"
|
||||
|
||||
#include "esp_wifi.h"
|
||||
#include "lwip/sockets.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
namespace EspIdf {
|
||||
|
||||
// #include <stdio.h>
|
||||
// #include <string.h>
|
||||
#include "esp_log.h"
|
||||
// #include "esp_system.h"
|
||||
#include "esp_netif.h"
|
||||
// #include "esp_event_loop.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "lwip/sockets.h"
|
||||
// #include "lwip/err.h"
|
||||
// #include "lwip/sys.h"
|
||||
// #include "lwip/ip_addr.h"
|
||||
// #include "lwip/inet.h"
|
||||
|
||||
void LocalParticipant::Setup(int localPort,
|
||||
const char* remoteIpAddress,
|
||||
int remotePort) {
|
||||
@ -31,10 +21,10 @@ void LocalParticipant::Setup(int localPort,
|
||||
return;
|
||||
}
|
||||
|
||||
struct sockaddr_in server_addr, client_addr;
|
||||
socklen_t addr_len = sizeof(client_addr);
|
||||
char recv_buffer[1024];
|
||||
// int sockfd;
|
||||
struct sockaddr_in server_addr; //, client_addr;
|
||||
// socklen_t addr_len = sizeof(client_addr);
|
||||
// char recv_buffer[1024];
|
||||
// int sockfd;
|
||||
|
||||
// Create a UDP socket
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
@ -96,7 +86,6 @@ void LocalParticipant::Receive() {
|
||||
int packetSize = recvfrom(sockfd, buffer, sizeof(buffer) - 1, 0,
|
||||
(struct sockaddr*)&client_addr, &addr_len);
|
||||
while (packetSize > 0) {
|
||||
|
||||
char sender_ipAddress[16];
|
||||
inet_ntoa_r(client_addr.sin_addr, sender_ipAddress, INET_ADDRSTRLEN);
|
||||
unsigned int sender_port = client_addr.sin_port;
|
||||
@ -116,7 +105,7 @@ void LocalParticipant::Receive() {
|
||||
// ReceiveData(packetSize, remoteParticipant);
|
||||
ReceiveData(packetSize, sender_ipAddress, sender_port);
|
||||
packetSize = recvfrom(sockfd, buffer, sizeof(buffer) - 1, 0,
|
||||
(struct sockaddr*)&client_addr, &addr_len);
|
||||
(struct sockaddr*)&client_addr, &addr_len);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -127,10 +116,13 @@ bool LocalParticipant::Send(Participant* remoteParticipant, int bufferSize) {
|
||||
// << remoteParticipant->port << "\n";
|
||||
|
||||
struct sockaddr_in dest_addr;
|
||||
dest_addr.sin_family = AF_INET;
|
||||
dest_addr.sin_port = htons(remoteParticipant->port);
|
||||
inet_pton(AF_INET, remoteParticipant->ipAddress, &dest_addr.sin_addr.s_addr);
|
||||
int err = sendto(sockfd, buffer, bufferSize, 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
|
||||
dest_addr.sin_family = AF_INET;
|
||||
dest_addr.sin_port = htons(remoteParticipant->port);
|
||||
inet_pton(AF_INET, remoteParticipant->ipAddress, &dest_addr.sin_addr.s_addr);
|
||||
int err = sendto(sockfd, buffer, bufferSize, 0, (struct sockaddr*)&dest_addr,
|
||||
sizeof(dest_addr));
|
||||
if (err != 0)
|
||||
std::cout << "Send error\n";
|
||||
|
||||
#endif
|
||||
return true;
|
||||
@ -142,14 +134,17 @@ bool LocalParticipant::Publish(IMessage* msg) {
|
||||
if (bufferSize <= 0)
|
||||
return true;
|
||||
|
||||
struct sockaddr_in dest_addr;
|
||||
dest_addr.sin_family = AF_INET;
|
||||
dest_addr.sin_port = htons(this->remotePort);
|
||||
inet_pton(AF_INET, this->broadcastIpAddress, &dest_addr.sin_addr.s_addr);
|
||||
int err = sendto(sockfd, buffer, bufferSize, 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
|
||||
// udp.beginPacket(this->broadcastIpAddress, this->remotePort);
|
||||
// udp.write((unsigned char*)buffer, bufferSize);
|
||||
// udp.endPacket();
|
||||
struct sockaddr_in dest_addr;
|
||||
dest_addr.sin_family = AF_INET;
|
||||
dest_addr.sin_port = htons(this->remotePort);
|
||||
inet_pton(AF_INET, this->broadcastIpAddress, &dest_addr.sin_addr.s_addr);
|
||||
int err = sendto(sockfd, buffer, bufferSize, 0, (struct sockaddr*)&dest_addr,
|
||||
sizeof(dest_addr));
|
||||
if (err != 0)
|
||||
std::cout << "Publish error\n";
|
||||
// udp.beginPacket(this->broadcastIpAddress, this->remotePort);
|
||||
// udp.write((unsigned char*)buffer, bufferSize);
|
||||
// udp.endPacket();
|
||||
|
||||
// std::cout << "Publish to " << this->broadcastIpAddress << ":"
|
||||
// << this->remotePort << "\n";
|
||||
|
@ -2,10 +2,6 @@
|
||||
|
||||
#include "../LocalParticipant.h"
|
||||
|
||||
// #if defined(HAS_WIFI)
|
||||
// #include <WiFiUdp.h>
|
||||
// #endif
|
||||
|
||||
namespace RoboidControl {
|
||||
namespace EspIdf {
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#if defined(IDF_VER)
|
||||
#include <iostream>
|
||||
#include "esp_event.h"
|
||||
// #include "esp_event.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "string.h"
|
||||
@ -26,9 +26,9 @@ static void wifi_event_handler(void* arg,
|
||||
esp_wifi_connect();
|
||||
} else if (event_base == IP_EVENT) {
|
||||
if (event_id == IP_EVENT_STA_GOT_IP) {
|
||||
ip_event_got_ip_t* event = (ip_event_got_ip_t*)event_data;
|
||||
std::cout << "Wifi connected, IP address " << (IP2STR(&event->ip_info.ip))
|
||||
<< "\n";
|
||||
//ip_event_got_ip_t* event = (ip_event_got_ip_t*)event_data;
|
||||
//const char* ipaddr = IP2STR(&event->ip_info.ip);
|
||||
std::cout << "Wifi connected, IP address (tbd)\n";
|
||||
wifi_connected = true;
|
||||
xSemaphoreGive(wifi_semaphore); // Signal that connection is established
|
||||
}
|
||||
@ -82,7 +82,7 @@ bool StartWifi(const char* wifiSsid, const char* wifiPassword) {
|
||||
}
|
||||
|
||||
if (!wifi_connected)
|
||||
std::cout << "\nCould not connect to home network.\n";
|
||||
std::cout << "\nCould not connect to home network.\n";
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ class AngleOf {
|
||||
private:
|
||||
T value;
|
||||
|
||||
AngleOf<T>(T rawValue);
|
||||
AngleOf(T rawValue);
|
||||
};
|
||||
|
||||
using AngleSingle = AngleOf<float>;
|
||||
|
@ -30,11 +30,11 @@ class DirectionOf {
|
||||
AngleOf<T> vertical;
|
||||
|
||||
/// @brief Create a new direction with zero angles
|
||||
DirectionOf<T>();
|
||||
DirectionOf();
|
||||
/// @brief Create a new direction
|
||||
/// @param horizontal The horizontal angle
|
||||
/// @param vertical The vertical angle.
|
||||
DirectionOf<T>(AngleOf<T> horizontal, AngleOf<T> vertical);
|
||||
DirectionOf(AngleOf<T> horizontal, AngleOf<T> vertical);
|
||||
|
||||
/// @brief Convert the direction into a carthesian vector
|
||||
/// @return The carthesian vector corresponding to this direction.
|
||||
|
@ -24,9 +24,9 @@ class SphericalOf {
|
||||
/// @brief The direction of the vector
|
||||
DirectionOf<T> direction;
|
||||
|
||||
SphericalOf<T>();
|
||||
SphericalOf<T>(float distance, AngleOf<T> horizontal, AngleOf<T> vertical);
|
||||
SphericalOf<T>(float distance, DirectionOf<T> direction);
|
||||
SphericalOf();
|
||||
SphericalOf(float distance, AngleOf<T> horizontal, AngleOf<T> vertical);
|
||||
SphericalOf(float distance, DirectionOf<T> direction);
|
||||
|
||||
/// @brief Create spherical vector without using AngleOf type. All given
|
||||
/// angles are in degrees
|
||||
|
@ -21,9 +21,9 @@ class SwingTwistOf {
|
||||
DirectionOf<T> swing;
|
||||
AngleOf<T> twist;
|
||||
|
||||
SwingTwistOf<T>();
|
||||
SwingTwistOf<T>(DirectionOf<T> swing, AngleOf<T> twist);
|
||||
SwingTwistOf<T>(AngleOf<T> horizontal, AngleOf<T> vertical, AngleOf<T> twist);
|
||||
SwingTwistOf();
|
||||
SwingTwistOf(DirectionOf<T> swing, AngleOf<T> twist);
|
||||
SwingTwistOf(AngleOf<T> horizontal, AngleOf<T> vertical, AngleOf<T> twist);
|
||||
|
||||
static SwingTwistOf<T> Degrees(float horizontal,
|
||||
float vertical = 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user