diff options
author | Fede85 <f.vanzati@gmail.com> | 2013-09-06 15:38:07 +0200 |
---|---|---|
committer | Fede85 <f.vanzati@gmail.com> | 2013-09-06 15:38:07 +0200 |
commit | a3e2e68e2b7edb9f5434734bed4001df1e65451c (patch) | |
tree | d4ef938bd8179a15d41b19197c51ca0a7f93936f /libraries/Bridge/YunServer.cpp | |
parent | 35f10e412f5d00027f9d7f2036243c681dbec406 (diff) |
Bridge library to the 1.5 format
Diffstat (limited to 'libraries/Bridge/YunServer.cpp')
-rw-r--r-- | libraries/Bridge/YunServer.cpp | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/libraries/Bridge/YunServer.cpp b/libraries/Bridge/YunServer.cpp deleted file mode 100644 index 3473ce8..0000000 --- a/libraries/Bridge/YunServer.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright (c) 2013 Arduino LLC. All right reserved. - - 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. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include <YunServer.h> -#include <YunClient.h> - -YunServer::YunServer(uint16_t _p, BridgeClass &_b) : - bridge(_b), port(_p), listening(false), useLocalhost(false) { -} - -void YunServer::begin() { - uint8_t tmp[] = { - 'N', - (port >> 8) & 0xFF, - port & 0xFF - }; - uint8_t res[1]; - String address = F("127.0.0.1"); - if (!useLocalhost) - address = F("0.0.0.0"); - bridge.transfer(tmp, 3, (const uint8_t *)address.c_str(), address.length(), res, 1); - listening = (res[0] == 1); -} - -YunClient YunServer::accept() { - uint8_t cmd[] = {'k'}; - uint8_t res[1]; - unsigned int l = bridge.transfer(cmd, 1, res, 1); - if (l==0) - return YunClient(); - return YunClient(res[0]); -} - -size_t YunServer::write(uint8_t c) { - uint8_t cmd[] = { 'b', c }; - bridge.transfer(cmd, 2); - return 1; -} - |