Skip to content

Commit a4017d0

Browse files
committed
Change boolean (deprecated) to bool
1 parent 155ccbc commit a4017d0

File tree

2 files changed

+69
-69
lines changed

2 files changed

+69
-69
lines changed

src/SparkFun_ATECCX08a_Arduino_Library.cpp

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
for the same purpose.
4040
*/
4141

42-
boolean ATECCX08A::begin(uint8_t i2caddr, TwoWire &wirePort, Stream &serialPort)
42+
bool ATECCX08A::begin(uint8_t i2caddr, TwoWire &wirePort, Stream &serialPort)
4343
{
4444
//Bring in the user's choices
4545
_i2cPort = &wirePort; //Grab which port the user wants us to use
@@ -68,7 +68,7 @@ boolean ATECCX08A::begin(uint8_t i2caddr, TwoWire &wirePort, Stream &serialPort)
6868
respond with a status, we are gonna use wakeUp() for the same purpose.
6969
*/
7070

71-
boolean ATECCX08A::wakeUp()
71+
bool ATECCX08A::wakeUp()
7272
{
7373
_i2cPort->beginTransmission(0x00); // set up to write to address "0x00",
7474
// This creates a "wake condition" where SDA is held low for at least tWLO
@@ -122,7 +122,7 @@ void ATECCX08A::idleMode()
122122
silicon revision.
123123
*/
124124

125-
boolean ATECCX08A::getInfo()
125+
bool ATECCX08A::getInfo()
126126
{
127127
if (!sendCommand(COMMAND_OPCODE_INFO, 0x00, 0x0000)) // param1 - 0x00 (revision mode).
128128
{
@@ -156,7 +156,7 @@ boolean ATECCX08A::getInfo()
156156
and listens for success response (0x00).
157157
*/
158158

159-
boolean ATECCX08A::lockConfig()
159+
bool ATECCX08A::lockConfig()
160160
{
161161
return lock(LOCK_MODE_ZONE_CONFIG);
162162
}
@@ -172,7 +172,7 @@ boolean ATECCX08A::lockConfig()
172172
This function also updates global variables for these other things.
173173
*/
174174

175-
boolean ATECCX08A::readConfigZone(boolean debug)
175+
bool ATECCX08A::readConfigZone(bool debug)
176176
{
177177
// read block 0, the first 32 bytes of config zone into inputBuffer
178178
read(ZONE_CONFIG, ADDRESS_CONFIG_READ_BLOCK_0, CONFIG_ZONE_READ_SIZE);
@@ -236,7 +236,7 @@ boolean ATECCX08A::readConfigZone(boolean debug)
236236
and listens for success response (0x00).
237237
*/
238238

239-
boolean ATECCX08A::lockDataAndOTP()
239+
bool ATECCX08A::lockDataAndOTP()
240240
{
241241
return lock(LOCK_MODE_ZONE_DATA_AND_OTP);
242242
}
@@ -249,7 +249,7 @@ boolean ATECCX08A::lockDataAndOTP()
249249
and listens for success response (0x00).
250250
*/
251251

252-
boolean ATECCX08A::lockDataSlot0()
252+
bool ATECCX08A::lockDataSlot0()
253253
{
254254
return lock(LOCK_MODE_SLOT0);
255255
}
@@ -262,7 +262,7 @@ boolean ATECCX08A::lockDataSlot0()
262262
and listens for success response (0x00).
263263
*/
264264

265-
boolean ATECCX08A::lock(uint8_t zone)
265+
bool ATECCX08A::lock(uint8_t zone)
266266
{
267267
if (!sendCommand(COMMAND_OPCODE_LOCK, zone, 0x0000))
268268
return false;
@@ -289,7 +289,7 @@ boolean ATECCX08A::lock(uint8_t zone)
289289

290290
/** \brief
291291
292-
updateRandom32Bytes(boolean debug)
292+
updateRandom32Bytes(bool debug)
293293
294294
This function pulls a complete random number (all 32 bytes)
295295
It stores it in a global array called random32Bytes[]
@@ -300,7 +300,7 @@ boolean ATECCX08A::lock(uint8_t zone)
300300
They are getRandomByte(), getRandomInt(), and getRandomLong().
301301
*/
302302

303-
boolean ATECCX08A::updateRandom32Bytes(boolean debug)
303+
bool ATECCX08A::updateRandom32Bytes(bool debug)
304304
{
305305
if (!sendCommand(COMMAND_OPCODE_RANDOM, 0x00, 0x0000))
306306
return false;
@@ -343,28 +343,28 @@ boolean ATECCX08A::updateRandom32Bytes(boolean debug)
343343

344344
/** \brief
345345
346-
getRandomByte(boolean debug)
346+
getRandomByte(bool debug)
347347
348348
This function returns a random byte.
349349
It calls updateRandom32Bytes(), then uses the first byte in that array for a return value.
350350
*/
351351

352-
byte ATECCX08A::getRandomByte(boolean debug)
352+
byte ATECCX08A::getRandomByte(bool debug)
353353
{
354354
updateRandom32Bytes(debug);
355355
return random32Bytes[0];
356356
}
357357

358358
/** \brief
359359
360-
getRandomInt(boolean debug)
360+
getRandomInt(bool debug)
361361
362362
This function returns a random Int.
363363
It calls updateRandom32Bytes(), then uses the first 2 bytes in that array for a return value.
364364
It bitwize ORS the first two bytes of the array into the return value.
365365
*/
366366

367-
int ATECCX08A::getRandomInt(boolean debug)
367+
int ATECCX08A::getRandomInt(bool debug)
368368
{
369369
updateRandom32Bytes(debug);
370370
int return_val;
@@ -376,14 +376,14 @@ int ATECCX08A::getRandomInt(boolean debug)
376376

377377
/** \brief
378378
379-
getRandomLong(boolean debug)
379+
getRandomLong(bool debug)
380380
381381
This function returns a random Long.
382382
It calls updateRandom32Bytes(), then uses the first 4 bytes in that array for a return value.
383383
It bitwize ORS the first 4 bytes of the array into the return value.
384384
*/
385385

386-
long ATECCX08A::getRandomLong(boolean debug)
386+
long ATECCX08A::getRandomLong(bool debug)
387387
{
388388
updateRandom32Bytes(debug);
389389
long return_val;
@@ -430,7 +430,7 @@ long ATECCX08A::random(long min, long max)
430430

431431
/** \brief
432432
433-
receiveResponseData(uint8_t length, boolean debug)
433+
receiveResponseData(uint8_t length, bool debug)
434434
435435
This function receives messages from the ATECCX08a IC (up to 128 Bytes)
436436
It will return true if it receives the correct amount of data and good CRCs.
@@ -443,7 +443,7 @@ long ATECCX08A::random(long min, long max)
443443
It needs length argument:
444444
length: length of data to receive (includes count + DATA + 2 crc bytes)
445445
*/
446-
boolean ATECCX08A::receiveResponseData(uint8_t length, boolean debug)
446+
bool ATECCX08A::receiveResponseData(uint8_t length, bool debug)
447447
{
448448

449449
// pull in data 32 bytes at at time. (necessary to avoid overflow on atmega328)
@@ -506,14 +506,14 @@ boolean ATECCX08A::receiveResponseData(uint8_t length, boolean debug)
506506

507507
/** \brief
508508
509-
checkCount(boolean debug)
509+
checkCount(bool debug)
510510
511511
This function checks that the count byte received in the most recent message equals countGlobal
512512
Call receiveResponseData, and then imeeditately call this to check the count of the complete message.
513513
Returns true if inputBuffer[0] == countGlobal.
514514
*/
515515

516-
boolean ATECCX08A::checkCount(boolean debug)
516+
bool ATECCX08A::checkCount(bool debug)
517517
{
518518
if (debug)
519519
{
@@ -535,13 +535,13 @@ boolean ATECCX08A::checkCount(boolean debug)
535535

536536
/** \brief
537537
538-
checkCrc(boolean debug)
538+
checkCrc(bool debug)
539539
540540
This function checks that the CRC bytes received in the most recent message equals a calculated CRCs
541541
Call receiveResponseData, then call immediately call this to check the CRCs of the complete message.
542542
*/
543543

544-
boolean ATECCX08A::checkCrc(boolean debug)
544+
bool ATECCX08A::checkCrc(bool debug)
545545
{
546546
// Check CRC[0] and CRC[1] are good to go.
547547
atca_calculate_crc(countGlobal - CRC_SIZE, inputBuffer); // first calculate it
@@ -622,7 +622,7 @@ void ATECCX08A::cleanInputBuffer()
622622
Sparkfun Default Configuration Sketch calls this, and then locks the data/otp zones and slot 0.
623623
*/
624624

625-
boolean ATECCX08A::createNewKeyPair(uint16_t slot)
625+
bool ATECCX08A::createNewKeyPair(uint16_t slot)
626626
{
627627
if (!sendCommand(COMMAND_OPCODE_GENKEY, GENKEY_MODE_NEW_PRIVATE, slot))
628628
return false;
@@ -651,7 +651,7 @@ boolean ATECCX08A::createNewKeyPair(uint16_t slot)
651651

652652
/** \brief
653653
654-
generatePublicKey(uint16_t slot, boolean debug)
654+
generatePublicKey(uint16_t slot, bool debug)
655655
656656
This function uses the GENKEY command in "Public Key Computation" mode.
657657
@@ -664,7 +664,7 @@ boolean ATECCX08A::createNewKeyPair(uint16_t slot)
664664
a global variable named publicKey64Bytes for later use.
665665
*/
666666

667-
boolean ATECCX08A::generatePublicKey(uint16_t slot, boolean debug)
667+
bool ATECCX08A::generatePublicKey(uint16_t slot, bool debug)
668668
{
669669
if (!sendCommand(COMMAND_OPCODE_GENKEY, GENKEY_MODE_PUBLIC, slot))
670670
return false;
@@ -711,20 +711,20 @@ boolean ATECCX08A::generatePublicKey(uint16_t slot, boolean debug)
711711

712712
/** \brief
713713
714-
read(uint8_t zone, uint16_t address, uint8_t length, boolean debug)
714+
read(uint8_t zone, uint16_t address, uint8_t length, bool debug)
715715
716716
Reads data from the IC at a specific zone and address.
717717
Your data response will be available at inputBuffer[].
718718
719719
For more info on address encoding, see datasheet pg 58.
720720
*/
721721

722-
boolean ATECCX08A::read(uint8_t zone, uint16_t address, uint8_t length, boolean debug)
722+
bool ATECCX08A::read(uint8_t zone, uint16_t address, uint8_t length, bool debug)
723723
{
724724
return read_output(zone, address, length, NULL, debug);
725725
}
726726

727-
boolean ATECCX08A::read_output(uint8_t zone, uint16_t address, uint8_t length, uint8_t * output, boolean debug)
727+
bool ATECCX08A::read_output(uint8_t zone, uint16_t address, uint8_t length, uint8_t * output, bool debug)
728728
{
729729
int i;
730730
// adjust zone as needed for whether it's 4 or 32 bytes length read
@@ -776,7 +776,7 @@ boolean ATECCX08A::read_output(uint8_t zone, uint16_t address, uint8_t length, u
776776
For more info on zone and address encoding, see datasheet pg 58.
777777
*/
778778

779-
boolean ATECCX08A::write(uint8_t zone, uint16_t address, uint8_t *data, uint8_t length_of_data)
779+
bool ATECCX08A::write(uint8_t zone, uint16_t address, uint8_t *data, uint8_t length_of_data)
780780
{
781781
// adjust zone as needed for whether it's 4 or 32 bytes length write
782782
// bit 7 of param1 needs to be set correctly
@@ -833,7 +833,7 @@ boolean ATECCX08A::write(uint8_t zone, uint16_t address, uint8_t *data, uint8_t
833833
receives the signature and copies it to signature[].
834834
*/
835835

836-
boolean ATECCX08A::createSignature(uint8_t *data, uint16_t slot)
836+
bool ATECCX08A::createSignature(uint8_t *data, uint16_t slot)
837837
{
838838
if (!loadTempKey(data) || !signTempKey(slot))
839839
return false;
@@ -855,7 +855,7 @@ boolean ATECCX08A::createSignature(uint8_t *data, uint16_t slot)
855855
when it requests data, and this will allow us to create a unique data + signature for every communication.
856856
*/
857857

858-
boolean ATECCX08A::loadTempKey(uint8_t *data)
858+
bool ATECCX08A::loadTempKey(uint8_t *data)
859859
{
860860
if (!sendCommand(COMMAND_OPCODE_NONCE, NONCE_MODE_PASSTHROUGH, 0x0000, data, 32))
861861
return false;
@@ -891,7 +891,7 @@ boolean ATECCX08A::loadTempKey(uint8_t *data)
891891
The response from this command (the signature) is stored in global varaible signature[].
892892
*/
893893

894-
boolean ATECCX08A::signTempKey(uint16_t slot)
894+
bool ATECCX08A::signTempKey(uint16_t slot)
895895
{
896896
if (!sendCommand(COMMAND_OPCODE_SIGN, SIGN_MODE_TEMPKEY, slot))
897897
return false;
@@ -939,7 +939,7 @@ boolean ATECCX08A::signTempKey(uint16_t slot)
939939
Note, it acutally uses loadTempKey, then uses the verify command in "external public key" mode.
940940
*/
941941

942-
boolean ATECCX08A::verifySignature(uint8_t *message, uint8_t *signature, uint8_t *publicKey)
942+
bool ATECCX08A::verifySignature(uint8_t *message, uint8_t *signature, uint8_t *publicKey)
943943
{
944944
uint8_t data_sigAndPub[128];
945945

@@ -975,7 +975,7 @@ boolean ATECCX08A::verifySignature(uint8_t *message, uint8_t *signature, uint8_t
975975
return true;
976976
}
977977

978-
boolean ATECCX08A::sha256(uint8_t * plain, size_t len, uint8_t * hash)
978+
bool ATECCX08A::sha256(uint8_t * plain, size_t len, uint8_t * hash)
979979
{
980980
int i;
981981
size_t chunks = len / SHA_BLOCK_SIZE + !!(len % SHA_BLOCK_SIZE);
@@ -1051,11 +1051,11 @@ boolean ATECCX08A::sha256(uint8_t * plain, size_t len, uint8_t * hash)
10511051
Returns true if write commands were successful.
10521052
*/
10531053

1054-
boolean ATECCX08A::writeConfigSparkFun()
1054+
bool ATECCX08A::writeConfigSparkFun()
10551055
{
10561056
// keep track of our write command results.
1057-
boolean result1;
1058-
boolean result2;
1057+
bool result1;
1058+
bool result2;
10591059

10601060
// set keytype on slot 0 and 1 to 0x3300
10611061
// Lockable, ECC, PuInfo set (public key always allowed to be generated), contains a private Key
@@ -1084,7 +1084,7 @@ boolean ATECCX08A::writeConfigSparkFun()
10841084
So those specific transmissions are handled in unique functions.
10851085
*/
10861086

1087-
boolean ATECCX08A::sendCommand(uint8_t command_opcode, uint8_t param1, uint16_t param2, uint8_t *data, size_t length_of_data)
1087+
bool ATECCX08A::sendCommand(uint8_t command_opcode, uint8_t param1, uint16_t param2, uint8_t *data, size_t length_of_data)
10881088
{
10891089
// build packet array (total_transmission) to send a communication to IC, with opcode COMMAND
10901090
// It expects to see: word address, count, command opcode, param1, param2, data (optional), CRC[0], CRC[1]

0 commit comments

Comments
 (0)