jgromes / RadioLib

Universal wireless communication library for embedded devices
https://jgromes.github.io/RadioLib/
MIT License
1.46k stars 367 forks source link

CubeCell + POCSAG issues. #1041

Closed ellisgl closed 4 months ago

ellisgl commented 4 months ago

Running POCSAG w/ the CubeCell (AB01 V2) at 1200 BPS, the ouput isn't able to be decoded in Multimon-ng. Running a test with RPITX, it works fine.

Here's the waterfall comparison (CubeCell on the left), looks like there's stuttering?: CubeCell-RPITX-POCSAG-1200

platformio.ini

[env:cubecell_board_v2]
platform = heltec-cubecell
board = cubecell_board_v2
framework = arduino
monitor_speed = 115200
lib_deps = jgromes/RadioLib@^6.5.0

main.c

#include <Arduino.h>
#include <RadioLib.h>

// CubeCell has the SX1262 built-in.
SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);

// Create the pager client instance using the FSK module.
PagerClient pager(&radio);

void setup() {
    Serial.begin(115200);
    while(!Serial);
    // Wait 5 seconds - so we can see the startup messages after upload.
    delay(5000);
    Serial.print(F("[CubeCell] Initializing ... "));
    int state = radio.beginFSK();
    state |= radio.setOutputPower(-9);
    if(state == RADIOLIB_ERR_NONE) {
        Serial.println(F("success!"));
    } else {
        Serial.print(F("failed, code "));
        Serial.println(state);
        while(true);
    }

    // Initialize the pager client.
    Serial.print(F("[Pager] Initializing ... "));
    // base (center) frequency:     914.1435 MHz testing!
    // speed:                       1200 bps
    state = pager.begin(915.142, 1200);
    if(state == RADIOLIB_ERR_NONE) {
      Serial.println(F("success!"));
    } else {
      Serial.print(F("failed, code "));
      Serial.println(state);
      while(true);
    }
}

void loop() {
    Serial.print(F("[Pager] Transmitting messages ... "));
    int state = pager.transmit("HELLOWRLD!\0", 0062551, RADIOLIB_PAGER_ASCII);
    delay(500);
    if(state == RADIOLIB_ERR_NONE) {
        Serial.println(F("success!"));
        // We are only to send once.
        while(true);
    } else {
        Serial.print(F("failed, code "));
        Serial.println(state);
    }

    // Wait for a couple seconds before next try.
    delay(3000);
}

Debug output: https://gist.github.com/ellisgl/f14dbda493654f984faf6bcb60180644

jgromes commented 4 months ago

To transmit POCSAG, RadioLib relies on Arduino API micros() function for timing, as can be seen here:

https://github.com/jgromes/RadioLib/blob/b2c7e98d6cfab071f20566d23d0380dd26839c91/src/protocols/Pager/Pager.cpp#L509

However, it has been reported that on CubeCell, the micros() function is broken, as shown e.g. here: https://github.com/jgromes/RadioLib/issues/1013#issuecomment-2017813858

There is a workaround you can try, which is described here: https://github.com/jgromes/RadioLib/wiki/Interrupt-Based-Timing Basically you don't use the micros() function and create an appropriate timer yourself, taking care to set it up so that it triggers every 1/1200 = 833 microseconds.