Skip to content

Commit

Permalink
Rename esp_now_ros -> smart_device_protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
sktometometo committed Nov 29, 2023
1 parent a6a4f07 commit 6105acf
Show file tree
Hide file tree
Showing 40 changed files with 107 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/catkin_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:
run: |
source /opt/ros/noetic/setup.bash
cd ${CATKIN_WS}
catkin run_tests esp_now_ros -v
catkin run_tests smart_device_protocol -v
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.8.3)
project(esp_now_ros)
project(smart_device_protocol)

find_package(catkin REQUIRED COMPONENTS message_generation catkin_virtualenv std_msgs)

Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<div align="center">

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Black formatting](https://github.com/sktometometo/esp_now_ros/actions/workflows/python_black.yml/badge.svg)](https://github.com/sktometometo/esp_now_ros/actions/workflows/python_black.yml)
[![ROS build workflow](https://github.com/sktometometo/esp_now_ros/actions/workflows/catkin_build.yml/badge.svg)](https://github.com/sktometometo/esp_now_ros/actions/workflows/catkin_build.yml)
[![PlatformIO Build Workflow](https://github.com/sktometometo/esp_now_ros/actions/workflows/platformio.yml/badge.svg)](https://github.com/sktometometo/esp_now_ros/actions/workflows/platformio.yml)
[![Black formatting](https://github.com/sktometometo/smart_device_protocol/actions/workflows/python_black.yml/badge.svg)](https://github.com/sktometometo/smart_device_protocol/actions/workflows/python_black.yml)
[![ROS build workflow](https://github.com/sktometometo/smart_device_protocol/actions/workflows/catkin_build.yml/badge.svg)](https://github.com/sktometometo/smart_device_protocol/actions/workflows/catkin_build.yml)
[![PlatformIO Build Workflow](https://github.com/sktometometo/smart_device_protocol/actions/workflows/platformio.yml/badge.svg)](https://github.com/sktometometo/smart_device_protocol/actions/workflows/platformio.yml)

</div>

# esp_now_ros
# smart_device_protocol

The Smart Device Protocol (SDP) Repository.

Expand Down Expand Up @@ -46,7 +46,7 @@ First, clone this repository to your catkin workspace and build it.

```bash
cd ~/catkin_ws/src
git clone https://github.com/sktometometo/esp_now_ros.git
git clone https://github.com/sktometometo/smart_device_protocol.git
cd ..
catkin build
```
Expand Down Expand Up @@ -106,7 +106,7 @@ Then, connect M5Stack-Core2 to your PC. You can check which port is connected to
So let's build firmware and burn it to M5Stack-Core2
```bash
roscd esp_now_ros/sketchbooks/smart_device_protocol_interface/
roscd smart_device_protocol/sketchbooks/smart_device_protocol_interface/
pio run -e m5stack-core2 --target upload --upload-port /dev/ttyACM0
```
Expand All @@ -118,7 +118,7 @@ We will use [sdp_example](./sketchbooks/sdp_example/).
Connect M5Stack-Fire to your PC and burn firmware to it.
```bash
roscd esp_now_ros/sketchbooks/sdp_example/
roscd smart_device_protocol/sketchbooks/sdp_example/
pio run -e m5stack-fire --target upload --upload-port /dev/ttyACM0
```
Expand All @@ -127,24 +127,24 @@ Connect M5Stack-Fire to your PC and burn firmware to it.
After step 2, you can run Smart Device Protocol interface node.
```bash
roslaunch esp_now_ros demo.launch port:=/dev/ttyACM0
roslaunch smart_device_protocol demo.launch port:=/dev/ttyACM0
```
with this, you can see topics below.
```bash
$ rostopic list
/diagnostics
/esp_now_ros/recv
/esp_now_ros/send
/smart_device_protocol/recv
/smart_device_protocol/send
/rosout
/rosout_agg
```
You can send a ESP-NOW (which is the bottom of Smart Device Protocol) packet directly by sending ROS a message to `/esp_now_ros/send` topic.
You can send a ESP-NOW (which is the bottom of Smart Device Protocol) packet directly by sending ROS a message to `/smart_device_protocol/send` topic.
```bash
rostopic pub -1 /esp_now_ros/send esp_now_ros/Packet "mac_address: [255, 255, 255, 255, 255, 255]
rostopic pub -1 /smart_device_protocol/send smart_device_protocol/Packet "mac_address: [255, 255, 255, 255, 255, 255]
data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
```
Expand All @@ -154,7 +154,7 @@ Now you can communicate with smart devices, wearable devices, and robots via Sma
You can run an example of Smart Device Protocol Interface node.
```bash
rosrun esp_now_ros sdp_v2_packet_printer.py
rosrun smart_device_protocol sdp_v2_packet_printer.py
```
With this command, you can see Smart Device Protocol packets from other devices.
Expand Down Expand Up @@ -190,7 +190,7 @@ There are some examples of Smart Device Protocol Interface Device. For more deta
If you update ros_lib for Arduino, you have to update `ros_lib` directory in [this directory](./ros_lib/).
```bash
cd ~/catkin_ws/src/esp_now_ros/ros_lib
cd ~/catkin_ws/src/smart_device_protocol/ros_lib
rm -rf ros_lib
rosrun rosserial_arduino make_libraries.py .
```
2 changes: 1 addition & 1 deletion arduino_lib/sdp/esp_now.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <esp_now.h>
#include <WiFi.h>

#include <esp_now_ros/Packet.h>
#include <smart_device_protocol/Packet.h>

bool init_esp_now(uint8_t *mac_address, esp_now_recv_cb_t callback_receive)
{
Expand Down
20 changes: 10 additions & 10 deletions arduino_lib/sdp/packet_creator.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef ESP_NOW_ROS_PACKET_CREATOR_H__
#define ESP_NOW_ROS_PACKET_CREATOR_H__
#ifndef SMART_DEVICE_PROTOCOL_PACKET_CREATOR_H__
#define SMART_DEVICE_PROTOCOL_PACKET_CREATOR_H__

#include <variant>
#include <vector>
#include <string.h>

#include <esp_now_ros/Packet.h>
#include <smart_device_protocol/Packet.h>

#include "sdp/packet_util.h"

Expand All @@ -14,7 +14,7 @@ void generate_meta_frame(uint8_t *packet, const char *device_name, const char *p
const char *serialization_format_02, const char *packet_description_03,
const char *serialization_format_03)
{
*(uint16_t *)(packet + 0) = esp_now_ros::Packet::PACKET_TYPE_META;
*(uint16_t *)(packet + 0) = smart_device_protocol::Packet::PACKET_TYPE_META;
strncpy((char *)(packet + 2), device_name, 20);
strncpy((char *)(packet + 2 + 20), packet_description_01, 64);
strncpy((char *)(packet + 2 + 20 + 64), serialization_format_01, 10);
Expand All @@ -35,7 +35,7 @@ bool generate_data_frame(uint8_t *packet, const char *packet_description, const
{
return false;
}
*(uint16_t *)(packet + 0) = esp_now_ros::Packet::PACKET_TYPE_DATA;
*(uint16_t *)(packet + 0) = smart_device_protocol::Packet::PACKET_TYPE_DATA;
strncpy((char *)(packet + 2), packet_description, 64);
strncpy((char *)(packet + 2 + 64), serialization_format, 10);
auto packet_data_p = packet + 2 + 64 + 10;
Expand Down Expand Up @@ -102,31 +102,31 @@ bool generate_data_frame(uint8_t *packet, const char *packet_description,
/* Version 1 functions */
void create_sensor_enviii_packet(uint8_t *packet, const char *module_name, int32_t pressure)
{
*(uint16_t *)(packet + 0) = esp_now_ros::Packet::PACKET_TYPE_SENSOR_ENV_III;
*(uint16_t *)(packet + 0) = smart_device_protocol::Packet::PACKET_TYPE_SENSOR_ENV_III;
strncpy((char *)(packet + 2), module_name, 64);
*(int32_t *)(packet + 2 + 64) = pressure;
}

void create_sensor_stickv2_packet(uint8_t *packet, uint32_t number_of_person, const char *place_name)
{
*(uint16_t *)(packet + 0) = esp_now_ros::Packet::PACKET_TYPE_SENSOR_UNITV2_PERSON_COUNTER;
*(uint16_t *)(packet + 0) = smart_device_protocol::Packet::PACKET_TYPE_SENSOR_UNITV2_PERSON_COUNTER;
*(uint32_t *)(packet + 2) = number_of_person;
strncpy((char *)(packet + 2 + 4), place_name, 64);
}

void create_device_message_board_meta_packet(uint8_t *packet, const char *module_name)
{
*(uint16_t *)(packet + 0) = esp_now_ros::Packet::PACKET_TYPE_DEVICE_MESSAGE_BOARD_META;
*(uint16_t *)(packet + 0) = smart_device_protocol::Packet::PACKET_TYPE_DEVICE_MESSAGE_BOARD_META;
strncpy((char *)(packet + 2), module_name, 64);
}

void create_device_message_board_data_packet(uint8_t *packet, const char *source_name, uint64_t timeout_duration,
const char *message)
{
*(uint16_t *)(packet + 0) = esp_now_ros::Packet::PACKET_TYPE_DEVICE_MESSAGE_BOARD_DATA;
*(uint16_t *)(packet + 0) = smart_device_protocol::Packet::PACKET_TYPE_DEVICE_MESSAGE_BOARD_DATA;
strncpy((char *)(packet + 2), source_name, 64);
*(uint64_t *)(packet + 2 + 64) = timeout_duration;
strncpy((char *)(packet + 2 + 64 + 8), message, 64);
}

#endif // ESP_NOW_ROS_PACKET_CREATOR_H__
#endif // SMART_DEVICE_PROTOCOL_PACKET_CREATOR_H__
8 changes: 4 additions & 4 deletions arduino_lib/sdp/packet_parser.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef ESP_NOW_ROS_PACKET_PARSER_H__
#define ESP_NOW_ROS_PACKET_PARSER_H__
#ifndef SMART_DEVICE_PROTOCOL_PACKET_PARSER_H__
#define SMART_DEVICE_PROTOCOL_PACKET_PARSER_H__

#include <string.h>
#include <tuple>
#include <variant>
#include <vector>

#include <esp_now_ros/Packet.h>
#include <smart_device_protocol/Packet.h>

#include "sdp/packet_util.h"

Expand Down Expand Up @@ -116,4 +116,4 @@ void parse_packet_as_message_board_data_packet(const uint8_t *packet, uint16_t &
strncpy(message, (char *)(packet + 2 + 64 + 8), 64);
}

#endif // ESP_NOW_ROS_PACKET_PARSER_H__z
#endif // SMART_DEVICE_PROTOCOL_PACKET_PARSER_H__z
6 changes: 3 additions & 3 deletions arduino_lib/sdp/packet_util.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef ESP_NOW_ROS_PACKET_UTIL_H__
#define ESP_NOW_ROS_PACKET_UTIL_H__
#ifndef SMART_DEVICE_PROTOCOL_PACKET_UTIL_H__
#define SMART_DEVICE_PROTOCOL_PACKET_UTIL_H__

#include <variant>
#include <vector>
Expand Down Expand Up @@ -86,4 +86,4 @@ bool is_consistent_serialization_format(const std::string &serialization_format,
return true;
}

#endif // ESP_NOW_ROS_PACKET_UTIL_H__
#endif // SMART_DEVICE_PROTOCOL_PACKET_UTIL_H__
8 changes: 4 additions & 4 deletions arduino_lib/sdp/sdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* SDP (Smart Device Protocol) Library
*
* To use these functions, you need to include the following libraries:
* - esp_now_ros/Packet.h
* - smart_device_protocol/Packet.h
*/

#include <esp_system.h>
#include <esp_now.h>
#include <WiFi.h>

#include <esp_now_ros/Packet.h>
#include <smart_device_protocol/Packet.h>

#include "sdp/esp_now.h"
#include "sdp/packet_creator.h"
Expand Down Expand Up @@ -69,7 +69,7 @@ void _OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len)
{
entry(mac_addr, data, data_len);
}
if (packet_type == esp_now_ros::Packet::PACKET_TYPE_DATA)
if (packet_type == smart_device_protocol::Packet::PACKET_TYPE_DATA)
{
auto packet = parse_packet_as_data_packet(data);
SDPInterfaceDescription packet_description_and_serialization_format = std::get<0>(packet);
Expand All @@ -91,7 +91,7 @@ void _OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len)
}
}
}
else if (packet_type == esp_now_ros::Packet::PACKET_TYPE_META)
else if (packet_type == smart_device_protocol::Packet::PACKET_TYPE_META)
{
auto packet = parse_packet_as_meta_packet(data);
std::string device_name = std::get<0>(packet);
Expand Down
6 changes: 3 additions & 3 deletions arduino_lib/sdp/sdp_util.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef ESP_NOW_ROS_SDP_UTIL_H
#define ESP_NOW_ROS_SDP_UTIL_H
#ifndef SMART_DEVICE_PROTOCOL_SDP_UTIL_H
#define SMART_DEVICE_PROTOCOL_SDP_UTIL_H

#include "sdp/sdp.h"

#endif // ESP_NOW_ROS_SDP_UTIL_H
#endif // SMART_DEVICE_PROTOCOL_SDP_UTIL_H
6 changes: 3 additions & 3 deletions arduino_lib/utils/config_loader.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef ESP_NOW_ROS_CONFIG_LOADER_H
#define ESP_NOW_ROS_CONFIG_LOADER_H
#ifndef SMART_DEVICE_PROTOCOL_CONFIG_LOADER_H
#define SMART_DEVICE_PROTOCOL_CONFIG_LOADER_H

#include <Arduino.h>
#include <ArduinoJson.h>
Expand All @@ -25,4 +25,4 @@ bool load_json_from_FS(fs::FS &fs, const String &filename, StaticJsonDocument<N>
return true;
}

#endif // ESP_NOW_ROS_CONFIG_LOADER_H
#endif // SMART_DEVICE_PROTOCOL_CONFIG_LOADER_H
2 changes: 1 addition & 1 deletion docs/README_old.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# old readme for ESP_NOW_ROS
# old readme for SMART_DEVICE_PROTOCOL

## Packet Specification

Expand Down
2 changes: 1 addition & 1 deletion launch/demo.launch
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<node
pkg="rosserial_python"
type="serial_node.py"
name="esp_now_ros"
name="smart_device_protocol"
output="screen"
>
<rosparam subst_value="true">
Expand Down
4 changes: 2 additions & 2 deletions node_scripts/broadcast_v1_test_packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import rospy

from esp_now_ros.esp_now_ros_interface import ESPNOWROSInterface
from esp_now_ros.packet_generator import create_test_packet
from smart_device_protocol.smart_device_protocol_interface import ESPNOWROSInterface
from smart_device_protocol.packet_generator import create_test_packet

if __name__ == "__main__":
rospy.init_node("broadcast_test_packet")
Expand Down
4 changes: 2 additions & 2 deletions node_scripts/esp_now_v1_packet_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import rospy

from esp_now_ros.esp_now_ros_interface import ESPNOWROSInterface
from esp_now_ros.packet_parser import parse_packet
from smart_device_protocol.smart_device_protocol_interface import ESPNOWROSInterface
from smart_device_protocol.packet_parser import parse_packet


def callback(src_address, data):
Expand Down
2 changes: 1 addition & 1 deletion node_scripts/sdp_v2_device_interface_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import rospy

from esp_now_ros.smart_device_protocol_interface import DeviceDictSDPInterface
from smart_device_protocol.smart_device_protocol_interface import DeviceDictSDPInterface


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion node_scripts/sdp_v2_packet_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import rospy

from esp_now_ros.smart_device_protocol_interface import SDPInterface
from smart_device_protocol.smart_device_protocol_interface import SDPInterface


def callback(src_address, frame):
Expand Down
4 changes: 2 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<package format="2">
<name>esp_now_ros</name>
<name>smart_device_protocol</name>
<version>0.4.1</version>
<description>The esp_now_ros package</description>
<description>The smart_device_protocol package</description>

<maintainer email="[email protected]">Koki Shinjo</maintainer>

Expand Down
6 changes: 3 additions & 3 deletions python/esp_now_ros/esp_now_ros_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import rospy

from esp_now_ros.msg import Packet
from smart_device_protocol.msg import Packet


class ESPNOWROSInterface:
def __init__(
self,
callback=None,
recv_topic="/esp_now_ros/recv",
send_topic="/esp_now_ros/send",
recv_topic="/smart_device_protocol/recv",
send_topic="/smart_device_protocol/send",
):
self.raw_callback = callback
self.sub = rospy.Subscriber(recv_topic, Packet, self.callback)
Expand Down
2 changes: 1 addition & 1 deletion python/esp_now_ros/packet_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import struct

from esp_now_ros.msg import Packet
from smart_device_protocol.msg import Packet


# Version 1 of the packet generator
Expand Down
4 changes: 2 additions & 2 deletions python/esp_now_ros/packet_parser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import struct
from typing import List, Tuple, Union

from esp_now_ros.sdp_frames import MetaFrame, DataFrame
from esp_now_ros.msg import Packet
from smart_device_protocol.sdp_frames import MetaFrame, DataFrame
from smart_device_protocol.msg import Packet

PACKET_TYPE_META = Packet.PACKET_TYPE_META
PACKET_TYPE_DATA = Packet.PACKET_TYPE_DATA
Expand Down
Loading

0 comments on commit 6105acf

Please sign in to comment.