diff --git a/libraries/Telnet/Telnet.cpp b/libraries/Telnet/Telnet.cpp deleted file mode 100644 index 214bdca3..00000000 --- a/libraries/Telnet/Telnet.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file Telnet.cpp - * @version 1.0 - * - * @section License - * Copyright (C) 2014-2015, Mikael Patel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * This file is part of the Arduino Che Cosa project. - */ - -#include "Telnet.hh" - -bool -Telnet::Server::begin(Socket* sock) -{ - // Sanity check parameter - if (sock == NULL) return (false); - - // Set telnet end of line mode (crlf) - sock->set_eol(IOStream::CRLF_MODE); - - // Complete the setup - return (INET::Server::begin(sock)); -} - -bool -Telnet::Server::on_accept(IOStream& ios) -{ - UNUSED(ios); - - // Sanity check server state - Socket* sock = get_socket(); - if (sock == NULL) return (false); - - // Skip first line from client; terminal settings not implemented - int res; - while ((res = sock->available()) == 0) yield(); - if (res < 0) return (false); - while (res--) sock->getchar(); - return (true); -} diff --git a/libraries/Telnet/Telnet.h b/libraries/Telnet/Telnet.h deleted file mode 100644 index 2d93045d..00000000 --- a/libraries/Telnet/Telnet.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @file Telnet.h - * @version 1.0 - * - * @section License - * Copyright (C) 2015, Mikael Patel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * This file is part of the Arduino Che Cosa project. - */ - -#ifndef COSA_TELNET_H -#define COSA_TELNET_H - -#include "Telnet.hh" - -#endif diff --git a/libraries/Telnet/Telnet.hh b/libraries/Telnet/Telnet.hh deleted file mode 100644 index 0c263fbe..00000000 --- a/libraries/Telnet/Telnet.hh +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @file Telnet.hh - * @version 1.0 - * - * @section License - * Copyright (C) 2014-2015, Mikael Patel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * This file is part of the Arduino Che Cosa project. - */ - -#ifndef COSA_TELNET_HH -#define COSA_TELNET_HH - -#include "Cosa/Types.h" -#include "Cosa/IOStream.hh" -#include "Cosa/Socket.hh" - -class Telnet { -public: - /** The Telnet server standard port. */ - static const uint16_t PORT = 23; - - /** - * Telnet server request handler. Should be sub-classed and the - * virtual member function INET::Server::on_request() should be - * implemented to receive client requests and send responses. - */ - class Server : public INET::Server { - public: - /** - * Default telnet server constructor. Must call begin() to - * initiate with socket. - * @param[in] ios associated io-stream. - */ - Server(IOStream& ios) : INET::Server(ios) {} - - /** - * @override INET::Server - * Start server with given socket. Initiates socket for incoming - * connection-oriented requests (TCP/listen). Set io-stream device - * (socket) in no echo mode. Returns true if successful otherwise - * false. - * @param[in] sock server socket. - * @return bool. - */ - virtual bool begin(Socket* sock); - - protected: - /** - * @override INET::Server - * Application extension; Called when a client connect has been - * accepted. Handle flush of telnet terminal setting on connect. - * Return true if accepted otherwise false. - * @param[in] ios iostream for response. - * @return bool. - */ - virtual bool on_accept(IOStream& ios); - }; -}; - -#endif diff --git a/libraries/Telnet/examples/CosaTelnetServer/CosaTelnetServer.ino b/libraries/Telnet/examples/CosaTelnetServer/CosaTelnetServer.ino deleted file mode 100644 index 42697dbe..00000000 --- a/libraries/Telnet/examples/CosaTelnetServer/CosaTelnetServer.ino +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @file CosaTelnetServer.ino - * @version 1.0 - * - * @section License - * Copyright (C) 2014-2015, Mikael Patel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * @section Description - * W5100 Ethernet Controller device driver example code; Use TELNET - * server port for trace stream output. Allow command "exit" and - * carriage return to toggle trace output state. In trace mode - * this sketch will print the digital and analog pin values, bandgap - * voltage (power supply voltage) and free memory to the connected - * telnet client. - * - * @section Circuit - * This sketch is designed for the Ethernet Shield. - * @code - * W5100/ethernet - * +------------+ - * (D10)--------------29-|CSN | - * (D11)--------------28-|MOSI | - * (D12)--------------27-|MISO | - * (D13)--------------30-|SCK | - * (D2)-----[ ]-------56-|IRQ | - * +------------+ - * @endcode - * - * This file is part of the Arduino Che Cosa project. - */ - -#include -#include -#include -#include - -#include "Cosa/Memory.h" -#include "Cosa/InputPin.hh" -#include "Cosa/AnalogPin.hh" -#include "Cosa/Watchdog.hh" -#include "Cosa/Trace.hh" - -// Disable SD on Ethernet Shield -#define USE_ETHERNET_SHIELD -#if defined(USE_ETHERNET_SHIELD) -#include "Cosa/OutputPin.hh" -OutputPin sd(Board::D4, 1); -#endif - -// Network configuration -#define IP 192,168,1,100 -#define SUBNET 255,255,255,0 -#define GATEWAY 192,168,1,1 - -// W5100 Ethernet Controller with MAC-address -static const uint8_t mac[6] __PROGMEM = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed }; -W5100 ethernet(mac); -Socket* sock = NULL; - -void setup() -{ - // Initiate watchdog for delay timing - Watchdog::begin(); - - // Initiate ethernet controller with address - uint8_t ip[4] = { IP }; - uint8_t subnet[4] = { SUBNET }; - ASSERT(ethernet.begin(ip, subnet)); - - // Allocate a TCP socket and listen - ASSERT((sock = ethernet.socket(Socket::TCP, Telnet::PORT)) != NULL); - ASSERT(!sock->listen()); - - // Wait for incoming connection requests - while (sock->accept() != 0) Watchdog::delay(32); - trace.begin(sock, PSTR("CosaTelnetServer: started")); - trace << flush; -} - -void loop() -{ - // Trace output state (on/off) - static bool state = true; - - // Check if a command is available - int res = sock->available(); - if (res < 0) goto error; - if (res > 0) { - char buf[32]; - if (res > (int) sizeof(buf)) res = sizeof(buf); - sock->read(buf, res); - if (res == 2) { - state = !state; - if (state) trace << PSTR("trace on"); - else trace << PSTR("trace off"); - trace << endl << flush; - } - else if (!memcmp_P(buf, PSTR("exit"), 4)) goto error; - } - - if (!state) return; - - // Trace state of device pins, power supply and free memory - trace << Watchdog::millis() << PSTR(":D="); - for (uint8_t i = 0; i < membersof(digital_pin_map); i++) { - Board::DigitalPin pin; - pin = (Board::DigitalPin) pgm_read_byte(digital_pin_map + i); - trace << InputPin::read(pin); - } - trace << PSTR(";A="); - trace << AnalogPin::sample((Board::AnalogPin) pgm_read_byte(analog_pin_map)); - for (uint8_t i = 1; i < membersof(analog_pin_map); i++) { - Board::AnalogPin pin; - pin = (Board::AnalogPin) pgm_read_byte(analog_pin_map + i); - trace << ',' << AnalogPin::sample(pin); - } - trace << PSTR(";Vcc=") << AnalogPin::bandgap(); - trace << PSTR(";mem=") << free_memory(); - trace << endl << flush; - sleep(5); - - return; - - error: - sock->disconnect(); - sock->listen(); - while (sock->accept() != 0) Watchdog::delay(32); -}