Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changes for Arduino 1.0 library interface change

commit 311156a2ea1226562875e28b40a3d164caa45ada 1 parent 981ea95
@jmr13031 authored
View
24 src/WiFly/Client.cpp
@@ -35,25 +35,43 @@ Client::Client(const char* domain, uint16_t port) :
isOpen = false;
}
-
+#if ARDUINO >= 100
+size_t Client::write(byte value) {
+#else
void Client::write(byte value) {
+#endif
/*
*/
_WiFly.uart.write(value);
+#if ARDUINO >= 100
+ return (0);
+#endif
}
-
+#if ARDUINO >= 100
+size_t Client::write(const char *str) {
+#else
void Client::write(const char *str) {
+#endif
/*
*/
_WiFly.uart.write(str);
+#if ARDUINO >= 100
+ return (0);
+#endif
}
-
+#if ARDUINO >= 100
+size_t Client::write(const uint8_t *buffer, size_t size) {
+#else
void Client::write(const uint8_t *buffer, size_t size) {
+#endif
/*
*/
_WiFly.uart.write(buffer, size);
+#if ARDUINO >= 100
+ return (0);
+#endif
}
View
6 src/WiFly/Client.h
@@ -18,9 +18,15 @@ class Client : public Print {
boolean connect();
+#if ARDUINO >= 100
+ size_t write(byte value);
+ size_t write(const char *str);
+ size_t write(const uint8_t *buffer, size_t size);
+#else
void write(byte value);
void write(const char *str);
void write(const uint8_t *buffer, size_t size);
+#endif
int available();
int read();
View
32 src/WiFly/SpiUart.cpp
@@ -157,7 +157,7 @@ byte SpiUartDevice::readRegister(byte registerAddress) {
byte SpiUartDevice::available() {
/*
-
+
Get the number of bytes (characters) available for reading.
This is data that's already arrived and stored in the receive
@@ -166,8 +166,9 @@ byte SpiUartDevice::available() {
*/
// This alternative just checks if there's data but doesn't
// return how many characters are in the buffer:
- // readRegister(LSR) & 0x01
- return readRegister(RXLVL);
+ // readRegister(LSR) & 0x01
+ delay(2);
+ return (readRegister(RXLVL));
}
@@ -188,8 +189,11 @@ int SpiUartDevice::read() {
return readRegister(RHR);
}
-
+#if ARDUINO >= 100
+size_t SpiUartDevice::write(byte value) {
+#else
void SpiUartDevice::write(byte value) {
+#endif
/*
Write byte to UART.
@@ -198,11 +202,17 @@ void SpiUartDevice::write(byte value) {
while (readRegister(TXLVL) == 0) {
// Wait for space in TX buffer
};
- writeRegister(THR, value);
+ writeRegister(THR, value);
+#if ARDUINO >= 100
+ return (0);
+#endif
}
-
+#if ARDUINO >= 100
+size_t SpiUartDevice::write(const char *str) {
+#else
void SpiUartDevice::write(const char *str) {
+#endif
/*
Write string to UART.
@@ -213,10 +223,17 @@ void SpiUartDevice::write(const char *str) {
// Wait for empty TX buffer (slow)
// (But apparently still not slow enough to ensure delivery.)
};
+#if ARDUINO >= 100
+ return (0);
+#endif
}
#if ENABLE_BULK_TRANSFERS
+#if ARDUINO >= 100
+size_t SpiUartDevice::write(const uint8_t *buffer, size_t size) {
+#else
void SpiUartDevice::write(const uint8_t *buffer, size_t size) {
+#endif
/*
Write buffer to UART.
@@ -233,6 +250,9 @@ void SpiUartDevice::write(const uint8_t *buffer, size_t size) {
transfer_bulk(buffer, size);
deselect();
+#if ARDUINO >= 100
+ return (0);
+#endif
}
#endif
View
12 src/WiFly/SpiUart.h
@@ -59,6 +59,15 @@ class SpiUartDevice : public SpiDevice, public Print {
void begin(unsigned long baudrate = BAUD_RATE_DEFAULT);
byte available();
int read();
+#if ARDUINO >= 100
+ size_t write(byte value);
+ size_t write(const char *str);
+#if ENABLE_BULK_TRANSFERS
+ size_t write(const uint8_t *buffer, size_t size);
+#else
+ using Print::write;
+#endif
+#else
void write(byte value);
void write(const char *str);
#if ENABLE_BULK_TRANSFERS
@@ -66,7 +75,8 @@ class SpiUartDevice : public SpiDevice, public Print {
#else
using Print::write;
#endif
- void flush();
+#endif
+ void flush();
// These are specific to the SPI UART
void ioSetDirection(unsigned char bits);
View
4 src/WiFly/_Spi.h
@@ -5,7 +5,11 @@
#ifndef ___SPI_H__
#define ___SPI_H__
+#if ARDUINO >= 100
+#include <Arduino.h>
+#else
#include <WProgram.h>
+#endif
#include <pins_arduino.h>
View
14 src/WiFly/examples/tools/HardwareFactoryReset/HardwareFactoryReset.pde
@@ -54,7 +54,11 @@ void readResponse(int timeOut = 0 /* millisecond */) {
int target = millis() + timeOut;
while((millis() < target) || SpiSerial.available() > 0) {
if (SpiSerial.available()) {
+#if ARDUINO >= 100
+ Serial.write(SpiSerial.read());
+#else
Serial.print(SpiSerial.read(), BYTE);
+#endif
}
}
}
@@ -158,10 +162,18 @@ void loop() {
// but note that this makes the terminal unresponsive
// while a response is being received.
while(SpiSerial.available() > 0) {
+#if ARDUINO >= 100
+ Serial.write(SpiSerial.read());
+#else
Serial.print(SpiSerial.read(), BYTE);
+#endif
}
if(Serial.available()) { // Outgoing data
+#if ARDUINO >= 100
+ SpiSerial.write(Serial.read());
+#else
SpiSerial.print(Serial.read(), BYTE);
+#endif
}
-}
+}
View
8 src/WiFly/examples/tools/SpiUartTerminal/SpiUartTerminal.pde
@@ -45,10 +45,18 @@ void loop() {
// but note that this makes the terminal unresponsive
// while a response is being received.
while(SpiSerial.available() > 0) {
+#if ARDUINO >= 100
+ Serial.write(SpiSerial.read());
+#else
Serial.print(SpiSerial.read(), BYTE);
+#endif
}
if(Serial.available()) { // Outgoing data
+#if ARDUINO >= 100
+ SpiSerial.write(Serial.read());
+#else
SpiSerial.print(Serial.read(), BYTE);
+#endif
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.