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

Implement batch transmission and better testing features #453

Closed
wants to merge 12 commits into from

Conversation

tpwrules
Copy link
Contributor

@tpwrules tpwrules commented Sep 18, 2023

Requires modification to the MonitorMyWatershed site to work properly. This PR has been marked as a draft until those changes are made.

This implementation of the protocol reuses the logic for formatting single values and buffers values as floats so there should be absolutely no change in transmitted values.

It's unclear if the two timeout extension commits at the end are still needed. I would be fine dropping them for now. I would also be fine splitting the testing button changes into a separate PR.

Please use the GitHub PR review feature to suggest changes.

@tpwrules tpwrules marked this pull request as draft September 18, 2023 22:34
Copy link
Contributor

@SRGDamia1 SRGDamia1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this! I made just a few comments within the code.

The build tests fail because the giant menu_a_la_carte example still expects the testingMode() function to exist (lines 3213 to 3223). The documentation checks fail because there's a typo in the documentation for dataPublisher::txBufferInit() on line 271 of dataPublisherBase.h.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the LogBuffer were converted to a circular buffer (FIFO), using it with endpoints that cannot receive more than one record at a time would be much easier. How difficult do you think it would be to convert it?

I don't need it for this PR, but I am looking toward future use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should not be too difficult but some of the math might be subtle and it would make the API a little hairy. I'll play with it.

src/LogBuffer.h Outdated Show resolved Hide resolved
src/LoggerBase.cpp Outdated Show resolved Hide resolved
src/LoggerBase.h Outdated Show resolved Hide resolved
src/publishers/EnviroDIYPublisher.cpp Show resolved Hide resolved
Serialize timestamps and variable values to the data buffer, then
unserialize and format into JSON arrays. Send interval is controlled
by sendEveryX variable. When data is buffered, 202 is returned to
avoid possibly misleading statement that data is saved by the server.

Offers considerable data and power savings.

Device reports 3K RAM free with six variables and 8K buffer.

making LogBuffer a member variable avoids the static initialization
order fiasco: https://isocpp.org/wiki/faq/ctors#static-init-order
The modem might not be able to accept the data written to it if its
transmit buffer is full. In that case, the portion not accepted needs to
be retried later. If we retry too many times, give up so we don't get
stuck in an infinite loop.
Avoids unnecessary time and power consumption when publishers just plan to
buffer the data.
Send the first few data points logged after initialization immediately
instead of buffering them until the programmed interval elapses. Allows
verification of functionality during deployment.
Avoid repeatedly retrying if the server is down, while still retrying a
couple times in case the connection is unreliable.
Allows field verification of logger functionality after deployment without
undue delay.

Leave default at 0 to allegedly reduce user confusion.
@tpwrules tpwrules force-pushed the batch-transmission branch 2 times, most recently from 2b7e625 to bea5837 Compare September 20, 2023 23:57
Allows easy field verification of functionality as opposed to previous
testing function which only served a purpose when attached to a computer
(and consumed lots of flash).

This behavior can be disabled and the old behavior restored by defining
`MS_LOGGERBASE_BUTTON_BENCH_TEST` to be `true`.
Allows immediate transmission of data in buffer without loss before
powering off and decomissioning a deployed datalogger.
Increases reliability of sending large transmissions.
Towers seem to take longer to connect the less recently a connection has
been estasblished. Now that that's been expanded from 15 minutes to 8
hours, increase the timeout for that action to 4 minutes from 50 seconds.
@tpwrules
Copy link
Contributor Author

tpwrules commented Sep 21, 2023

Can you help me understand the timed out tests? Is there anything I need to/can do about that?

I also see that some boards might need a smaller default buffer size to avoid running out of RAM?

@SRGDamia1
Copy link
Contributor

The GitHub actions stop running further tests in a group after one fails. So when the Mega failed because the program was too big for its RAM, the rest of the tests stopped.

@tpwrules
Copy link
Contributor Author

Okay, how do you recommend we solve that? Is there a way to do board specific defines?

@SRGDamia1 SRGDamia1 marked this pull request as ready for review September 21, 2023 17:04
Copy link
Contributor

@SRGDamia1 SRGDamia1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This looks good, pending updates on the Monitor My Watershed side.

Would you like for me to open separate issues for some of the future possible improvements we've talked about (batching to SD, FIFO buffer)?

uint32_t getRecordTimestamp(int record);

/**
* @brief Gets the value of a particular vaiable in a particular record.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in variable

@SRGDamia1
Copy link
Contributor

You can do board-specific defines by checking for which board type is already defined in the compiler:

#if defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_SAMD_ZERO) || \

@tpwrules
Copy link
Contributor Author

Do you know which boards have less than 16K of RAM?

@SRGDamia1
Copy link
Contributor

The Mega is the only one I'm testing.

@aufdenkampe
Copy link
Member

@SRGDamia1
Copy link
Contributor

Closed in favor of #479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants