Control of mbed using OSC. Based on code from the Make Controller. Right now you can turn the onboard LEDs on/off and toggle 8 digital out pins. More I/O will be done in the future.

Dependencies:   mbed

lwip/TCPListener.cpp

Committer:
pehrhovey
Date:
2010-03-17
Revision:
0:439354122597

File content as of revision 0:439354122597:

#include "TCPListener.h"
#include "NetServer.h"

using namespace std;
using namespace mbed;

err_t TCPListener::accept_callback(void *arg, struct tcp_pcb *newpcb, err_t err) {
  TCPListener *listener   = static_cast<TCPListener *>(arg);
  if(listener) {
    return (listener->accept)(newpcb, err);
  }
  return ERR_OK;
}

void TCPListener::bind() {
  NetServer::ready();
  open();
  tcp_arg(this->_pcb, static_cast<void *>(this));
  if(tcp_bind(this->_pcb, IP_ADDR_ANY, this->_port) == ERR_OK) {
    this->_pcb = tcp_listen(this->_pcb);
    tcp_accept(this->_pcb, TCPListener::accept_callback);
  }
}