Skip to content

Autobaud, sleep, wake changes#234

Open
jpmeijers wants to merge 2 commits intomasterfrom
fix/autobaud-powersaving
Open

Autobaud, sleep, wake changes#234
jpmeijers wants to merge 2 commits intomasterfrom
fix/autobaud-powersaving

Conversation

@jpmeijers
Copy link
Copy Markdown
Collaborator

@jpmeijers jpmeijers commented Apr 4, 2018

Let's discuss this first before merging.

hallard and others added 2 commits April 4, 2018 17:55
* fixed RN2xxx not waked from sleep by autoBaud sometimes

* changes requested by johan

* changes requested by johan

* johan request

* cosmetic

* HAL abstration of modemStream

* Ability to use AltSoftSerial Library

* Code optimization, added ~700 bytes flash for sketch

* HardwareSerial only used on TheThings Node and Uno

* Applied changes requested by johan

* Fixed dual check

* cosmetic

* Added Hardware Serial only for the things node
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 4, 2018

CLA assistant check
All committers have signed the CLA.

@hallard
Copy link
Copy Markdown
Contributor

hallard commented Apr 4, 2018

Thanks for splitting @jpmeijers , looks good to me

Copy link
Copy Markdown
Collaborator Author

@jpmeijers jpmeijers left a comment

Choose a reason for hiding this comment

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

Some comments

Comment thread src/TheThingsNetwork.cpp
return readLine(buffer, size);
}

size_t TheThingsNetwork::checkModuleAvailable()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Having a function like this is a good idea. I would however like to change it to check the version of the RNxxxx module and return a value from an enum stating which hardware and firmware version it is.

We can then use the result to check before we set the frequency plan, and prevent errors when setting the wrong FP into the wrong module.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

makes sense

Comment thread src/TheThingsNetwork.cpp
return !baudDetermined;
}

void TheThingsNetwork::wake()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

There isn't much difference between the wake() and autoBaud() functions. I would recommend we merge these two.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, I do not wanted to change your original one, but I prefer also to merge both, much cleaner

Comment thread src/TheThingsNetwork.cpp

bool TheThingsNetwork::isSleeping()
{
return !baudDetermined;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think we should rename this flag to something like moduleSleeping.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok

Comment thread src/TheThingsNetwork.cpp
{
autoBaud();
// to be determined back on wake up
baudDetermined = false;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Again, moduleSleeping would make more sense here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that's fine

Comment thread src/TheThingsNetwork.cpp
delay(100);
clearReadBuffer();
modemStream->setTimeout(10000);
baudDetermined = true;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I actually don't know why we added this flag to start with. Presumably to do a check before every sendCommand call and autoBaud if we didn't do so yet. If we do decide to implement this, we need to write the autoBaud and checkModuleAvailable functions not to use sendCommand.

But for now maybe let's just scrap the baudDetermined flag and rather introduce a moduleSleeping flag.

Copy link
Copy Markdown
Contributor

@hallard hallard May 16, 2018

Choose a reason for hiding this comment

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

I think we need to know and distinct 2 cases

  • module available (physically connected and responding) if it's not we do nothing (no send)
  • module sleeping, we saw it at init (so available flag set), we put in in sleep (and we know that) but if it does not answer back, so trying to wake it up before sending any data, and check it answer

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point. Maybe not a flag then but an enum. Something like this perhaps? Please suggest naming.

enum state {
  UNKNOWN,
  AWAKE,
  SLEEPING
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sounds good, may be UNKNOWN => NOT_FOUND or NONE or MISSING

@johanstokking
Copy link
Copy Markdown
Member

@hallard can you address @jpmeijers review comments?

@johanstokking
Copy link
Copy Markdown
Member

Hmm, you're approving but I don't see @jpmeijers suggestions implemented.

@hallard
Copy link
Copy Markdown
Contributor

hallard commented May 23, 2018

Well, I'm not an expert of git, @jpmeijers splitted my PR into smaller one and created this one, I thought he was asking for validation, not for implementation. And I'm not sure how to do file changes on a PR from another user.

@jpmeijers
Copy link
Copy Markdown
Collaborator Author

Yes, I'll make the improvements and come back for feedback. Won't happen that fast though. Perhaps the weekend.

Comment thread src/TheThingsNetwork.cpp
}

TheThingsNetwork::TheThingsNetwork(Stream &modemStream, Stream &debugStream, ttn_fp_t fp, uint8_t sf, uint8_t fsb)
TheThingsNetwork::TheThingsNetwork(SerialType &modemStream, Stream &debugStream, ttn_fp_t fp, uint8_t sf, uint8_t fsb)
Copy link
Copy Markdown
Contributor

@cimm cimm Jul 17, 2018

Choose a reason for hiding this comment

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

  1. Random drive by comment but don't forget to update the documentation since the Stream is changing to a SerialType.
  2. Wouldn't it make sense to change the variable name from modemStream to modemSerial or something to avoid confusion?

@johanstokking
Copy link
Copy Markdown
Member

@cimm you may want to assist @jpmeijers if wanted!

@cimm
Copy link
Copy Markdown
Contributor

cimm commented Jul 20, 2018

@johanstokking Happy to help but... I am a software developer, not (yet) a hardware guy. I can see SerialType &modemStream doesn't make sense but I have no idea why we go for a SerialType over a Stream. Simple renaming I can do. 😃

Happy to do the work if someone can give me some simple beginner tasks.

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.

5 participants