-
Notifications
You must be signed in to change notification settings - Fork 12
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
Clarify newkey logic with enum #453
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I support adding an enum
I think we can do better with the enum value naming. What do the KEYUP_ALLOWED, NOKEYUP_ALLOWED, and OLD_KEYUP_ALLOWED names mean? And, at the very least, it would be good to add some comments in app_rpt.h
about each value and when it should be used.
I don't disagree. These were names that made sense to me with limited understanding as I was trying to understand the logic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed your enum value comments :-)
... and now that I know more about the variable/values "I" might suggest a few renames.
- KEYUP_ALLOWED : OK
- OLD_KEYUP_ALLOWED --> KEYUP_ALLOWED_OLD
- NOKEYUP_ALLOWED --> KEYUP_NOT_ALLOWED
and, I will add that I'm not wild about the "_OLD"
Also, the app_rpt.c handling of newkey == 1
is odd ... and because the handling differs from newkey == 2
that makes me question _OLD even more.
But, before making changes I think we should hear what @InterLinked1 and @KB4MDD think about the naming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I very much support this change, I was going to do it myself but not having a radio background I wasn't super confident about what the values actually meant, so thanks for doing this.
Mostly stylistic recommendations here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please squash all your commits together into a single commit, and please rename the commit to be prefixed with the module name, e.g. app_rpt: Use enum for newkey variable.
I agree with @Allan-N, I think the enums should setup with KEYUP. I don't know the purpose of _OLD value - it would be nice to give it a good name if we understand how it works. |
I called it old key because of this code: app_rpt/apps/app_rpt/rpt_channel.c Lines 463 to 483 in 604328d
I suppose we should rename this function too? |
f87ab5f
to
075b635
Compare
Best I can tell, there was an "old" mechanism for !NEWKEY!, I don't see anywhere in the current code base where it is sent other than a response to someone sending it, so this is probably hanging around for compatibility which may no longer be needed (who really knows if there are super old versions out there for sure...). I could be missing it. To me, it looks like !NEWKEY1! mechanism keeps a remote from triggering TX First we set up the channel and flag Lines 6686 to 6692 in 604328d
Then we send a couple of !NEWKEY1! messages: Lines 6740 to 6763 in 604328d
The other side of the link then responds with !NEWKEY1! for answering the call: Lines 4454 to 4468 in 604328d
The key to control happening is here: Lines 4488 to 4499 in 604328d
If it is (>=2) we ignore There are a few things in here that should also get #DEFINES to clear things up: Line 6759 in 604328d
l->name[0] <= '9' -> That's the first character of the node id (right?) What type are we really looking for?
Same thing here: Line 6742 in 604328d
l->name > '9'
I think that means it's not numeric - maybe a web receiver? Then there is this Line 6691 in 604328d
What nodes have 0 for the first character? This is a LOT! I feel like putting it in words may help me verify my thoughts and allow others to confirm I'm not out in the weeds. |
Looking over app_rpt.c and all of the place where we check
and maybe :
|
541c704
to
aae6a16
Compare
0618fa6
to
c0e1583
Compare
858b966
to
5fa77c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the commit message, enum should be all lowercase. ENUM
in Asterisk refers to something completely different :)
apps/app_rpt/app_rpt.h
Outdated
@@ -342,6 +342,12 @@ struct rpt_chan_stat { | |||
#define NEWKEY1STR "!NEWKEY1!" | |||
#define IAXKEYSTR "!IAXKEY!" | |||
|
|||
enum rpt_newkey { /*!< Repeter connection newkey handshake */ | |||
KEYUP_ALLOWED, /*!< Radio keyup is allowed from link */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More comments describing when a repeater is in each state might be nice :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some comments to these - I think it's more clear.
496e302
to
54387a9
Compare
7660f5c
to
36e4347
Compare
I think I've untangled this a bit. I went with 2 enums one for the repeater structure and one for the link structure. Hopefully that will help be a bit more clear which one we are using. If I've done it right, I think it will explain it self :) |
6dc9bcd
to
b3a5445
Compare
As far as I can tell all this newkey business is doing is deciding if we send As you dig around, let's see if it helps... |
Since we (currently) only have one enum, maybe change |
Change names of xxx->newkey to link_newkey in rpt_link structure and rpt_newkey in rpt structure.
After some struggles understanding newkey logic, I had made these changes for my own sanity.