Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add debug messages to cFram::saveField() and change return type to bool #317

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,9 @@ This sketch demonstrates the use of the Catena FSM class to implement the `Turns
| [`catena-mcciadk`](https://github.com/mcci-catena/Catena-mcciadk) | 0.2.1 | 0.1.2 | Needed for miscellaneous definitions |

## Release History
- HEAD includes the following changes.

- fix [#309](https://github.com/mcci-catena/Catena-Arduino-Platform/issues/309): add debug message to `cFram::saveField()` and set `bool` as return type. (version 0.21.3-1)

- v0.21.2 includes the following changes, non breaking, all bug fixes.

Expand Down
2 changes: 1 addition & 1 deletion src/CatenaBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Copyright notice:
(((major) << 24u) | ((minor) << 16u) | ((patch) << 8u) | (local))

#define CATENA_ARDUINO_PLATFORM_VERSION \
CATENA_ARDUINO_PLATFORM_VERSION_CALC(0, 21, 2, 0) /* v0.21.2 */
CATENA_ARDUINO_PLATFORM_VERSION_CALC(0, 21, 3, 1) /* v0.21.3-1 */

#define CATENA_ARDUINO_PLATFORM_VERSION_GET_MAJOR(v) \
(((v) >> 24u) & 0xFFu)
Expand Down
6 changes: 3 additions & 3 deletions src/Catena_Fram.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ class cFram : public cPersistentStorage
char **argv
);

void saveField(
bool saveField(
cFramStorage::StandardKeys uKey,
const uint8_t *pValue,
size_t nValue
);

template <typename T>
void saveField(
bool saveField(
cFramStorage::StandardKeys uKey,
const T &field
)
{
this->saveField(uKey, (const uint8_t *)&field, sizeof(field));
return this->saveField(uKey, (const uint8_t *)&field, sizeof(field));
};

bool getField(
Expand Down
16 changes: 14 additions & 2 deletions src/lib/Catena_Fram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,23 +615,35 @@ McciCatena::cFram::writeItemData(
return fResult;
}

void McciCatena::cFram::saveField(
bool McciCatena::cFram::saveField(
cFramStorage::StandardKeys uKey,
const uint8_t *pValue,
size_t nValue
)
{
cFram::Cursor cursor(this, uKey);

bool fResult;

fResult = true;
if (! cursor.create())
{
gLog.printf(gLog.kError,
"%s: can't save uKey(0x%x) %u bytes\n",
__FUNCTION__, uKey, nValue
);
fResult = false;
}

if (! cursor.put(pValue, nValue))
{
gLog.printf(gLog.kError, "%s: can't put uKey(0xx) %u bytes\n",
__func__, uKey, nValue
);
fResult = false;
}

cursor.put(pValue, nValue);
return fResult;
}

bool McciCatena::cFram::getField(
Expand Down