Use bool instead of boolean in drivers (#888)

In the Arduino IDE, boolean is an alias for bool.
The Arduino IDE might deprecate boolean in the future. See
https://github.com/arduino/Arduino/issues/4673 for details.

Command:
find drivers -type f | xargs sed -i 's/boolean/bool/g'
This commit is contained in:
Mikael Falkvidd
2017-07-05 16:23:27 +02:00
committed by Patrick Fallberg
parent 4ea0c88ac8
commit a941827157
7 changed files with 54 additions and 55 deletions
-1
View File
@@ -99,7 +99,6 @@ using std::min;
using std::max; using std::max;
using std::abs; using std::abs;
typedef bool boolean;
typedef uint8_t byte; typedef uint8_t byte;
typedef string String; typedef string String;
typedef char __FlashStringHelper; typedef char __FlashStringHelper;
+3 -3
View File
@@ -152,7 +152,7 @@ long Stream::parseInt()
// this allows format characters (typically commas) in values to be ignored // this allows format characters (typically commas) in values to be ignored
long Stream::parseInt(char skipChar) long Stream::parseInt(char skipChar)
{ {
boolean isNegative = false; bool isNegative = false;
long value = 0; long value = 0;
int c; int c;
@@ -190,8 +190,8 @@ float Stream::parseFloat()
// this allows format characters (typically commas) in values to be ignored // this allows format characters (typically commas) in values to be ignored
float Stream::parseFloat(char skipChar) float Stream::parseFloat(char skipChar)
{ {
boolean isNegative = false; bool isNegative = false;
boolean isFraction = false; bool isFraction = false;
long value = 0; long value = 0;
int c; int c;
float fraction = 1.0; float fraction = 1.0;
+23 -23
View File
@@ -119,24 +119,24 @@ PubSubClient::PubSubClient(const char* domain, uint16_t port, MQTT_CALLBACK_SIGN
setStream(stream); setStream(stream);
} }
boolean PubSubClient::connect(const char *id) bool PubSubClient::connect(const char *id)
{ {
return connect(id,NULL,NULL,0,0,0,0); return connect(id,NULL,NULL,0,0,0,0);
} }
boolean PubSubClient::connect(const char *id, const char *user, const char *pass) bool PubSubClient::connect(const char *id, const char *user, const char *pass)
{ {
return connect(id,user,pass,0,0,0,0); return connect(id,user,pass,0,0,0,0);
} }
boolean PubSubClient::connect(const char *id, const char* willTopic, uint8_t willQos, bool PubSubClient::connect(const char *id, const char* willTopic, uint8_t willQos,
boolean willRetain, const char* willMessage) bool willRetain, const char* willMessage)
{ {
return connect(id,NULL,NULL,willTopic,willQos,willRetain,willMessage); return connect(id,NULL,NULL,willTopic,willQos,willRetain,willMessage);
} }
boolean PubSubClient::connect(const char *id, const char *user, const char *pass, bool PubSubClient::connect(const char *id, const char *user, const char *pass,
const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage) const char* willTopic, uint8_t willQos, bool willRetain, const char* willMessage)
{ {
if (!connected()) { if (!connected()) {
int result = 0; int result = 0;
@@ -230,7 +230,7 @@ boolean PubSubClient::connect(const char *id, const char *user, const char *pass
} }
// reads a byte into result // reads a byte into result
boolean PubSubClient::readByte(uint8_t * result) bool PubSubClient::readByte(uint8_t * result)
{ {
uint32_t previousMillis = millis(); uint32_t previousMillis = millis();
while(!_client->available()) { while(!_client->available()) {
@@ -244,7 +244,7 @@ boolean PubSubClient::readByte(uint8_t * result)
} }
// reads a byte into result[*index] and increments index // reads a byte into result[*index] and increments index
boolean PubSubClient::readByte(uint8_t * result, uint16_t * index) bool PubSubClient::readByte(uint8_t * result, uint16_t * index)
{ {
uint16_t current_index = *index; uint16_t current_index = *index;
uint8_t * write_address = &(result[current_index]); uint8_t * write_address = &(result[current_index]);
@@ -316,7 +316,7 @@ uint16_t PubSubClient::readPacket(uint8_t* lengthLength)
return len; return len;
} }
boolean PubSubClient::loop() bool PubSubClient::loop()
{ {
if (connected()) { if (connected()) {
unsigned long t = millis(); unsigned long t = millis();
@@ -382,23 +382,23 @@ boolean PubSubClient::loop()
return false; return false;
} }
boolean PubSubClient::publish(const char* topic, const char* payload) bool PubSubClient::publish(const char* topic, const char* payload)
{ {
return publish(topic,(const uint8_t*)payload,strlen(payload),false); return publish(topic,(const uint8_t*)payload,strlen(payload),false);
} }
boolean PubSubClient::publish(const char* topic, const char* payload, boolean retained) bool PubSubClient::publish(const char* topic, const char* payload, bool retained)
{ {
return publish(topic,(const uint8_t*)payload,strlen(payload),retained); return publish(topic,(const uint8_t*)payload,strlen(payload),retained);
} }
boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength) bool PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength)
{ {
return publish(topic, payload, plength, false); return publish(topic, payload, plength, false);
} }
boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength, bool PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength,
boolean retained) bool retained)
{ {
if (connected()) { if (connected()) {
if (MQTT_MAX_PACKET_SIZE < 5 + 2+strlen(topic) + plength) { if (MQTT_MAX_PACKET_SIZE < 5 + 2+strlen(topic) + plength) {
@@ -421,8 +421,8 @@ boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigne
return false; return false;
} }
boolean PubSubClient::publish_P(const char* topic, const uint8_t* payload, unsigned int plength, bool PubSubClient::publish_P(const char* topic, const uint8_t* payload, unsigned int plength,
boolean retained) bool retained)
{ {
uint8_t llen = 0; uint8_t llen = 0;
uint8_t digit; uint8_t digit;
@@ -468,7 +468,7 @@ boolean PubSubClient::publish_P(const char* topic, const uint8_t* payload, unsig
return rc == tlen + 4 + plength; return rc == tlen + 4 + plength;
} }
boolean PubSubClient::write(uint8_t header, uint8_t* buf, uint16_t length) bool PubSubClient::write(uint8_t header, uint8_t* buf, uint16_t length)
{ {
uint8_t lenBuf[4]; uint8_t lenBuf[4];
uint8_t llen = 0; uint8_t llen = 0;
@@ -495,7 +495,7 @@ boolean PubSubClient::write(uint8_t header, uint8_t* buf, uint16_t length)
uint8_t* writeBuf = buf+(4-llen); uint8_t* writeBuf = buf+(4-llen);
uint16_t bytesRemaining = length+1+llen; //Match the length type uint16_t bytesRemaining = length+1+llen; //Match the length type
uint8_t bytesToWrite; uint8_t bytesToWrite;
boolean result = true; bool result = true;
while((bytesRemaining > 0) && result) { while((bytesRemaining > 0) && result) {
bytesToWrite = (bytesRemaining > MQTT_MAX_TRANSFER_SIZE)?MQTT_MAX_TRANSFER_SIZE:bytesRemaining; bytesToWrite = (bytesRemaining > MQTT_MAX_TRANSFER_SIZE)?MQTT_MAX_TRANSFER_SIZE:bytesRemaining;
rc = _client->write(writeBuf,bytesToWrite); rc = _client->write(writeBuf,bytesToWrite);
@@ -511,12 +511,12 @@ boolean PubSubClient::write(uint8_t header, uint8_t* buf, uint16_t length)
#endif #endif
} }
boolean PubSubClient::subscribe(const char* topic) bool PubSubClient::subscribe(const char* topic)
{ {
return subscribe(topic, 0); return subscribe(topic, 0);
} }
boolean PubSubClient::subscribe(const char* topic, uint8_t qos) bool PubSubClient::subscribe(const char* topic, uint8_t qos)
{ {
// original: if (qos < 0 || qos > 1) { (qos is uint8_t, hence qos < 0 impossible, tekka) // original: if (qos < 0 || qos > 1) { (qos is uint8_t, hence qos < 0 impossible, tekka)
if (qos > 1) { if (qos > 1) {
@@ -542,7 +542,7 @@ boolean PubSubClient::subscribe(const char* topic, uint8_t qos)
return false; return false;
} }
boolean PubSubClient::unsubscribe(const char* topic) bool PubSubClient::unsubscribe(const char* topic)
{ {
if (MQTT_MAX_PACKET_SIZE < 9 + strlen(topic)) { if (MQTT_MAX_PACKET_SIZE < 9 + strlen(topic)) {
// Too long // Too long
@@ -587,9 +587,9 @@ uint16_t PubSubClient::writeString(const char* string, uint8_t* buf, uint16_t po
} }
boolean PubSubClient::connected() bool PubSubClient::connected()
{ {
boolean rc; bool rc;
if (_client == NULL ) { if (_client == NULL ) {
rc = false; rc = false;
} else { } else {
+21 -21
View File
@@ -92,9 +92,9 @@ private:
bool pingOutstanding; bool pingOutstanding;
MQTT_CALLBACK_SIGNATURE; MQTT_CALLBACK_SIGNATURE;
uint16_t readPacket(uint8_t*); uint16_t readPacket(uint8_t*);
boolean readByte(uint8_t * result); bool readByte(uint8_t * result);
boolean readByte(uint8_t * result, uint16_t * index); bool readByte(uint8_t * result, uint16_t * index);
boolean write(uint8_t header, uint8_t* buf, uint16_t length); bool write(uint8_t header, uint8_t* buf, uint16_t length);
uint16_t writeString(const char* string, uint8_t* buf, uint16_t pos); uint16_t writeString(const char* string, uint8_t* buf, uint16_t pos);
IPAddress ip; IPAddress ip;
const char* domain; const char* domain;
@@ -127,25 +127,25 @@ public:
PubSubClient& setClient(Client& client); //!< setClient PubSubClient& setClient(Client& client); //!< setClient
PubSubClient& setStream(Stream& stream); //!< setStream PubSubClient& setStream(Stream& stream); //!< setStream
boolean connect(const char* id); //!< connect bool connect(const char* id); //!< connect
boolean connect(const char* id, const char* user, const char* pass); //!< connect bool connect(const char* id, const char* user, const char* pass); //!< connect
boolean connect(const char* id, const char* willTopic, uint8_t willQos, boolean willRetain, bool connect(const char* id, const char* willTopic, uint8_t willQos, bool willRetain,
const char* willMessage); //!< connect const char* willMessage); //!< connect
boolean connect(const char* id, const char* user, const char* pass, const char* willTopic, bool connect(const char* id, const char* user, const char* pass, const char* willTopic,
uint8_t willQos, boolean willRetain, const char* willMessage); //!< connect uint8_t willQos, bool willRetain, const char* willMessage); //!< connect
void disconnect(); //!< disconnect void disconnect(); //!< disconnect
boolean publish(const char* topic, const char* payload); //!< publish bool publish(const char* topic, const char* payload); //!< publish
boolean publish(const char* topic, const char* payload, boolean retained); //!< publish bool publish(const char* topic, const char* payload, bool retained); //!< publish
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength); //!< publish bool publish(const char* topic, const uint8_t * payload, unsigned int plength); //!< publish
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, bool publish(const char* topic, const uint8_t * payload, unsigned int plength,
boolean retained); //!< publish bool retained); //!< publish
boolean publish_P(const char* topic, const uint8_t * payload, unsigned int plength, bool publish_P(const char* topic, const uint8_t * payload, unsigned int plength,
boolean retained); //!< publish_P bool retained); //!< publish_P
boolean subscribe(const char* topic); //!< subscribe bool subscribe(const char* topic); //!< subscribe
boolean subscribe(const char* topic, uint8_t qos); //!< subscribe bool subscribe(const char* topic, uint8_t qos); //!< subscribe
boolean unsubscribe(const char* topic); //!< unsubscribe bool unsubscribe(const char* topic); //!< unsubscribe
boolean loop(); //!< loop bool loop(); //!< loop
boolean connected(); //!< connected bool connected(); //!< connected
int state(); //!< state int state(); //!< state
}; };
+3 -3
View File
@@ -95,7 +95,7 @@ void SPIFlash::unselect()
} }
/// setup SPI, read device ID etc... /// setup SPI, read device ID etc...
boolean SPIFlash::initialize() bool SPIFlash::initialize()
{ {
#if defined(SPCR) && defined(SPSR) #if defined(SPCR) && defined(SPSR)
_SPCR = SPCR; _SPCR = SPCR;
@@ -180,7 +180,7 @@ void SPIFlash::readBytes(uint32_t addr, void* buf, uint16_t len)
} }
/// Send a command to the flash chip, pass TRUE for isWrite when its a write command /// Send a command to the flash chip, pass TRUE for isWrite when its a write command
void SPIFlash::command(uint8_t cmd, boolean isWrite) void SPIFlash::command(uint8_t cmd, bool isWrite)
{ {
#if defined(__AVR_ATmega32U4__) // Arduino Leonardo, MoteinoLeo #if defined(__AVR_ATmega32U4__) // Arduino Leonardo, MoteinoLeo
DDRB |= B00000001; // Make sure the SS pin (PB0 - used by RFM12B on MoteinoLeo R1) is set as output HIGH! DDRB |= B00000001; // Make sure the SS pin (PB0 - used by RFM12B on MoteinoLeo R1) is set as output HIGH!
@@ -201,7 +201,7 @@ void SPIFlash::command(uint8_t cmd, boolean isWrite)
} }
/// check if the chip is busy erasing/writing /// check if the chip is busy erasing/writing
boolean SPIFlash::busy() bool SPIFlash::busy()
{ {
/* /*
select(); select();
+3 -3
View File
@@ -117,8 +117,8 @@ class SPIFlash
public: public:
static uint8_t UNIQUEID[8]; //!< Storage for unique identifier static uint8_t UNIQUEID[8]; //!< Storage for unique identifier
SPIFlash(uint8_t slaveSelectPin, uint16_t jedecID=0); //!< Constructor SPIFlash(uint8_t slaveSelectPin, uint16_t jedecID=0); //!< Constructor
boolean initialize(); //!< setup SPI, read device ID etc... bool initialize(); //!< setup SPI, read device ID etc...
void command(uint8_t cmd, boolean isWrite= void command(uint8_t cmd, bool isWrite=
false); //!< Send a command to the flash chip, pass TRUE for isWrite when its a write command false); //!< Send a command to the flash chip, pass TRUE for isWrite when its a write command
uint8_t readStatus(); //!< return the STATUS register uint8_t readStatus(); //!< return the STATUS register
uint8_t readByte(uint32_t addr); //!< read 1 byte from flash memory uint8_t readByte(uint32_t addr); //!< read 1 byte from flash memory
@@ -126,7 +126,7 @@ public:
void writeByte(uint32_t addr, uint8_t byt); //!< Write 1 byte to flash memory void writeByte(uint32_t addr, uint8_t byt); //!< Write 1 byte to flash memory
void writeBytes(uint32_t addr, const void* buf, void writeBytes(uint32_t addr, const void* buf,
uint16_t len); //!< write multiple bytes to flash memory (up to 64K), if define SPIFLASH_SST25TYPE is set AAI Word Programming will be used uint16_t len); //!< write multiple bytes to flash memory (up to 64K), if define SPIFLASH_SST25TYPE is set AAI Word Programming will be used
boolean busy(); //!< check if the chip is busy erasing/writing bool busy(); //!< check if the chip is busy erasing/writing
void chipErase(); //!< erase entire flash memory array void chipErase(); //!< erase entire flash memory array
void blockErase4K(uint32_t address); //!< erase a 4Kbyte block void blockErase4K(uint32_t address); //!< erase a 4Kbyte block
void blockErase32K(uint32_t address); //!< erase a 32Kbyte block void blockErase32K(uint32_t address); //!< erase a 32Kbyte block
+1 -1
View File
@@ -31,7 +31,7 @@
1.8 1.8
* KeepAlive interval is configurable in PubSubClient.h * KeepAlive interval is configurable in PubSubClient.h
* Maximum packet size is configurable in PubSubClient.h * Maximum packet size is configurable in PubSubClient.h
* API change: Return boolean rather than int from various functions * API change: Return bool rather than int from various functions
* API change: Length parameter in message callback changed * API change: Length parameter in message callback changed
from int to unsigned int from int to unsigned int
* Various internal tidy-ups around types * Various internal tidy-ups around types