Skip to content

Commit

Permalink
Fix compiler warnings (const char, missing returns, unsused vars)
Browse files Browse the repository at this point in the history
  • Loading branch information
SciLor committed Apr 24, 2022
1 parent ec4866a commit 1ea0362
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 40 deletions.
1 change: 1 addition & 0 deletions AudioOutputCC3200I2S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void AudioOutputCC3200I2S::flush() {

bool AudioOutputCC3200I2S::stop() {
flush();
return true;
}
bool AudioOutputCC3200I2S::begin() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion BoxAccelerometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void BoxAccelerometer::loop() {
bool AxZ = tap&0b1000000; //event on axis
bool AxY = tap&0b0100000;
bool AxX = tap&0b0010000;
bool DPE = tap&0b0001000; //double
//bool DPE = tap&0b0001000; //double
bool PolZ = tap&0b0000100; //0=positive 1=negative
bool PolY = tap&0b0000010;
bool PolX = tap&0b0000001;
Expand Down
2 changes: 2 additions & 0 deletions BoxAudioBufferTriple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ BoxAudioBufferTriple::BufferStruct* BoxAudioBufferTriple::getBuffer(BoxAudioBuff
return _bufferRead;
case BufferType::WRITE:
return _bufferWrite;
case BufferType::WAIT:
return NULL;
}
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion BoxBattery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void BoxBattery::startBatteryTest() {
file.writeString("Comments");
file.writeString("\r\n");
file.writeString("0;;;;;;");
sprintf(output, "vFactor=%u, vChargerFactor=%u;v2-wav", _batteryVoltageFactor, _batteryVoltageChargerFactor);
sprintf(output, "vFactor=%lu, vChargerFactor=%lu;v2-wav", _batteryVoltageFactor, _batteryVoltageChargerFactor);
file.writeString(output);
file.writeString("\r\n");
file.close();
Expand Down
2 changes: 1 addition & 1 deletion BoxCLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void BoxCLI::parse() {

void BoxCLI::execI2C() {
Command c = lastCmd;
int argNum = c.countArgs();
//int argNum = c.countArgs();

unsigned long int tmpNum;
uint8_t addr, regi;
Expand Down
2 changes: 1 addition & 1 deletion BoxDAC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void BoxDAC::opusTest() {
Log.info("Mp3 finished");
*/
//AudioGeneratorTonie *opus;
AudioFileSourceFatFs *file;
//AudioFileSourceFatFs *file;

//file = new AudioFileSourceFatFs("/gs-16b-2c-44100hz.opus");
/*file = new AudioFileSourceFatFs("/CONTENT/6977960C/500304E0");
Expand Down
4 changes: 2 additions & 2 deletions BoxDAC.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class BoxDAC : public EnhancedThread {
bool playFile(const char* path);
bool _playWAV(const char* path);

const static uint8_t VOL_MIN = 0xB0+0x7F; //0xB0=-40.0dB /min allowed value 0x81=-63.5dB
const static uint8_t VOL_MAX = 0x0A+0x7F; //0x0A=+04.0dB /max allowed value 0x30=+24.0dB
const static uint8_t VOL_MIN = 0x2F; //0xB0+0x7F; //0xB0=-40.0dB /min allowed value 0x81=-63.5dB
const static uint8_t VOL_MAX = 0x89; //0x0A+0x7F; //0x0A=+04.0dB /max allowed value 0x30=+24.0dB
const static uint8_t VOL_STEP = 0x06; //3dB
const static uint8_t VOL_TEST = VOL_MIN + 6*VOL_STEP;
uint8_t current_volume;
Expand Down
12 changes: 6 additions & 6 deletions BoxEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ void BoxEvents::loop() {
}

void BoxEvents::handleEarEvent(BoxButtonEars::EarButton earId, BoxButtonEars::PressedType pressType, BoxButtonEars::PressedTime pressLength) {
char* nameEar;
char* nameType;
char* nameLength;
const char* nameEar;
const char* nameType;
const char* nameLength;

switch (earId) {
case BoxButtonEars::EarButton::SMALL:
Expand Down Expand Up @@ -203,7 +203,7 @@ void BoxEvents::handlePowerEvent(BoxPower::PowerEvent event) {
}

void BoxEvents::handleAccelerometerOrientationEvent(BoxAccelerometer::Orientation orient) {
char* orientText;
const char* orientText;
switch (orient) {
case BoxAccelerometer::Orientation::EARS_UP:
orientText = "ears up";
Expand Down Expand Up @@ -252,7 +252,7 @@ void BoxEvents::handleTagEvent(BoxRFID::TAG_EVENT event) {
DirFs dir;
if(Config.get()->misc.autodump) {
Log.info("Autodump...");
char* rdump = "/rDUMP";
const char* rdump = "/rDUMP";
if (!dir.openDir(rdump)) {
Log.info("Create dir %s...", rdump);
if (!FatFs.mkdir(rdump)) {
Expand All @@ -269,7 +269,7 @@ void BoxEvents::handleTagEvent(BoxRFID::TAG_EVENT event) {
Log.info("No Autodump");
}

char* rcontent = "/rCONTENT";
const char* rcontent = "/rCONTENT";
if (!dir.openDir(rcontent)) {
Log.info("Create dir %s...", rcontent);
if (!FatFs.mkdir(rcontent)) {
Expand Down
1 change: 1 addition & 0 deletions BoxI2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bool BoxI2C::send(uint8_t address, uint8_t target_register, uint8_t data) {
uint8_t result = Wire.endTransmission(false);
if (!result) return true;
Log.error("Couldn't send I2C buffer, error=%i", result);
return false;
}

uint8_t BoxI2C::readByte(uint8_t address, uint8_t source_register) {
Expand Down
8 changes: 7 additions & 1 deletion BoxLEDs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void BoxLEDs::setAllBool(bool red, bool green, bool blue) {
setBlueBool(blue);
}

void BoxLEDs::setAll(uint8_t intensity) {
void BoxLEDs::setWhite(uint8_t intensity) {
setAll(intensity, intensity, intensity);
}

Expand All @@ -292,6 +292,12 @@ void BoxLEDs::setAll(CRGB crgb) {
setAll(crgb.red, crgb.green, crgb.blue);
}

void BoxLEDs::setAll(uint32_t color) {
CRGB crgb;
crgb.setRGB(color);
setAll(crgb);
}

void BoxLEDs::testLEDs() {
uint8_t ledR = getRed();
uint8_t ledG = getGreen();
Expand Down
10 changes: 8 additions & 2 deletions BoxLEDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class BoxLEDs : public EnhancedThread {
red = r;
green = g;
blue = b;
}
void setRGB(uint32_t colorcode) {
red = (colorcode >> 16) & 0xFF;
green = (colorcode >> 8) & 0xFF;
blue = (colorcode >> 0) & 0xFF;
}
inline CRGB& operator= (const uint32_t colorcode) __attribute__((always_inline)) {
red = (colorcode >> 16) & 0xFF;
Expand Down Expand Up @@ -209,9 +214,10 @@ class BoxLEDs : public EnhancedThread {
setRed(uint8_t intensity),
setGreen(uint8_t intensity),
setBlue(uint8_t intensity),
setAll(uint8_t intensity),
setWhite(uint8_t intensity),
setAll(uint8_t red, uint8_t green, uint8_t blue),
setAll(CRGB crgb);
setAll(CRGB crgb),
setAll(uint32_t color);

uint8_t
getRed(),
Expand Down
32 changes: 16 additions & 16 deletions BoxRFID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void BoxRFID::processInterrupt(IRQ_STATUS irqStatus) {

trfOffset += trfRxLength;
} else {
trfStatus == TRF_STATUS::PROTOCOL_ERROR;
trfStatus = TRF_STATUS::PROTOCOL_ERROR;
Log.error("Read buffer too small, size=%i, count=%", FIFO_SIZE, (trfOffset+trfRxLength));
return;
}
Expand Down Expand Up @@ -211,9 +211,10 @@ uint8_t BoxRFID::readRegister(uint8_t regi) {
uint8_t data = regi & 0b00011111;
data |= (uint8_t)REG_CMD_WORD_BITS::REGISTER_B7 | (uint8_t)REG_CMD_WORD_BITS::READ_B6;

uint8_t res1, res2;
//uint8_t res1;
uint8_t res2;
spiEnable();
res1 = SPI.transfer(data);
SPI.transfer(data);
SPI.setDataMode(SPI_SUB_MODE_1);
res2 = SPI.transfer(0x00); //0xFF or 0x00? (Ghost bytes)
SPI.setDataMode(SPI_SUB_MODE_0);
Expand Down Expand Up @@ -253,10 +254,10 @@ void BoxRFID::writeRegister(uint8_t regi, uint8_t value) {
uint8_t data = regi & 0b00011111;
data |= (uint8_t)REG_CMD_WORD_BITS::REGISTER_B7 | (uint8_t)REG_CMD_WORD_BITS::WRITE_B6;

uint8_t res1, res2;
//uint8_t res1, res2;
spiEnable();
res1 = SPI.transfer(data);
res2 = SPI.transfer(value);
SPI.transfer(data);
SPI.transfer(value);
spiDisable();

//Log.info("Write register %i, data=%i, value=%i, res1=%i, res2=%i", regi, data, value, res1, res2);
Expand All @@ -268,10 +269,10 @@ void BoxRFID::sendCommand(uint8_t command) {
uint8_t data = command & 0b00011111;
data |= (uint8_t)REG_CMD_WORD_BITS::COMMAND_B7 | (uint8_t)REG_CMD_WORD_BITS::WRITE_B6;

uint8_t res1, res2;
//uint8_t res1, res2;
spiEnable();
res1 = SPI.transfer(data);
res2 = SPI.transfer(0x00); //0xFF or 0x00? (Ghost bytes) //Dummy transfer, see TRF796xA SPI Design Tips (sloa140)
SPI.transfer(data);
SPI.transfer(0x00); //0xFF or 0x00? (Ghost bytes) //Dummy transfer, see TRF796xA SPI Design Tips (sloa140)
spiDisable();

//Log.info("Write command %i, data=%i, res1=%i, res2=%i", command, data, res1, res2);
Expand Down Expand Up @@ -402,7 +403,7 @@ BoxRFID::ISO15693_RESULT BoxRFID::ISO15693_readSingleBlock(uint8_t blockId, uint
}

BoxRFID::ISO15693_RESULT BoxRFID::ISO15693_sendSingleSlotInventory(uint8_t* uid) {
uint8_t g_ui8TagDetectedCount;
//uint8_t g_ui8TagDetectedCount;
uint8_t ui8LoopCount = 0;
uint8_t offset = 0;

Expand All @@ -425,7 +426,7 @@ BoxRFID::ISO15693_RESULT BoxRFID::ISO15693_sendSingleSlotInventory(uint8_t* uid)
Log.printf("%x ", uid[7-ui8LoopCount]); // Send UID to host
}
Log.println();*/
g_ui8TagDetectedCount = 1;
//g_ui8TagDetectedCount = 1;
return ISO15693_RESULT::INVENTORY_VALID_RESPONSE;
} else {
Log.error("Invalid length, should be %i but is %i", 10, trfRxLength);
Expand All @@ -444,7 +445,6 @@ BoxRFID::ISO15693_RESULT BoxRFID::ISO15693_sendSingleSlotInventory(uint8_t* uid)
}
BoxRFID::ISO15693_RESULT BoxRFID::ISO15693_getRandomSlixL(uint8_t* random) {
uint8_t offset = 0;
uint16_t randomNum;

trfBuffer[offset++] = 0x02; // ISO15693 flags - ISO15693_REQ_DATARATE_HIGH
trfBuffer[offset++] = 0xB2; // ISO15693_CMD_NXP_GET_RANDOM_NUMBER
Expand All @@ -458,7 +458,7 @@ BoxRFID::ISO15693_RESULT BoxRFID::ISO15693_getRandomSlixL(uint8_t* random) {
random[0] = trfBuffer[1];
random[1] = trfBuffer[2];
}
randomNum = ((trfBuffer[1]<<8)|trfBuffer[2]);
//uint16_t randomNum = ((trfBuffer[1]<<8)|trfBuffer[2]);
//Log.info("Random number=%X", randomNum);
return ISO15693_RESULT::GET_RANDOM_VALID;
} else {
Expand Down Expand Up @@ -492,7 +492,7 @@ BoxRFID::ISO15693_RESULT BoxRFID::ISO15693_setPassSlixL(uint8_t pass_id, uint32_
buffer[2] = (password>>16) & 0xFF;
buffer[3] = (password>>24) & 0xFF;

if(random) {
if (random[0] || random[1]) {
buffer[0] ^= random[0];
buffer[1] ^= random[1];
buffer[2] ^= random[0];
Expand Down Expand Up @@ -676,7 +676,7 @@ void BoxRFID::initRFID() {
}

BoxRFID::TRF_STATUS BoxRFID::sendDataTag(uint8_t *sendBuffer, uint8_t sendLen) {
sendDataTag(sendBuffer, sendLen, 15, 15); //15, 5 vs. 15, 15 (longer timeout for set password)
return sendDataTag(sendBuffer, sendLen, 15, 15); //15, 5 vs. 15, 15 (longer timeout for set password)
}
BoxRFID::TRF_STATUS BoxRFID::sendDataTag(uint8_t *sendBuffer, uint8_t sendLen, uint8_t txTimeout, uint8_t rxTimeout) {
uint8_t buffer[sendLen+5];
Expand Down Expand Up @@ -757,7 +757,7 @@ bool BoxRFID::dumpTagMemory(bool overwrite) {
FileFs dumpFile;
uint8_t data[32];
uint8_t bytesRead;
char* path = "rDUMP/0123456789ABCDEF";
char path[23];//= "rDUMP/0123456789ABCDEF";
sprintf(
(char *)path,
"rDUMP/%02x%02x%02x%02x%02x%02x%02x%02x",
Expand Down
2 changes: 1 addition & 1 deletion LogStreamSd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <Logging.h>

size_t LogStreamSd::write(uint8_t character) {
write(&character, 1);
return write(&character, 1);
}
size_t LogStreamSd::write(const uint8_t *buffer, size_t size) {
if (!Box.boxSD.isInitialized())
Expand Down
14 changes: 9 additions & 5 deletions WrapperWebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ void WrapperWebServer::handleAjax(void) {
if (commandGetFlashFile(&filename, read_start, read_length))
return;
} else if (cmd.equals("copy-file")) {
/*
String source_str = _server->arg("source");
String target_str = _server->arg("target");
char* source = (char*)source_str.c_str();
char* target = (char*)target_str.c_str();
//TBD
//TODO
*/
} else if (cmd.equals("move-file")) {
String source_str = _server->arg("source");
String target_str = _server->arg("target");
Expand Down Expand Up @@ -202,11 +204,13 @@ void WrapperWebServer::handleAjax(void) {
}
}
} else if (cmd.equals("copy-dir")) {
/*
String source_str = _server->arg("source");
String target_str = _server->arg("target");
char* source = (char*)source_str.c_str();
char* target = (char*)target_str.c_str();
//TBD
//TODO
*/
} else if (cmd.equals("delete-dir")) {
String dir_str = _server->arg("dir");
char* dir = (char*)dir_str.c_str();
Expand Down Expand Up @@ -337,7 +341,7 @@ void WrapperWebServer::sendJsonSuccess() {
_server->send(200, "text/json", "{ \"success\": true }");
}

bool WrapperWebServer::commandGetFile(String* path, long read_start, long read_length, bool download) {
bool WrapperWebServer::commandGetFile(String* path, uint32_t read_start, uint32_t read_length, bool download) {
FileFs file;
if (file.open((char*)path->c_str(), FA_OPEN_EXISTING | FA_READ)) {
if (read_length == 0 || file.fileSize() < read_length)
Expand Down Expand Up @@ -381,7 +385,7 @@ bool WrapperWebServer::commandGetFile(String* path, long read_start, long read_l
}
return false;
}
bool WrapperWebServer::commandGetFlashFile(String* path, long read_start, long read_length) {
bool WrapperWebServer::commandGetFlashFile(String* path, uint32_t read_start, uint32_t read_length) {
if (SerFlash.open((char*)path->c_str(), FS_MODE_OPEN_READ) == SL_FS_OK) {
if (read_length == 0 || SerFlash.size() < read_length)
read_length = SerFlash.size();
Expand Down Expand Up @@ -509,7 +513,7 @@ void WrapperWebServer::handleUploadFlashFile() {
handleNotFound();
}

void WrapperWebServer::sendEvent(char* eventname, char* content) {
void WrapperWebServer::sendEvent(const char* eventname, const char* content) {
bool clientConnected = false;
for (uint8_t i = 0; i < SSE_MAX_CHANNELS; i++) {
if (!(subscription[i].clientIP))
Expand Down
6 changes: 3 additions & 3 deletions WrapperWebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ class WrapperWebServer : public EnhancedThread {
void
sseHandler(uint8_t channel),
sseKeepAlive(),
sendEvent(char* eventname, char* content);
sendEvent(const char* eventname, const char* content);
//sendEventJSON(char* eventname, xyzjsondoc jsonContent);


bool
commandGetFile(String* path, long read_start, long read_length, bool download),
commandGetFlashFile(String* path, long read_start, long read_length);
commandGetFile(String* path, uint32_t read_start, uint32_t read_length, bool download),
commandGetFlashFile(String* path, uint32_t read_start, uint32_t read_length);

BoxTimer _sseTimer;
WebServer* _server;
Expand Down

0 comments on commit 1ea0362

Please sign in to comment.