Some quick code to use UDP-only (no TCP) with mBed. Echos received packets and sends packets when a button is pressed
TCPItem.cpp
00001 #include "TCPItem.h" 00002 00003 using namespace std; 00004 using namespace mbed; 00005 00006 void TCPItem::abort() const { 00007 tcp_abort(this->_pcb); 00008 } 00009 00010 void TCPItem::release_callbacks() const { 00011 tcp_arg(this->_pcb, NULL); 00012 tcp_sent(this->_pcb, NULL); 00013 tcp_recv(this->_pcb, NULL); 00014 tcp_poll(this->_pcb, NULL, 255); 00015 tcp_accept(this->_pcb, NULL); 00016 tcp_err(this->_pcb, NULL); 00017 } 00018 00019 err_t TCPItem::close() { 00020 err_t err = tcp_close(this->_pcb); 00021 this->_pcb = NULL; 00022 return err; 00023 } 00024 00025 void TCPItem::open() { 00026 if(!this->_pcb) { 00027 this->_pcb = tcp_new(); 00028 tcp_arg(this->_pcb, this); 00029 } 00030 }
Generated on Tue Jul 12 2022 19:17:24 by 1.7.2