and now it should be possible to enter and leave bind mode
This commit is contained in:
@@ -429,7 +429,7 @@ void loop(void)
|
|||||||
&rxDeviceState,
|
&rxDeviceState,
|
||||||
radioNode.rssi,
|
radioNode.rssi,
|
||||||
radioNode.snr,
|
radioNode.snr,
|
||||||
platformNode.platformState
|
(platformNode.platformState == DEVICE_STATE_FAILSAFE)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,16 +23,16 @@ void PlatformNode::setRcChannel(uint8_t channel, int value, int offset) {
|
|||||||
void PlatformNode::enterBindMode(void) {
|
void PlatformNode::enterBindMode(void) {
|
||||||
isBindMode = true;
|
isBindMode = true;
|
||||||
|
|
||||||
// radioNode.set(
|
radioNode.set(
|
||||||
// 0, // Minimum power
|
0, // Minimum power
|
||||||
// 125000, // 125kHz bandwidth
|
125000, // 125kHz bandwidth
|
||||||
// 6, // low spreading factor, we do not need high RX sensitivity
|
6, // low spreading factor, we do not need high RX sensitivity
|
||||||
// 5, // same for coding rate
|
5, // same for coding rate
|
||||||
// 868000000 //Fixed frequency while binding
|
868000000 //Fixed frequency while binding
|
||||||
// );
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformNode::leaveBindMode(void) {
|
void PlatformNode::leaveBindMode(void) {
|
||||||
isBindMode = false;
|
isBindMode = false;
|
||||||
|
radioNode.reset();
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
#include "radio_node.h"
|
||||||
|
|
||||||
#ifndef PLATFORM_NODE_H
|
#ifndef PLATFORM_NODE_H
|
||||||
#define PLATFORM_NODE_H
|
#define PLATFORM_NODE_H
|
||||||
@@ -9,6 +10,8 @@
|
|||||||
#define PLATFORM_CHANNEL_COUNT 10
|
#define PLATFORM_CHANNEL_COUNT 10
|
||||||
#define PLATFORM_DEFAULT_CHANNEL_VALUE 1000
|
#define PLATFORM_DEFAULT_CHANNEL_VALUE 1000
|
||||||
|
|
||||||
|
extern RadioNode radioNode;
|
||||||
|
|
||||||
enum deviceStates {
|
enum deviceStates {
|
||||||
DEVICE_STATE_OK,
|
DEVICE_STATE_OK,
|
||||||
DEVICE_STATE_FAILSAFE,
|
DEVICE_STATE_FAILSAFE,
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ void qspComputeCrc(QspConfiguration_t *qsp, uint8_t dataByte)
|
|||||||
qsp->crc = crc8_dvb_s2(qsp->crc, dataByte);
|
qsp->crc = crc8_dvb_s2(qsp->crc, dataByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
void encodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceState, uint8_t rssi, uint8_t snr, uint8_t platformState) {
|
void encodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceState, uint8_t rssi, uint8_t snr, bool isFailsafe) {
|
||||||
qsp->payload[0] = rssi;
|
qsp->payload[0] = rssi;
|
||||||
qsp->payload[1] = snr;
|
qsp->payload[1] = snr;
|
||||||
qsp->payload[2] = rxDeviceState->rxVoltage;
|
qsp->payload[2] = rxDeviceState->rxVoltage;
|
||||||
@@ -50,7 +50,7 @@ void encodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceSta
|
|||||||
|
|
||||||
uint8_t flags = 0;
|
uint8_t flags = 0;
|
||||||
|
|
||||||
if (platformState == DEVICE_STATE_FAILSAFE) {
|
if (isFailsafe) {
|
||||||
flags |= 0x01 << 0;
|
flags |= 0x01 << 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
#include "radio_node.h"
|
|
||||||
|
|
||||||
void qspDecodeRcDataFrame(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceSate);
|
void qspDecodeRcDataFrame(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceSate);
|
||||||
void decodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceState);
|
void decodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceState);
|
||||||
@@ -8,7 +7,7 @@ void decodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceSta
|
|||||||
uint8_t get10bitHighShift(uint8_t channel);
|
uint8_t get10bitHighShift(uint8_t channel);
|
||||||
uint8_t get10bitLowShift(uint8_t channel);
|
uint8_t get10bitLowShift(uint8_t channel);
|
||||||
void qspComputeCrc(QspConfiguration_t *qsp, uint8_t dataByte);
|
void qspComputeCrc(QspConfiguration_t *qsp, uint8_t dataByte);
|
||||||
void encodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceState, uint8_t rssi, uint8_t snr, uint8_t platformState);
|
void encodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceState, uint8_t rssi, uint8_t snr, bool isFailsafe);
|
||||||
void encodeRcDataPayload(QspConfiguration_t *qsp, uint8_t noOfChannels);
|
void encodeRcDataPayload(QspConfiguration_t *qsp, uint8_t noOfChannels);
|
||||||
void qspDecodeIncomingFrame(
|
void qspDecodeIncomingFrame(
|
||||||
QspConfiguration_t *qsp,
|
QspConfiguration_t *qsp,
|
||||||
|
|||||||
@@ -17,6 +17,16 @@ RadioNode::RadioNode(void) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RadioNode::reset(void) {
|
||||||
|
set(
|
||||||
|
loraTxPower,
|
||||||
|
loraBandwidth,
|
||||||
|
loraSpreadingFactor,
|
||||||
|
loraCodingRate,
|
||||||
|
getFrequencyForChannel(getChannel())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void RadioNode::init(uint8_t ss, uint8_t rst, uint8_t di0, void(*callback)(int)) {
|
void RadioNode::init(uint8_t ss, uint8_t rst, uint8_t di0, void(*callback)(int)) {
|
||||||
/*
|
/*
|
||||||
* Setup hardware
|
* Setup hardware
|
||||||
@@ -31,14 +41,7 @@ void RadioNode::init(uint8_t ss, uint8_t rst, uint8_t di0, void(*callback)(int))
|
|||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
set(
|
reset();
|
||||||
loraTxPower,
|
|
||||||
loraBandwidth,
|
|
||||||
loraSpreadingFactor,
|
|
||||||
loraCodingRate,
|
|
||||||
getFrequencyForChannel(getChannel())
|
|
||||||
);
|
|
||||||
|
|
||||||
LoRa.enableCrc();
|
LoRa.enableCrc();
|
||||||
|
|
||||||
//Setup ISR callback and start receiving
|
//Setup ISR callback and start receiving
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class RadioNode {
|
|||||||
uint8_t codingRate,
|
uint8_t codingRate,
|
||||||
long frequency
|
long frequency
|
||||||
);
|
);
|
||||||
|
void reset(void);
|
||||||
volatile int8_t bytesToRead = -1;
|
volatile int8_t bytesToRead = -1;
|
||||||
volatile uint8_t radioState = RADIO_STATE_RX;
|
volatile uint8_t radioState = RADIO_STATE_RX;
|
||||||
uint8_t rssi = 0;
|
uint8_t rssi = 0;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "radio_node.h"
|
|
||||||
#include "platform_node.h"
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user