-
Notifications
You must be signed in to change notification settings - Fork 14
[WIP] Implement sending welcome packets to clickers #16
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,44 @@ enum iClickerAnswer : uint8_t | |
| NUM_ANSWER_CHOICES, | ||
| }; | ||
|
|
||
| struct QuestionMode | ||
| { | ||
| // magic bytes used in the welcome packet for this | ||
| // question mode | ||
| uint8_t welcome_bytes[2]; | ||
| }; | ||
|
|
||
| namespace QuestionModes { | ||
| const QuestionMode MULTIPLE_CHOICE = | ||
| { | ||
| {0x92, 0x62} | ||
| }; | ||
|
|
||
| const QuestionMode NUMERIC = | ||
| { | ||
| {0x93, 0x63} | ||
| }; | ||
|
|
||
| const QuestionMode ALPHANUMERIC = | ||
| { | ||
| {0x9B, 0x6B} | ||
| }; | ||
|
|
||
| const QuestionMode MULTIPLE_NUMERIC = | ||
| { | ||
| {0x94, 0x64} | ||
| }; | ||
|
|
||
| const QuestionMode MULTIPLE_ALPHANUMERIC = | ||
| { | ||
| {0x9C, 0x6C} | ||
| }; | ||
| }; | ||
|
|
||
| #define WELCOME_RECV_SYNC_ADDR_LEN 6 | ||
| const uint8_t WELCOME_RECV_SYNC_ADDR[WELCOME_RECV_SYNC_ADDR_LEN] = | ||
| {0x55, 0x55, 0x55, 0x36, 0x36, 0x36}; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I imagine you see the base station's firmware transmitting this leading This actually bring up a problem with the way thehttps://github.com//pull/12. Trying to receive the ack by triggering using the sync address functionality on the preamble ({0x55, 0x55, 0x55}) likely will not work reliably in certain situations. I think we should use the first two bytes of the encodedID instead.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The RFM69HCW's datasheet is really confusing me here, the only configurable part of the preamble seems to be
The datasheet does mention the following:
So only 1.5 bytes are required to trigger the preamble detecting part of the RFM69 and the rest should be safe to use as a sync word? Also won't this present a problem for promiscuously snooping on all ACKs? What do we use as the sync word there?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, the datasheet is a bit confusing... so the preamble is an alternating series of 1 and 0s. So both 0b01010101 (0x55) as well as 0b10101010 (0xaa) would work.
1.5 bytes is only the minimum. I'm not sure if with this particular chipset a longer preamble helps after the first 1.5 bytes. After reading the datasheet more carefully it looks like it is mostly being used to lock on to the bitrate of the transmission. Remember this is supposed to be a general purpose FSK transceivers, so they designed it to be compatible with other transceivers. Some more advanced FSK receivers could use this preamble to do additional things. I think the best solution is just avoid using preamble bytes for the sync word unless we absolutely have to. For example with answer submission the sync word is
Yeah, this is a problem with trying to support promisoucMode for acks. See #13 |
||
|
|
||
|
|
||
| // Encoded answer choice is sent as follows: | ||
| /* | ||
|
|
@@ -111,6 +149,8 @@ class iClickerEmulator | |
| bool begin(iClickerChannel chan); | ||
| bool submitAnswer(uint8_t id[ICLICKER_ID_LEN], iClickerAnswer ans, | ||
| bool withAck=false, uint32_t timeout=DEFAULT_ACK_TIMEOUT, bool waitClear = true); | ||
| void sendWelcomePacket(char* msg, QuestionMode mode=QuestionModes::MULTIPLE_CHOICE, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| uint16_t num_questions=0); | ||
| void acknowledgeAnswer(iClickerAnswerPacket* packet, bool accept=true); | ||
|
|
||
| void startPromiscuous(iClickerChannelType chanType, void (*cb)(iClickerPacket *)); | ||
|
|
||
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.
Can't this just be done with the
computeChecksummethod?