Skip to content

Commit

Permalink
Add testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sktometometo committed Oct 15, 2024
1 parent 3b813c0 commit c6685cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions arduino_lib/sdp/esp_now.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#include <WiFi.h>
#include <esp_mac.h>
#include <esp_now.h>
#include <esp_system.h>
#include <esp_wifi.h>
#include <smart_device_protocol/Packet.h>

bool init_esp_now(uint8_t *mac_address, esp_now_recv_cb_t callback_receive) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@ build_unflags =
-std=gnu++11
-DUSE_DISPLAY

[env:m5atom-lite-new]
platform = espressif32@ ^6.9.0
[env:m5atom-lite-testing]
platform = https://github.com/pioarduino/platform-espressif32.git#51.03.05 # For arduino-esp32 v3.0.5 which uses ESP-IDF 5.1.4
board = m5stack-atom
framework = arduino
lib_ldf_mode = deep
lib_deps =
m5stack/M5Atom@^0.1.1
fastled/FastLED@^3.6.0
https://github.com/m5stack/M5Atom.git#0.1.3
fastled/FastLED@^3.7.8
monitor_speed = 115200
build_flags =
-DM5ATOMLITE
-DTESTING
-std=gnu++17
build_unflags =
-std=gnu++11
Expand Down
10 changes: 10 additions & 0 deletions sketchbooks/smart_device_protocol_ros_interface/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,16 @@ void ledcolorCb(const std_msgs::ColorRGBA &msg) {

// Display

#if defined(TESTING)
void OnDataRecv(const esp_now_recv_info_t *esp_now_info, const uint8_t *data, int data_len) {
uint8_t mac_addr[6];
// copy esp_now_info->mac_addr to mac_addr
for (int i = 0; i < 6; i++) {
mac_addr[i] = esp_now_info->src_addr[i];
}
#else
void OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len) {
#endif
for (int i = 0; i < 6; i++) {
mac_address_for_msg[i] = mac_addr[i];
}
Expand All @@ -157,6 +166,7 @@ void OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len) {
}
msg_recv_packet.mac_address = mac_address_for_msg;
msg_recv_packet.mac_address_length = 6;
// msg_recv_packet.rssi = esp_now_info->rx_ctrl->rssi;
msg_recv_packet.data = buffer_for_msg;
msg_recv_packet.data_length = data_len;
publisher.publish(&msg_recv_packet);
Expand Down

0 comments on commit c6685cc

Please sign in to comment.