kopia lustrzana https://github.com/rpp0/gr-lora
Add doxygen documentation for the msg source block
rodzic
13c14c799f
commit
91a5bfa97f
|
@ -686,9 +686,13 @@ namespace gr {
|
||||||
namespace lora {
|
namespace lora {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief <+description of block+>
|
* \brief Message socket source block , using UDP
|
||||||
* \ingroup lora
|
* \ingroup lora
|
||||||
*
|
*
|
||||||
|
* \details This block creates a UDP server at a specific port
|
||||||
|
* and pass received UDP datagrams as a pmt::pmt_t blob message.
|
||||||
|
* The datagrams sent to the UDP server always contain valid
|
||||||
|
* LoRaTAP header, LoRaPHY header and payload
|
||||||
*/
|
*/
|
||||||
class LORA_API message_socket_source : virtual public gr::block
|
class LORA_API message_socket_source : virtual public gr::block
|
||||||
{
|
{
|
||||||
|
@ -696,12 +700,10 @@ namespace gr {
|
||||||
typedef boost::shared_ptr<message_socket_source> sptr;
|
typedef boost::shared_ptr<message_socket_source> sptr;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Return a shared_ptr to a new instance of lora::message_socket_source.
|
* \param addr the address to bind the UDP socket
|
||||||
*
|
* \param port the UDP port to wait for packets
|
||||||
* To avoid accidental use of raw pointers, lora::message_socket_source's
|
* \param mtu the maximum MTU. Used to pre-allocate a maximum packet size
|
||||||
* constructor is in a private implementation
|
* \param payload_len the payload length in bytes
|
||||||
* class. lora::message_socket_source::make is the public interface for
|
|
||||||
* creating new instances.
|
|
||||||
*/
|
*/
|
||||||
static sptr make(const std::string& addr, uint16_t port, size_t mtu, size_t payload_len);
|
static sptr make(const std::string& addr, uint16_t port, size_t mtu, size_t payload_len);
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,8 +52,7 @@ namespace gr
|
||||||
d_udp_port (port),
|
d_udp_port (port),
|
||||||
d_mtu (mtu),
|
d_mtu (mtu),
|
||||||
d_payload_len (payload_len),
|
d_payload_len (payload_len),
|
||||||
d_running (true),
|
d_running (true)
|
||||||
d_layer (0)
|
|
||||||
{
|
{
|
||||||
message_port_register_out (pmt::mp ("out"));
|
message_port_register_out (pmt::mp ("out"));
|
||||||
boost::shared_ptr<boost::thread> (
|
boost::shared_ptr<boost::thread> (
|
||||||
|
@ -73,6 +72,7 @@ namespace gr
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
uint32_t bytes_num;
|
uint32_t bytes_num;
|
||||||
|
pmt::pmt_t lora_tap;
|
||||||
|
|
||||||
if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
|
if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
|
||||||
perror ("opening UDP socket");
|
perror ("opening UDP socket");
|
||||||
|
@ -104,8 +104,9 @@ namespace gr
|
||||||
ret = recvfrom (sock, buf, d_mtu, 0, &client_addr, &client_addr_len);
|
ret = recvfrom (sock, buf, d_mtu, 0, &client_addr, &client_addr_len);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
bytes_num = (uint32_t) ret;
|
bytes_num = (uint32_t) ret;
|
||||||
if (bytes_num == (sizeof(loratap_header_t)+sizeof(loraphy_header_t)+ d_payload_len)) {
|
if (bytes_num
|
||||||
pmt::pmt_t lora_tap;
|
== (sizeof(loratap_header_t) + sizeof(loraphy_header_t)
|
||||||
|
+ d_payload_len)) {
|
||||||
lora_tap = pmt::make_blob (buf, bytes_num);
|
lora_tap = pmt::make_blob (buf, bytes_num);
|
||||||
message_port_pub (pmt::mp ("out"), lora_tap);
|
message_port_pub (pmt::mp ("out"), lora_tap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ namespace gr
|
||||||
const size_t d_mtu;
|
const size_t d_mtu;
|
||||||
const size_t d_payload_len;
|
const size_t d_payload_len;
|
||||||
bool d_running;
|
bool d_running;
|
||||||
int d_layer;
|
|
||||||
boost::shared_ptr<boost::thread> d_thread;
|
boost::shared_ptr<boost::thread> d_thread;
|
||||||
|
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue