First attempt at some form of autodiscovery of an mbed based device by periodically broadcasting our IP in a UDP packet.

Dependencies:   mbed

BroadcastMessage.cpp

Committer:
darran
Date:
2010-06-18
Revision:
0:c1be031ca851

File content as of revision 0:c1be031ca851:

#include "BroadcastMessage.h"

BroadcastMessage::BroadcastMessage() {
}

BroadcastMessage::~BroadcastMessage() {
}

void BroadcastMessage::init() {
    NetIf* netIf = Net::getDefaultIf();
    IpAddr ip = netIf->getIp();
    len = sprintf(buff, 
        "mbed microcontroller\r\n"
        "IP: %d.%d.%d.%d!\r\n"
        "Service: CANWIFI\r\n",
        ip[0], ip[1], ip[2], ip[3]
    );
}

char* BroadcastMessage::getBytes() {
    return buff;
}

int BroadcastMessage::getLength() {
    return len;
}