dsvensson / cc1101

A platform agnostic driver to interface with the CC1101 (Sub-1GHz RF Transceiver)
Apache License 2.0
30 stars 16 forks source link

Come up with better names for SyncMode::* #4

Closed dsvensson closed 6 years ago

dsvensson commented 6 years ago

Right now SyncMode members are defined as follows:

pub enum SyncMode {
    Disabled,
    Check15of16(u16),
    Check16of16(u16),
    Check30of32(u16),
    DisabledCarrierSense,
    Check15of16CarrierSense(u16),
    Check16of16CarrierSense(u16),
    Check30of32CarrierSense(u16),
}

These names are close to the CC1101 spec, but they're not particularly meaningful.

The CheckXXofYY denote that XX number of bits should be checked in the YY bits of the sync word. The sync word is 16 bits long, and in the case of YY=32, the sync word is repeated. Then the *CarrierSense versions are the same as the first ones, except that they add CarrierSense into the mix. There must be better names, and perhaps it's possible to split it, or perhaps it should be two functions. set_sync_mode(SyncMode), and set_sync_mode_carrier_sense(SyncMode).

Maybe:

pub enum SyncMode {
    Disabled,
    MatchPartial(u16), // 15of16
    MatchRepeated(u16), // 30of32
    MatchFull(u16), // 16of16
}

..and it would map to the corresponding with/without CarrierSense register values.

Maybe just remove the CarrierSense for now. It could be that there should be some other API for controlling CarrierSense, which also controls gain etc (17.4 in spec), and this other function works in tandem with the current sync mode setting.

dsvensson commented 6 years ago

There seem to be some Carrier Sense interaction wrt sync word that I don't fully understand. Using SyncMode::MatchFull (no explicit Carrier Sense sync mode) and leaving MAX_LNA_GAIN at its default, "Maximum possible LNA + LNA 2 gain" results in lost packets, ie not passing threshold.