Add single byte 'print' function to send data. The name is to match the 'Serial.print' function. TODO: Print strings etc? Change demo to echo data received to sender.

git-svn-id: svn+ssh://oldsvn/home/mlalondesvn/svn/cral@115 3ee9b42a-b53c-0410-a25e-f0b6218d5d5b
master
follower 17 years ago
parent 7d38f68179
commit 4f372c3010

@ -228,6 +228,7 @@ class NetworkConnection { // Essentially a Socket wrapper
int isConnected();
int available();
int read();
void print(uint8_t);
void NetworkConnection::close();
private:
@ -311,6 +312,17 @@ int NetworkConnection::isConnected() {
return (getSn_SR(_socket) == SOCK_ESTABLISHED);
}
void NetworkConnection::print(uint8_t b) {
/*
*/
if (isConnected()) {
send(_socket, &b, 1);
} else {
// Just drop it if we're not connected.
}
}
void NetworkConnection::close() {
/*
@ -442,7 +454,8 @@ void setup () {
while (conn.isConnected()) {
if (conn.available()) {
Serial.print(conn.read(), BYTE);
// Serial.print(conn.read(), BYTE);
conn.print(conn.read());
}
}

Loading…
Cancel
Save