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

Committer:
pehrhovey
Date:
Wed Mar 17 03:17:38 2010 +0000
Revision:
0:439354122597

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pehrhovey 0:439354122597 1 #include "TCPListener.h"
pehrhovey 0:439354122597 2 #include "NetServer.h"
pehrhovey 0:439354122597 3
pehrhovey 0:439354122597 4 using namespace std;
pehrhovey 0:439354122597 5 using namespace mbed;
pehrhovey 0:439354122597 6
pehrhovey 0:439354122597 7 err_t TCPListener::accept_callback(void *arg, struct tcp_pcb *newpcb, err_t err) {
pehrhovey 0:439354122597 8 TCPListener *listener = static_cast<TCPListener *>(arg);
pehrhovey 0:439354122597 9 if(listener) {
pehrhovey 0:439354122597 10 return (listener->accept)(newpcb, err);
pehrhovey 0:439354122597 11 }
pehrhovey 0:439354122597 12 return ERR_OK;
pehrhovey 0:439354122597 13 }
pehrhovey 0:439354122597 14
pehrhovey 0:439354122597 15 void TCPListener::bind() {
pehrhovey 0:439354122597 16 NetServer::ready();
pehrhovey 0:439354122597 17 open();
pehrhovey 0:439354122597 18 tcp_arg(this->_pcb, static_cast<void *>(this));
pehrhovey 0:439354122597 19 if(tcp_bind(this->_pcb, IP_ADDR_ANY, this->_port) == ERR_OK) {
pehrhovey 0:439354122597 20 this->_pcb = tcp_listen(this->_pcb);
pehrhovey 0:439354122597 21 tcp_accept(this->_pcb, TCPListener::accept_callback);
pehrhovey 0:439354122597 22 }
pehrhovey 0:439354122597 23 }