ESP32  1.0.4
AsyncUDP クラス

#include <AsyncUDP.h>

AsyncUDP の継承関係図
Print

公開メンバ関数

 AsyncUDP ()
 
virtual ~AsyncUDP ()
 
void onPacket (AuPacketHandlerFunctionWithArg cb, void *arg=NULL)
 
void onPacket (AuPacketHandlerFunction cb)
 
bool listen (const ip_addr_t *addr, uint16_t port)
 
bool listen (const IPAddress addr, uint16_t port)
 
bool listen (const IPv6Address addr, uint16_t port)
 
bool listen (uint16_t port)
 
bool listenMulticast (const ip_addr_t *addr, uint16_t port, uint8_t ttl=1, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
bool listenMulticast (const IPAddress addr, uint16_t port, uint8_t ttl=1, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
bool listenMulticast (const IPv6Address addr, uint16_t port, uint8_t ttl=1, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
bool connect (const ip_addr_t *addr, uint16_t port)
 
bool connect (const IPAddress addr, uint16_t port)
 
bool connect (const IPv6Address addr, uint16_t port)
 
void close ()
 
size_t writeTo (const uint8_t *data, size_t len, const ip_addr_t *addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
size_t writeTo (const uint8_t *data, size_t len, const IPAddress addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
size_t writeTo (const uint8_t *data, size_t len, const IPv6Address addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
size_t write (const uint8_t *data, size_t len)
 
size_t write (uint8_t data)
 
size_t broadcastTo (uint8_t *data, size_t len, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
size_t broadcastTo (const char *data, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
size_t broadcast (uint8_t *data, size_t len)
 
size_t broadcast (const char *data)
 
size_t sendTo (AsyncUDPMessage &message, const ip_addr_t *addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
size_t sendTo (AsyncUDPMessage &message, const IPAddress addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
size_t sendTo (AsyncUDPMessage &message, const IPv6Address addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
size_t send (AsyncUDPMessage &message)
 
size_t broadcastTo (AsyncUDPMessage &message, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
 
size_t broadcast (AsyncUDPMessage &message)
 
IPAddress listenIP ()
 
IPv6Address listenIPv6 ()
 
bool connected ()
 
 operator bool ()
 
- 基底クラス Print に属する継承公開メンバ関数
 Print ()
 
virtual ~Print ()
 
int getWriteError ()
 
void clearWriteError ()
 
size_t write (const char *str)
 
size_t write (const char *buffer, size_t size)
 
size_t printf (const char *format,...) __attribute__((format(printf
 
size_t size_t print (const __FlashStringHelper *)
 
size_t print (const String &)
 
size_t print (const char[])
 
size_t print (char)
 
size_t print (unsigned char, int=DEC)
 
size_t print (int, int=DEC)
 
size_t print (unsigned int, int=DEC)
 
size_t print (long, int=DEC)
 
size_t print (unsigned long, int=DEC)
 
size_t print (double, int=2)
 
size_t print (const Printable &)
 
size_t print (struct tm *timeinfo, const char *format=NULL)
 
size_t println (const __FlashStringHelper *)
 
size_t println (const String &s)
 
size_t println (const char[])
 
size_t println (char)
 
size_t println (unsigned char, int=DEC)
 
size_t println (int, int=DEC)
 
size_t println (unsigned int, int=DEC)
 
size_t println (long, int=DEC)
 
size_t println (unsigned long, int=DEC)
 
size_t println (double, int=2)
 
size_t println (const Printable &)
 
size_t println (struct tm *timeinfo, const char *format=NULL)
 
size_t println (void)
 

静的公開メンバ関数

static void _s_recv (void *arg, udp_pcb *upcb, pbuf *p, const ip_addr_t *addr, uint16_t port, struct netif *netif)
 

限定公開メンバ関数

bool _init ()
 
void _recv (udp_pcb *upcb, pbuf *pb, const ip_addr_t *addr, uint16_t port, struct netif *netif)
 
- 基底クラス Print に属する継承限定公開メンバ関数
void setWriteError (int err=1)
 

限定公開変数類

udp_pcb * _pcb
 
bool _connected
 
AuPacketHandlerFunction _handler
 

詳解

AsyncUDP.h92 行目に定義があります。

構築子と解体子

◆ AsyncUDP()

AsyncUDP::AsyncUDP ( )

AsyncUDP.cpp478 行目に定義があります。

479 {
480  _pcb = NULL;
481  _connected = false;
482  _handler = NULL;
483 }
#define NULL
Definition: def.h:70
bool _connected
Definition: AsyncUDP.h:97
AuPacketHandlerFunction _handler
Definition: AsyncUDP.h:98
udp_pcb * _pcb
Definition: AsyncUDP.h:95

◆ ~AsyncUDP()

AsyncUDP::~AsyncUDP ( )
virtual

AsyncUDP.cpp485 行目に定義があります。

486 {
487  close();
488  UDP_MUTEX_LOCK();
489  udp_recv(_pcb, NULL, NULL);
490  _udp_remove(_pcb);
491  _pcb = NULL;
493  //vSemaphoreDelete(_lock);
494 }
void close()
Definition: AsyncUDP.cpp:496
#define UDP_MUTEX_UNLOCK()
Definition: AsyncUDP.cpp:218
#define NULL
Definition: def.h:70
#define UDP_MUTEX_LOCK()
Definition: AsyncUDP.cpp:217
udp_pcb * _pcb
Definition: AsyncUDP.h:95

関数詳解

◆ _init()

bool AsyncUDP::_init ( )
protected

AsyncUDP.cpp465 行目に定義があります。

465  {
466  if(_pcb){
467  return true;
468  }
469  _pcb = udp_new();
470  if(!_pcb){
471  return false;
472  }
473  //_lock = xSemaphoreCreateMutex();
474  udp_recv(_pcb, &_udp_recv, (void *) this);
475  return true;
476 }
udp_pcb * _pcb
Definition: AsyncUDP.h:95

◆ _recv()

void AsyncUDP::_recv ( udp_pcb *  upcb,
pbuf pb,
const ip_addr_t addr,
uint16_t  port,
struct netif netif 
)
protected

AsyncUDP.cpp676 行目に定義があります。

677 {
678  while(pb != NULL) {
679  pbuf * this_pb = pb;
680  pb = pb->next;
681  this_pb->next = NULL;
682  if(_handler) {
683  AsyncUDPPacket packet(this, this_pb, addr, port, netif);
684  _handler(packet);
685  } else {
686  pbuf_free(this_pb);
687  }
688  }
689 }
struct pbuf * next
Definition: pbuf.h:144
u8_t pbuf_free(struct pbuf *p)
#define NULL
Definition: def.h:70
AuPacketHandlerFunction _handler
Definition: AsyncUDP.h:98
Definition: pbuf.h:142
Definition: netif.h:235
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208

◆ _s_recv()

void AsyncUDP::_s_recv ( void *  arg,
udp_pcb *  upcb,
pbuf p,
const ip_addr_t addr,
uint16_t  port,
struct netif netif 
)
static

AsyncUDP.cpp691 行目に定義があります。

692 {
693  reinterpret_cast<AsyncUDP*>(arg)->_recv(upcb, p, addr, port, netif);
694 }
Definition: netif.h:235
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208

◆ broadcast() [1/3]

size_t AsyncUDP::broadcast ( uint8_t data,
size_t  len 
)

AsyncUDP.cpp801 行目に定義があります。

802 {
803  if(_pcb->local_port != 0) {
804  return broadcastTo(data, len, _pcb->local_port);
805  }
806  return 0;
807 }
size_t broadcastTo(uint8_t *data, size_t len, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:791
udp_pcb * _pcb
Definition: AsyncUDP.h:95

◆ broadcast() [2/3]

size_t AsyncUDP::broadcast ( const char *  data)

AsyncUDP.cpp809 行目に定義があります。

810 {
811  return broadcast((uint8_t *)data, strlen(data));
812 }
size_t broadcast(uint8_t *data, size_t len)
Definition: AsyncUDP.cpp:801
__uint8_t uint8_t
Definition: stdint.h:21

◆ broadcast() [3/3]

size_t AsyncUDP::broadcast ( AsyncUDPMessage message)

AsyncUDP.cpp855 行目に定義があります。

856 {
857  if(!message) {
858  return 0;
859  }
860  return broadcast(message.data(), message.length());
861 }
size_t broadcast(uint8_t *data, size_t len)
Definition: AsyncUDP.cpp:801
uint8_t * data()
Definition: AsyncUDP.cpp:265
size_t length()
Definition: AsyncUDP.cpp:270

◆ broadcastTo() [1/3]

size_t AsyncUDP::broadcastTo ( uint8_t data,
size_t  len,
uint16_t  port,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp791 行目に定義があります。

792 {
793  return writeTo(data, len, IP_ADDR_BROADCAST, port, tcpip_if);
794 }
size_t writeTo(const uint8_t *data, size_t len, const ip_addr_t *addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:636

◆ broadcastTo() [2/3]

size_t AsyncUDP::broadcastTo ( const char *  data,
uint16_t  port,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp796 行目に定義があります。

797 {
798  return broadcastTo((uint8_t *)data, strlen(data), port, tcpip_if);
799 }
size_t broadcastTo(uint8_t *data, size_t len, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:791
__uint8_t uint8_t
Definition: stdint.h:21

◆ broadcastTo() [3/3]

size_t AsyncUDP::broadcastTo ( AsyncUDPMessage message,
uint16_t  port,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp847 行目に定義があります。

848 {
849  if(!message) {
850  return 0;
851  }
852  return broadcastTo(message.data(), message.length(), port, tcpip_if);
853 }
size_t broadcastTo(uint8_t *data, size_t len, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:791
uint8_t * data()
Definition: AsyncUDP.cpp:265
size_t length()
Definition: AsyncUDP.cpp:270

◆ close()

void AsyncUDP::close ( )

AsyncUDP.cpp496 行目に定義があります。

497 {
498  UDP_MUTEX_LOCK();
499  if(_pcb != NULL) {
500  if(_connected) {
501  _udp_disconnect(_pcb);
502  }
503  _connected = false;
504  //todo: unjoin multicast group
505  }
507 }
#define UDP_MUTEX_UNLOCK()
Definition: AsyncUDP.cpp:218
#define NULL
Definition: def.h:70
bool _connected
Definition: AsyncUDP.h:97
#define UDP_MUTEX_LOCK()
Definition: AsyncUDP.cpp:217
udp_pcb * _pcb
Definition: AsyncUDP.h:95

◆ connect() [1/3]

bool AsyncUDP::connect ( const ip_addr_t addr,
uint16_t  port 
)

AsyncUDP.cpp509 行目に定義があります。

510 {
511  if(!_udp_task_start()){
512  log_e("failed to start task");
513  return false;
514  }
515  if(!_init()) {
516  return false;
517  }
518  close();
519  UDP_MUTEX_LOCK();
520  err_t err = _udp_connect(_pcb, addr, port);
521  if(err != ERR_OK) {
523  return false;
524  }
525  _connected = true;
527  return true;
528 }
void close()
Definition: AsyncUDP.cpp:496
#define UDP_MUTEX_UNLOCK()
Definition: AsyncUDP.cpp:218
bool _connected
Definition: AsyncUDP.h:97
#define UDP_MUTEX_LOCK()
Definition: AsyncUDP.cpp:217
bool _init()
Definition: AsyncUDP.cpp:465
#define log_e(format,...)
s8_t err_t
Definition: err.h:57
Definition: err.h:63
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
udp_pcb * _pcb
Definition: AsyncUDP.h:95

◆ connect() [2/3]

bool AsyncUDP::connect ( const IPAddress  addr,
uint16_t  port 
)

AsyncUDP.cpp717 行目に定義があります。

718 {
719  ip_addr_t daddr;
720  daddr.type = IPADDR_TYPE_V4;
721  daddr.u_addr.ip4.addr = addr;
722  return connect(&daddr, port);
723 }
bool connect(const ip_addr_t *addr, uint16_t port)
Definition: AsyncUDP.cpp:509
ip6_addr_t ip_addr_t
Definition: ip_addr.h:295
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208

◆ connect() [3/3]

bool AsyncUDP::connect ( const IPv6Address  addr,
uint16_t  port 
)

AsyncUDP.cpp757 行目に定義があります。

758 {
759  ip_addr_t daddr;
760  daddr.type = IPADDR_TYPE_V6;
761  memcpy((uint8_t*)(daddr.u_addr.ip6.addr), (const uint8_t*)addr, 16);
762  return connect(&daddr, port);
763 }
bool connect(const ip_addr_t *addr, uint16_t port)
Definition: AsyncUDP.cpp:509
ip6_addr_t ip_addr_t
Definition: ip_addr.h:295
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
__uint8_t uint8_t
Definition: stdint.h:21

◆ connected()

bool AsyncUDP::connected ( )

AsyncUDP.cpp868 行目に定義があります。

869 {
870  return _connected;
871 }
bool _connected
Definition: AsyncUDP.h:97

◆ listen() [1/4]

bool AsyncUDP::listen ( const ip_addr_t addr,
uint16_t  port 
)

AsyncUDP.cpp530 行目に定義があります。

531 {
532  if(!_udp_task_start()){
533  log_e("failed to start task");
534  return false;
535  }
536  if(!_init()) {
537  return false;
538  }
539  close();
540  if(addr){
541  IP_SET_TYPE_VAL(_pcb->local_ip, addr->type);
542  IP_SET_TYPE_VAL(_pcb->remote_ip, addr->type);
543  }
544  UDP_MUTEX_LOCK();
545  if(_udp_bind(_pcb, addr, port) != ERR_OK) {
547  return false;
548  }
549  _connected = true;
551  return true;
552 }
void close()
Definition: AsyncUDP.cpp:496
#define UDP_MUTEX_UNLOCK()
Definition: AsyncUDP.cpp:218
bool _connected
Definition: AsyncUDP.h:97
#define UDP_MUTEX_LOCK()
Definition: AsyncUDP.cpp:217
bool _init()
Definition: AsyncUDP.cpp:465
#define IP_SET_TYPE_VAL(ipaddr, iptype)
Definition: ip_addr.h:303
#define log_e(format,...)
Definition: err.h:63
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
udp_pcb * _pcb
Definition: AsyncUDP.h:95

◆ listen() [2/4]

bool AsyncUDP::listen ( const IPAddress  addr,
uint16_t  port 
)

AsyncUDP.cpp701 行目に定義があります。

702 {
703  ip_addr_t laddr;
704  laddr.type = IPADDR_TYPE_V4;
705  laddr.u_addr.ip4.addr = addr;
706  return listen(&laddr, port);
707 }
bool listen(const ip_addr_t *addr, uint16_t port)
Definition: AsyncUDP.cpp:530
ip6_addr_t ip_addr_t
Definition: ip_addr.h:295
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208

◆ listen() [3/4]

bool AsyncUDP::listen ( const IPv6Address  addr,
uint16_t  port 
)

AsyncUDP.cpp741 行目に定義があります。

742 {
743  ip_addr_t laddr;
744  laddr.type = IPADDR_TYPE_V6;
745  memcpy((uint8_t*)(laddr.u_addr.ip6.addr), (const uint8_t*)addr, 16);
746  return listen(&laddr, port);
747 }
bool listen(const ip_addr_t *addr, uint16_t port)
Definition: AsyncUDP.cpp:530
ip6_addr_t ip_addr_t
Definition: ip_addr.h:295
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
__uint8_t uint8_t
Definition: stdint.h:21

◆ listen() [4/4]

bool AsyncUDP::listen ( uint16_t  port)

AsyncUDP.cpp696 行目に定義があります。

697 {
698  return listen(IP_ANY_TYPE, port);
699 }
bool listen(const ip_addr_t *addr, uint16_t port)
Definition: AsyncUDP.cpp:530
#define IP_ANY_TYPE
Definition: ip_addr.h:405

◆ listenIP()

IPAddress AsyncUDP::listenIP ( )

AsyncUDP.cpp733 行目に定義があります。

734 {
735  if(!_pcb || _pcb->remote_ip.type != IPADDR_TYPE_V4){
736  return IPAddress();
737  }
738  return IPAddress(_pcb->remote_ip.u_addr.ip4.addr);
739 }
udp_pcb * _pcb
Definition: AsyncUDP.h:95

◆ listenIPv6()

IPv6Address AsyncUDP::listenIPv6 ( )

AsyncUDP.cpp773 行目に定義があります。

774 {
775  if(!_pcb || _pcb->remote_ip.type != IPADDR_TYPE_V6){
776  return IPv6Address();
777  }
778  return IPv6Address(_pcb->remote_ip.u_addr.ip6.addr);
779 }
udp_pcb * _pcb
Definition: AsyncUDP.h:95

◆ listenMulticast() [1/3]

bool AsyncUDP::listenMulticast ( const ip_addr_t addr,
uint16_t  port,
uint8_t  ttl = 1,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp612 行目に定義があります。

613 {
614  if(!ip_addr_ismulticast(addr)) {
615  return false;
616  }
617 
618  if (joinMulticastGroup(addr, true, tcpip_if)!= ERR_OK) {
619  return false;
620  }
621 
622  if(!listen(NULL, port)) {
623  return false;
624  }
625 
626  UDP_MUTEX_LOCK();
627  _pcb->mcast_ttl = ttl;
628  _pcb->remote_port = port;
629  ip_addr_copy(_pcb->remote_ip, *addr);
630  //ip_addr_copy(_pcb->remote_ip, ip_addr_any_type);
632 
633  return true;
634 }
#define UDP_MUTEX_UNLOCK()
Definition: AsyncUDP.cpp:218
#define NULL
Definition: def.h:70
bool listen(const ip_addr_t *addr, uint16_t port)
Definition: AsyncUDP.cpp:530
#define UDP_MUTEX_LOCK()
Definition: AsyncUDP.cpp:217
#define ip_addr_ismulticast(ipaddr)
Definition: ip_addr.h:327
#define ip_addr_copy(dest, src)
Definition: ip_addr.h:310
Definition: err.h:63
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
udp_pcb * _pcb
Definition: AsyncUDP.h:95

◆ listenMulticast() [2/3]

bool AsyncUDP::listenMulticast ( const IPAddress  addr,
uint16_t  port,
uint8_t  ttl = 1,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp709 行目に定義があります。

710 {
711  ip_addr_t laddr;
712  laddr.type = IPADDR_TYPE_V4;
713  laddr.u_addr.ip4.addr = addr;
714  return listenMulticast(&laddr, port, ttl, tcpip_if);
715 }
bool listenMulticast(const ip_addr_t *addr, uint16_t port, uint8_t ttl=1, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:612
ip6_addr_t ip_addr_t
Definition: ip_addr.h:295
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208

◆ listenMulticast() [3/3]

bool AsyncUDP::listenMulticast ( const IPv6Address  addr,
uint16_t  port,
uint8_t  ttl = 1,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp749 行目に定義があります。

750 {
751  ip_addr_t laddr;
752  laddr.type = IPADDR_TYPE_V6;
753  memcpy((uint8_t*)(laddr.u_addr.ip6.addr), (const uint8_t*)addr, 16);
754  return listenMulticast(&laddr, port, ttl, tcpip_if);
755 }
bool listenMulticast(const ip_addr_t *addr, uint16_t port, uint8_t ttl=1, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:612
ip6_addr_t ip_addr_t
Definition: ip_addr.h:295
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
__uint8_t uint8_t
Definition: stdint.h:21

◆ onPacket() [1/2]

void AsyncUDP::onPacket ( AuPacketHandlerFunctionWithArg  cb,
void *  arg = NULL 
)

AsyncUDP.cpp873 行目に定義があります。

874 {
875  onPacket(std::bind(cb, arg, std::placeholders::_1));
876 }
void onPacket(AuPacketHandlerFunctionWithArg cb, void *arg=NULL)
Definition: AsyncUDP.cpp:873
ASIO_DECL int bind(socket_type s, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)

◆ onPacket() [2/2]

void AsyncUDP::onPacket ( AuPacketHandlerFunction  cb)

AsyncUDP.cpp878 行目に定義があります。

879 {
880  _handler = cb;
881 }
AuPacketHandlerFunction _handler
Definition: AsyncUDP.h:98

◆ operator bool()

AsyncUDP::operator bool ( )

AsyncUDP.cpp863 行目に定義があります。

864 {
865  return _connected;
866 }
bool _connected
Definition: AsyncUDP.h:97

◆ send()

size_t AsyncUDP::send ( AsyncUDPMessage message)

AsyncUDP.cpp839 行目に定義があります。

840 {
841  if(!message) {
842  return 0;
843  }
844  return writeTo(message.data(), message.length(), &(_pcb->remote_ip), _pcb->remote_port);
845 }
size_t writeTo(const uint8_t *data, size_t len, const ip_addr_t *addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:636
uint8_t * data()
Definition: AsyncUDP.cpp:265
udp_pcb * _pcb
Definition: AsyncUDP.h:95
size_t length()
Definition: AsyncUDP.cpp:270

◆ sendTo() [1/3]

size_t AsyncUDP::sendTo ( AsyncUDPMessage message,
const ip_addr_t addr,
uint16_t  port,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp815 行目に定義があります。

816 {
817  if(!message) {
818  return 0;
819  }
820  return writeTo(message.data(), message.length(), addr, port, tcpip_if);
821 }
size_t writeTo(const uint8_t *data, size_t len, const ip_addr_t *addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:636
uint8_t * data()
Definition: AsyncUDP.cpp:265
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
size_t length()
Definition: AsyncUDP.cpp:270

◆ sendTo() [2/3]

size_t AsyncUDP::sendTo ( AsyncUDPMessage message,
const IPAddress  addr,
uint16_t  port,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp823 行目に定義があります。

824 {
825  if(!message) {
826  return 0;
827  }
828  return writeTo(message.data(), message.length(), addr, port, tcpip_if);
829 }
size_t writeTo(const uint8_t *data, size_t len, const ip_addr_t *addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:636
uint8_t * data()
Definition: AsyncUDP.cpp:265
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
size_t length()
Definition: AsyncUDP.cpp:270

◆ sendTo() [3/3]

size_t AsyncUDP::sendTo ( AsyncUDPMessage message,
const IPv6Address  addr,
uint16_t  port,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp831 行目に定義があります。

832 {
833  if(!message) {
834  return 0;
835  }
836  return writeTo(message.data(), message.length(), addr, port, tcpip_if);
837 }
size_t writeTo(const uint8_t *data, size_t len, const ip_addr_t *addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:636
uint8_t * data()
Definition: AsyncUDP.cpp:265
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
size_t length()
Definition: AsyncUDP.cpp:270

◆ write() [1/2]

size_t AsyncUDP::write ( const uint8_t data,
size_t  len 
)
virtual

Printを再実装しています。

AsyncUDP.cpp781 行目に定義があります。

782 {
783  return writeTo(data, len, &(_pcb->remote_ip), _pcb->remote_port);
784 }
size_t writeTo(const uint8_t *data, size_t len, const ip_addr_t *addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:636
udp_pcb * _pcb
Definition: AsyncUDP.h:95

◆ write() [2/2]

size_t AsyncUDP::write ( uint8_t  data)
virtual

Printを実装しています。

AsyncUDP.cpp786 行目に定義があります。

787 {
788  return write(&data, 1);
789 }
size_t write(const uint8_t *data, size_t len)
Definition: AsyncUDP.cpp:781

◆ writeTo() [1/3]

size_t AsyncUDP::writeTo ( const uint8_t data,
size_t  len,
const ip_addr_t addr,
uint16_t  port,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp636 行目に定義があります。

637 {
638  if(!_pcb) {
639  UDP_MUTEX_LOCK();
640  _pcb = udp_new();
642  if(_pcb == NULL) {
643  return 0;
644  }
645  }
646  if(len > CONFIG_TCP_MSS) {
647  len = CONFIG_TCP_MSS;
648  }
649  err_t err = ERR_OK;
650  pbuf* pbt = pbuf_alloc(PBUF_TRANSPORT, len, PBUF_RAM);
651  if(pbt != NULL) {
652  uint8_t* dst = reinterpret_cast<uint8_t*>(pbt->payload);
653  memcpy(dst, data, len);
654  UDP_MUTEX_LOCK();
655  if(tcpip_if < TCPIP_ADAPTER_IF_MAX){
656  void * nif = NULL;
658  if(!nif){
659  err = _udp_sendto(_pcb, pbt, addr, port);
660  } else {
661  err = _udp_sendto_if(_pcb, pbt, addr, port, (struct netif *)nif);
662  }
663  } else {
664  err = _udp_sendto(_pcb, pbt, addr, port);
665  }
667  pbuf_free(pbt);
668  if(err < ERR_OK) {
669  return 0;
670  }
671  return len;
672  }
673  return 0;
674 }
#define UDP_MUTEX_UNLOCK()
Definition: AsyncUDP.cpp:218
u8_t pbuf_free(struct pbuf *p)
#define NULL
Definition: def.h:70
esp_err_t tcpip_adapter_get_netif(tcpip_adapter_if_t tcpip_if, void **netif)
Get the LwIP netif* that is assigned to the interface
tcpip_adapter_if_t
Definition: pbuf.h:108
#define UDP_MUTEX_LOCK()
Definition: AsyncUDP.cpp:217
Definition: pbuf.h:142
Definition: netif.h:235
#define CONFIG_TCP_MSS
Definition: sdkconfig.h:86
s8_t err_t
Definition: err.h:57
Definition: err.h:63
void * payload
Definition: pbuf.h:147
struct pbuf * pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type)
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
__uint8_t uint8_t
Definition: stdint.h:21
udp_pcb * _pcb
Definition: AsyncUDP.h:95

◆ writeTo() [2/3]

size_t AsyncUDP::writeTo ( const uint8_t data,
size_t  len,
const IPAddress  addr,
uint16_t  port,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp725 行目に定義があります。

726 {
727  ip_addr_t daddr;
728  daddr.type = IPADDR_TYPE_V4;
729  daddr.u_addr.ip4.addr = addr;
730  return writeTo(data, len, &daddr, port, tcpip_if);
731 }
size_t writeTo(const uint8_t *data, size_t len, const ip_addr_t *addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:636
ip6_addr_t ip_addr_t
Definition: ip_addr.h:295
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208

◆ writeTo() [3/3]

size_t AsyncUDP::writeTo ( const uint8_t data,
size_t  len,
const IPv6Address  addr,
uint16_t  port,
tcpip_adapter_if_t  tcpip_if = TCPIP_ADAPTER_IF_MAX 
)

AsyncUDP.cpp765 行目に定義があります。

766 {
767  ip_addr_t daddr;
768  daddr.type = IPADDR_TYPE_V6;
769  memcpy((uint8_t*)(daddr.u_addr.ip6.addr), (const uint8_t*)addr, 16);
770  return writeTo(data, len, &daddr, port, tcpip_if);
771 }
size_t writeTo(const uint8_t *data, size_t len, const ip_addr_t *addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX)
Definition: AsyncUDP.cpp:636
ip6_addr_t ip_addr_t
Definition: ip_addr.h:295
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
__uint8_t uint8_t
Definition: stdint.h:21

メンバ詳解

◆ _connected

bool AsyncUDP::_connected
protected

AsyncUDP.h97 行目に定義があります。

◆ _handler

AuPacketHandlerFunction AsyncUDP::_handler
protected

AsyncUDP.h98 行目に定義があります。

◆ _pcb

udp_pcb* AsyncUDP::_pcb
protected

AsyncUDP.h95 行目に定義があります。


このクラス詳解は次のファイルから抽出されました: