My goal in the end is to aggregate sensor data across the Mesh which shall be send to the Router which is also an ESP32 with softAP.
The basic setup seems to work for now. I've observed my small network electing a root, meshing together and connecting to the "router-ESP".
So far so good.
Now I'm trying to send data from a leaf or a node to the router-ESP.
I created a new task but I can't figure out why I'm getting this error:
Code: Select all
incompatible types when assigning to type 'ip4_addr_t' {aka 'struct ip4_addr'} from type 'u32_t' {aka 'unsigned int'} mesh_main.c /internal_communication_example/main line 398 C/C++ Problem
Code: Select all
void sensor_test(void *arg)
{
u32_t greetings = 123456;
mesh_data_t data;
data.data = &greetings; //todo
data.size = sizeof(greetings); //todo
data.proto = MESH_PROTO_BIN;
data.tos = MESH_TOS_P2P;
is_running = true;
while (is_running) {
/* non-root do nothing but print */
if (!esp_mesh_is_root()) {
vTaskDelay(10 * 1000 / portTICK_RATE_MS);
continue;
}
mip_t broker_addr;
broker_addr.ip4 = ipaddr_addr("192.168.2.2");
broker_addr.port = 1883;
esp_mesh_send(&broker_addr, &data, MESH_DATA_TODS, NULL, 0);
}
vTaskDelete(NULL);
}
I do understand the nature of the error, but I don't understand why it occurs, since;
Code: Select all
u32_t ipaddr_addr(const char *cp);
and "mip_t" comes down to a u32_t as well:
Code: Select all
typedef union {
uint8_t addr[6]; /**< mac address */
mip_t mip; /**< mip address */
} mesh_addr_t;
Code: Select all
typedef struct {
ip4_addr_t ip4; /**< IP address */
uint16_t port; /**< port */
} __attribute__((packed)) mip_t;
Code: Select all
typedef struct ip4_addr ip4_addr_t;
Code: Select all
struct ip4_addr {
u32_t addr;
};
What exactly is my problem here?
And btw; it would be highly appreciated to have more code examples for all the functions and workings of the mesh.
Thanks!