mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-10 02:23:21 +00:00
manual
This commit is contained in:
@@ -8,17 +8,35 @@ Configuration Variables
|
||||
|
||||
uint8_t receiver_mac[ESP_NOW_ETH_ALEN] = {0xe4, 0xb0, 0x63, 0x17, 0x9e, 0x44};
|
||||
|
||||
typedef struct {
|
||||
int x_axis; // Joystick x-position
|
||||
int y_axis; // Joystick y-position
|
||||
bool nav_bttn; // Joystick push button
|
||||
bool led; // LED ON/OFF state
|
||||
uint8_t motor1_rpm_pwm; // PWMs for 4 DC motors
|
||||
uint8_t motor2_rpm_pwm;
|
||||
uint8_t motor3_rpm_pwm;
|
||||
uint8_t motor4_rpm_pwm;
|
||||
} __attribute__((packed)) sensors_data_t;
|
||||
|
||||
Sending & Ecapsulating Data
|
||||
----------------------------
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
void onDataReceived (const uint8_t *mac_addr, const uint8_t *data, uint8_t data_len) {
|
||||
ESP_LOGI(TAG, "Data received from: %02x:%02x:%02x:%02x:%02x:%02x, len=%d", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5], data_len);
|
||||
memcpy(&buf, data, sizeof(buf));
|
||||
void sendData (void) {
|
||||
|
||||
x_axis = buf.x_axis;
|
||||
y_axis = buf.y_axis
|
||||
... ... ...
|
||||
... ... ...
|
||||
|
||||
buffer.x_axis = x_axis;
|
||||
buffer.y_axis = y_axis;
|
||||
|
||||
// Call ESP-NOW function to send data (MAC address of receiver, pointer to the memory holding data & data length)
|
||||
uint8_t result = esp_now_send((uint8_t*)receiver_mac, (uint8_t *)&buffer, sizeof(buffer));
|
||||
|
||||
... ... ...
|
||||
... ... ...
|
||||
}
|
||||
|
||||
Main Function
|
||||
|
Reference in New Issue
Block a user