Skip to content

Commit 55fa8bc

Browse files
authored
Merge pull request #54 from ihsrobotics/bt-bind
Bt bind
2 parents a8acee9 + 2d1ce9e commit 55fa8bc

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.0)
2-
project(ihs_boost VERSION 1.6.0)
2+
project(ihs_boost VERSION 1.6.1)
33

44
# options
55
option(build_tests "build_tests" OFF)

modules/bindings/include/ihs_bindings.pyi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ class SysVCommunicator(CommunicatorBase):
6161
@param max_msg_size - the maximum size for messages
6262
"""
6363

64+
class BluetoothServer(CommunicatorBase):
65+
def __init__(self, max_msg_size: int = ...) -> None:
66+
"""
67+
Construct a new Bluetooth Server object
68+
@param max_msg_size - the maximum size of your messages
69+
"""
70+
71+
class BluetoothClient(CommunicatorBase):
72+
def __init__(self, target_addr: str, max_msg_size: int = ...) -> None:
73+
"""
74+
Construct a new Bluetooth Client object
75+
@param target_addr - the bluetooth address to connect to
76+
@param max_msg_size - the maximum size of your messages
77+
"""
78+
6479
class Speed:
6580
def __init__(self, left_speed: int, right_speed: int) -> None:
6681
"""

modules/bindings/src/communicate_bindings.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#ifdef build_communicate
44
#include "communicate.hpp"
55
#include <boost/python.hpp>
6+
#include <string>
67

78
namespace communicate_export
89
{
@@ -111,15 +112,18 @@ void export_communicate()
111112
{
112113
using namespace communicate_export;
113114
using namespace boost::python;
115+
using std::string;
114116

115117
// communicate section
116118
// classes
117119
class_<Communicator, boost::noncopyable>("CommunicatorBase", no_init);
118120
class_<SocketServer, bases<Communicator>>("SocketServer", init<int, optional<int>>((arg("port"), arg("max_msg_size"))));
119-
class_<SocketClient, bases<Communicator>>("SocketClient", init<const char *, int, optional<int>>((arg("ip"), arg("max_msg_size"))));
121+
class_<SocketClient, bases<Communicator>>("SocketClient", init<string, int, optional<int>>((arg("ip"), arg("max_msg_size"))));
120122
class_<SHMCommunicator, bases<Communicator>>("SHMCommunicator", init<int, optional<int>>((arg("id"), arg("max_msg_size"))));
121-
class_<PosixQCommunicator, bases<Communicator>>("PosixQCommunicator", init<const char *, optional<int, int>>((arg("name"), arg("max_msgs"), arg("max_msg_size"))));
123+
class_<PosixQCommunicator, bases<Communicator>>("PosixQCommunicator", init<string, optional<int, int>>((arg("name"), arg("max_msgs"), arg("max_msg_size"))));
122124
class_<SysVCommunicator, bases<Communicator>>("SysVCommunicator", init<int, optional<int>>((arg("id"), arg("max_msg_size"))));
125+
class_<BluetoothClient, bases<Communicator>>("BluetoothClient", init<string, optional<int>>((arg("bluetooth_addr"), arg("max_msg_size"))));
126+
class_<BluetoothServer, bases<Communicator>>("BluetoothServer", init<optional<int>>((arg("max_msg_size"))));
123127

124128
// ints
125129
def("receive_ints", receive_ints);

modules/communicate/include/btcommunicator.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class BluetoothServer : public Communicator
4949
*
5050
*/
5151
virtual void open();
52+
5253
/**
5354
* @brief Close the communicator.
5455
* @details This should be called automatically in the deconstructor.
@@ -91,7 +92,7 @@ class BluetoothClient : public Communicator
9192
* @brief Construct a new Bluetooth Client object
9293
*
9394
* @param target_addr the bluetooth address to connect to
94-
* @param max_msg_size the maximum size of your messages
95+
* @param max_msg_size The maximum size of your messages
9596
*/
9697
BluetoothClient(std::string target_addr, uint32_t max_msg_size);
9798

@@ -114,6 +115,7 @@ class BluetoothClient : public Communicator
114115
*
115116
*/
116117
virtual void open();
118+
117119
/**
118120
* @brief Close the communicator.
119121
* @details This should be called automatically in the deconstructor.

0 commit comments

Comments
 (0)