Skip to content

Commit

Permalink
fixing issue with RadioLib - need to fork library still
Browse files Browse the repository at this point in the history
  • Loading branch information
TomD53 committed Nov 12, 2022
1 parent 06d154b commit 4f19dbd
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 33 deletions.
28 changes: 2 additions & 26 deletions lib/downlink/payloads/DARTDebugPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,13 @@ struct DARTDebugPayload {
"DAQTime=%du,"
"adxlX=%f,"
"adxlY=%f,"
"adxlZ=%f %llu",
"adxlZ=%f",
mpuAccel[0], mpuAccel[1], mpuAccel[2],
mpuGyro[0], mpuGyro[1], mpuGyro[2],
latitude, longitude, altitude, satellitesInView, fixType,
pressure, temperature,
DAQTime,
adxlAccel[0], adxlAccel[1], adxlAccel[2],
timestamp);

/*
return LineProtocolBuilder("DARTDebugPayload")
.addField("mpuAX", mpuAccel[0])
.addField("mpuAY", mpuAccel[1])
.addField("mpuAZ", mpuAccel[2])
.addField("mpuGX", mpuGyro[0])
.addField("mpuGY", mpuGyro[1])
.addField("mpuGZ", mpuGyro[2])
.addField("lat", latitude)
.addField("long", longitude)
.addField("altGPS", altitude)
.addField("SIV", satellitesInView)
.addField("fixType", fixType)
.addField("pressure", pressure)
.addField("temp", temperature)
.addField("DAQTime", DAQTime)
.addField("adxlX", adxlAccel[0])
.addField("adxlY", adxlAccel[1])
.addField("adxlZ", adxlAccel[2])
.setTimestamp(timestamp)
.build();
*/
adxlAccel[0], adxlAccel[1], adxlAccel[2]);
}

DARTDebugPayload(IMU *imu, GPS *gps, Barometer *barometer, Accelerometer *accelerometer) {
Expand Down
23 changes: 23 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ monitor_port = COM5
platform = nordicnrf52
board = adafruit_feather_nrf52840_sense

build_src_filter = -<main-*.cpp> +<main-ground.cpp>

lib_deps = jgromes/RadioLib@^5.1.2

; allow unit tests to know that this env has a radio receiver
Expand All @@ -73,6 +75,27 @@ upload_port = COM3
test_port = COM3
monitor_port = COM3

[env:ground-breadboard-teensy]
platform = teensy
board = teensy41

build_src_filter = -<main-*.cpp> +<main-ground.cpp>

lib_deps = jgromes/RadioLib@^5.1.2

; allow unit tests to know that this env has a radio receiver
build_flags = -D TEST_RADIO_GROUND -D TEENSY_RADIO_BREADBOARD_PINS
-D UNIX_TIME=$UNIX_TIME -D PLATFORM_$PIOPLATFORM

; https://community.platformio.org/t/adafruit-feather-nrf52840-sense-upload-issue/22845/2
lib_archive = no

upload_protocol = teensy-cli

upload_port = COM4
test_port = COM4
monitor_port = COM4

[env:i2cscan]
platform = teensy
board = teensy41
Expand Down
15 changes: 13 additions & 2 deletions src/main-dart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ Accelerometer *accelerometer = &adxl375;

Sensor *sensors[] = {barometer, imu, gps, accelerometer};

int packets_sent = 0;
uint32_t last_packet_update = 0;

void setup() {
// set the Time library to use Teensy's RTC to keep time
setSyncProvider(getTeensy3Time);

Serial.begin(115200);
Serial.begin(2000000);

// begin I2C bus
Wire.begin();
Expand Down Expand Up @@ -100,8 +102,17 @@ void loop() {
// transmit byte array containing payload data
downlink::transmit(radioBuffer, sizeof radioBuffer);


char output_string[512];
payload.toLineProtocol(output_string);
Serial.println(output_string);
//Serial.println(output_string);

packets_sent++;

if (millis() - last_packet_update > 1000) {
Serial.printf("Packets sent: %d\n", packets_sent);
packets_sent = 0;
last_packet_update = millis();
}
}
}
42 changes: 37 additions & 5 deletions src/main-ground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,28 @@
#include "payloads/DARTDebugPayload.h"
#include "buzzer.h"

#if defined(RADIOLIB_SPI_SLOWDOWN)

#warning "RADIOLIB SPI SLOWDOWN ENABLED"
#endif

uint8_t radioBuffer[255];

int packets_received = 0;
uint32_t last_packet_update = 0;



#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
// Required for Serial on Zero based boards
#define Serial SERIAL_PORT_USBVIRTUAL

#endif


void setup() {
pinMode(BUZZER_PIN, OUTPUT);
Serial.begin(115200);
Serial.begin(2000000);
buzzer_startup();
// while (!Serial) {}
downlink::setupRadio();
Expand All @@ -36,11 +53,20 @@ void setup() {
void loop() {
if (downlink::radioAvailable) {



// clear the radio buffer
memset(radioBuffer, 0, sizeof radioBuffer);

uint32_t start = micros();
// output all data into the buffer. Setting `len` to zero retrieves the packet length automatically
downlink::radio.readData(radioBuffer, 0);
uint32_t read_time = micros() - start;


// put the radio back into receive mode
downlink::receive();


// determine which payload type was received by reading the first byte
auto receivedPayloadType = static_cast<downlink::PayloadType>(radioBuffer[0]);
Expand All @@ -54,18 +80,24 @@ void loop() {
Serial.println(testPayload.toLineProtocol());
break;
}


case downlink::DARTDebugPayload: {
DARTDebugPayload dartDebugPayload = fromByteArray<DARTDebugPayload>(radioBuffer);
char output_string[512];
dartDebugPayload.toLineProtocol(output_string);
Serial.println(output_string);
buzzer_tone(1800, 100);
break;
}
}

// put the radio back into receive mode
downlink::receive();


packets_received++;

if (millis() - last_packet_update > 1000) {
//Serial.printf("Packets received: %d Read time: %d\n", packets_received, read_time);
packets_received = 0;
last_packet_update = millis();
}
}
}

0 comments on commit 4f19dbd

Please sign in to comment.