Skip to content

Commit

Permalink
Ported to Arduino 1.0 compiler.
Browse files Browse the repository at this point in the history
Includes support for size_t print functions (not void) and changed program code suffix (.pde to .ino).
  • Loading branch information
Joe Touch committed Dec 16, 2011
1 parent 8a1a9e3 commit 23f701c
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 23 deletions.
4 changes: 4 additions & 0 deletions README
Expand Up @@ -3,6 +3,10 @@ WiShield library and TCP/IP stack files for the WiShield 1.0 wireless devices
Async Labs Inc. Async Labs Inc.
www.asynclabs.com www.asynclabs.com


-------------------------------------------------------------------------------
Changes:
- updated to support Ardunino compiler 1.0 (from 0023)

------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Version 1.2.0 Version 1.2.0
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Expand Down
45 changes: 29 additions & 16 deletions WiServer.cpp
Expand Up @@ -31,11 +31,13 @@
multi-pass transmission, local client multi-pass transmission, local client
checks, activity LED support, etc. checks, activity LED support, etc.
Joe Touch 12/14/2011 Ported to arduino-1.0 compiler
*****************************************************************************/ *****************************************************************************/




#include "WProgram.h" #include "Arduino.h"
#include "WiServer.h" #include "WiServer.h"


extern "C" { extern "C" {
Expand Down Expand Up @@ -154,55 +156,64 @@ void setRXPin(byte value) {
/******* Generic printing and sending functions ********/ /******* Generic printing and sending functions ********/




void Server::write_P(const char data[], int len) { size_t Server::write_P(const char data[], int len) {
while (len-- > 0) { while (len-- > 0) {
this->write(pgm_read_byte(data++)); this->write(pgm_read_byte(data++));
} }
return len;
} }




void Server::print_P(const char s[]) { size_t Server::print_P(const char s[]) {
char c = pgm_read_byte(s); char c = pgm_read_byte(s);
size_t count = 0;
while (c) { while (c) {
this->print(c); this->print(c);
c = pgm_read_byte(++s); c = pgm_read_byte(++s);
count++;
} }
return count;
} }




void Server::println_P(const char c[]) { size_t Server::println_P(const char c[]) {
this->print_P(c); size_t count = 0;
this->println(); count += this->print_P(c);
count += this->println();
return count;
} }






void Server::printTime(long t) { size_t Server::printTime(long t) {
size_t count = 0;


long secs = t / 1000; long secs = t / 1000;
int mins = (int)(secs / 60); int mins = (int)(secs / 60);
int hours = mins / 60; int hours = mins / 60;


hours %= 24; hours %= 24;
this->print(hours / 10); count += this->print(hours / 10);
this->print(hours % 10); count += this->print(hours % 10);
this->print(':'); count += this->print(':');


mins %= 60; mins %= 60;
this->print(mins / 10); count += this->print(mins / 10);
this->print(mins % 10); count += this->print(mins % 10);
this->print(':'); count += this->print(':');


secs %= 60; secs %= 60;
this->print(secs / 10); count += this->print(secs / 10);
this->print(secs % 10); count += this->print(secs % 10);

return count;
} }




/* /*
* Writes a byte to the virtual buffer for the current connection * Writes a byte to the virtual buffer for the current connection
*/ */
void Server::write(uint8_t b) { size_t Server::write(uint8_t b) {


// Make sure there's a current connection // Make sure there's a current connection
if (uip_conn) { if (uip_conn) {
Expand All @@ -212,8 +223,10 @@ void Server::write(uint8_t b) {
if ((offset >= 0) && (offset < (int)uip_conn->mss)) { if ((offset >= 0) && (offset < (int)uip_conn->mss)) {
// Write the byte to the corresponding location in the buffer // Write the byte to the corresponding location in the buffer
*((char*)uip_appdata + offset) = b; *((char*)uip_appdata + offset) = b;
return 1;
} }
} }
return 0;
} }




Expand Down
12 changes: 7 additions & 5 deletions WiServer.h
Expand Up @@ -33,6 +33,8 @@
Mark A. Patel 06/22/2009 Revised client API Mark A. Patel 06/22/2009 Revised client API
Joe Touch 12/14/2011 port to arduino-1.0 compiler
*****************************************************************************/ *****************************************************************************/


Expand Down Expand Up @@ -188,28 +190,28 @@ class Server: public Print
/** /**
* Writes a single byte to the current connection buffer * Writes a single byte to the current connection buffer
*/ */
virtual void write(uint8_t); virtual size_t write(uint8_t);


/** /**
* Prints a string that is stored in program memory * Prints a string that is stored in program memory
*/ */
void print_P(const char[]); size_t print_P(const char[]);


/** /**
* Prints a string that is stored in program memory followed by a line feed * Prints a string that is stored in program memory followed by a line feed
*/ */
void println_P(const char[]); size_t println_P(const char[]);


/** /**
* Writes data of a specified length that is stored in program memory * Writes data of a specified length that is stored in program memory
*/ */
void write_P(const char[], int len); size_t write_P(const char[], int len);


/** /**
* Prints a time value in the form HH:MM:SS. The time value is in milliseconds. * Prints a time value in the form HH:MM:SS. The time value is in milliseconds.
* *
*/ */
void printTime(long t); size_t printTime(long t);


/** /**
* Indicates if a page is currently being sent, and that a subsequent call to the page * Indicates if a page is currently being sent, and that a subsequent call to the page
Expand Down
3 changes: 2 additions & 1 deletion WiShield.cpp
Expand Up @@ -30,6 +30,7 @@
--------------------------------------------------------------- ---------------------------------------------------------------
AsyncLabs 05/01/2009 Initial version AsyncLabs 05/01/2009 Initial version
AsyncLabs 05/29/2009 Adding support for new library AsyncLabs 05/29/2009 Adding support for new library
Joe Touch 12/14/2011 Ported to arduino-1.0 compiler
*****************************************************************************/ *****************************************************************************/


Expand All @@ -43,7 +44,7 @@ extern "C" {
void stack_process(void); void stack_process(void);
} }


#include "WProgram.h" #include "Arduino.h"
#include "WiShield.h" #include "WiShield.h"


boolean WiShield::init(U8 seconds) boolean WiShield::init(U8 seconds)
Expand Down
5 changes: 4 additions & 1 deletion clock-arch.c
Expand Up @@ -30,6 +30,9 @@
--------------------------------------------------------------- ---------------------------------------------------------------
AsyncLabs 05/29/2009 Initial port AsyncLabs 05/29/2009 Initial port
Joe Touch 12/14/2011 ported to arduino-1.0 compiler
*****************************************************************************/ *****************************************************************************/


#include "global-conf.h" #include "global-conf.h"
Expand All @@ -41,7 +44,7 @@
#include <avr/sfr_defs.h> #include <avr/sfr_defs.h>


#include "clock-arch.h" #include "clock-arch.h"
#include "wiring.h" #include "Arduino.h"


#if 0 #if 0
//Counted time //Counted time
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 23f701c

Please sign in to comment.