#include "SX1276Wiring.hpp"
SX1276Wiring SX1276 = SX1276Wiring(
A0,
D10,
A4,
D2,
D3,
D4,
D5,
A3
);
uint32_t tRxStarted, tRxDone;
int16_t rssiRxStarted;
char buf[20];
int8_t modem;
bool iqInverted = false;
uint8_t syncword;
static void printRxDone(void *args) {
printf( "[%lu us (d:%lu)] Rx is done!: RSSI:%d dB, CRC:%s, Length:%u, (",
tRxDone, (tRxDone - tRxStarted),
uint16_t i;
for (i = 0; i < rxFrame->len; i++)
printf(
"%02X ", rxFrame->
buf[i]);
printf("\b)\n");
delete rxFrame;
}
if (!rxFrame) {
printf("Out of memory to read frame\n");
SX1276.flushBuffer();
return;
}
SX1276.readFrame(rxFrame);
postTask(printRxDone, (
void *) rxFrame);
}
printf("Channel Busy!!\n");
SX1276.cca();
}
static void printRxStarted(void *args) {
printf("[%lu us] Rx is started... (%d dB)\n", tRxStarted, rssiRxStarted);
}
rssiRxStarted = SX1276.getRssi();
}
static void taskRSSI(void *args) {
printf(
"[%lu us] RSSI: %d dB\n",
micros(), SX1276.getRssi());
}
}
static void appStart() {
Serial.onReceive(eventKeyboardInput);
SX1276.begin();
if (modem == 0) {
SX1276.setRadio(sf, bw, cr, true, iqInverted);
SX1276.setSyncword(syncword);
} else {
SX1276.setRadio(50000, 50000, 83333, 25000);
}
SX1276.setChannel(917100000);
SX1276.onRxStarted = eventOnRxStarted;
SX1276.onRxDone = eventOnRxDone;
SX1276.onChannelBusy = eventOnChannelBusy;
SX1276.wakeup();
}
static void askSyncword() {
printf("Enter syncword [0x12]:");
Serial.onReceive(inputSyncword);
Serial.inputKeyboard(buf, sizeof(buf));
}
if (strlen(buf) == 0) {
syncword = 0x12;
} else {
uint8_t sw = (uint8_t) strtoul(buf, NULL, 0);
if (sw == 0) {
printf("* Invalid syncword.\n");
askSyncword();
return;
}
syncword = sw;
}
printf("* Syncword: 0x%02X\n", syncword);
appStart();
}
static void askIQ() {
printf("Set IQ (0:normal, 1:inverted) [0]:");
Serial.onReceive(inputIQ);
Serial.inputKeyboard(buf, sizeof(buf));
}
if (strlen(buf) == 0 || strcmp(buf, "0") == 0) {
printf("* Normal selected.\n");
iqInverted = false;
} else if (strcmp(buf, "1") == 0) {
printf("* Inverted selected.\n");
iqInverted = true;
} else {
printf("* Unknown IQ mode\n");
askIQ();
return;
}
askSyncword();
}
static void askBW() {
printf("Set bandwidth (0:125kHz, 1:250kHz, 2:500kHz) [0]:");
Serial.onReceive(inputBW);
Serial.inputKeyboard(buf, sizeof(buf));
}
if (strlen(buf) == 0 || strcmp(buf, "0") == 0) {
printf("* 125kHz selected.\n");
} else if (strcmp(buf, "1") == 0) {
printf("* 250kHz selected.\n");
} else if (strcmp(buf, "2") == 0) {
printf("* 500kHz selected.\n");
} else {
printf("* Unknown SF\n");
askBW();
return;
}
askIQ();
}
static void askSF() {
printf("Set SF (7, 8, 9, 10, 11, 12) [7]:");
Serial.onReceive(inputSF);
Serial.inputKeyboard(buf, sizeof(buf));
}
if (strlen(buf) == 0 || strcmp(buf, "7") == 0) {
printf("* SF7 selected.\n");
} else if (strcmp(buf, "8") == 0) {
printf("* SF8 selected.\n");
} else if (strcmp(buf, "9") == 0) {
printf("* SF9 selected.\n");
} else if (strcmp(buf, "10") == 0) {
printf("* SF10 selected.\n");
} else if (strcmp(buf, "11") == 0) {
printf("* SF11 selected.\n");
} else if (strcmp(buf, "12") == 0) {
printf("* SF12 selected.\n");
} else {
printf("* Unknown SF\n");
askSF();
return;
}
askBW();
}
static void askModem() {
printf("Select modem (0: LoRa, 1:FSK) [0]:");
Serial.onReceive(inputModem);
Serial.inputKeyboard(buf, sizeof(buf));
}
if (strlen(buf) == 0 || strcmp(buf, "0") == 0) {
printf("* LoRa selected.\n");
modem = 0;
askSF();
} else if (strcmp(buf, "1") == 0) {
printf("* FSK selected.\n");
modem = 1;
appStart();
} else {
printf("* Unknown modem\n");
askModem();
}
}
void setup(void) {
Serial.begin(115200);
printf("\n*** [ST Nucleo-F429ZI] SX1276 Low-Level Rx Control Example ***\n");
#if 1
Serial.listen();
askModem();
#else
modem = 0;
iq = true;
syncword = 0x34;
appStart();
#endif
}
무선 패킷
Definition RadioPacket.hpp:59
@ SUCCESS
송신 또는 수신 성공
Definition RadioPacket.hpp:69
Result_t result
송신 또는 수신 패킷 처리 결과
Definition RadioPacket.hpp:131
int16_t power
송신시 사용할 power (단위: dBm) 또는 수신시의 신호 세기 (단위: dB)
Definition RadioPacket.hpp:137
시리얼 포트를 제어하기 위한 클래스
Definition SerialPort.hpp:76
Timer는 일정 시간 이후에 1회 실행될 작업, 매 일정 시간마다 실행될 작업 등을 위한 기능입니다.
Definition Timer.hpp:61
void onFired(void(*func)(void *), void *args=nullptr)
타이머 만료시 실행시킬 작업함수를 지정합니다.
uint32_t micros()
보드 부팅 이후부터 현재까지의 경과 시간을 마이크로초 단위로 구합니다.
void reboot()
소프트웨어 리셋을 통하여 시스템을 재시작합니다.
bool digitalWrite(int8_t pin, int value)
pin 를 HIGH 또는 LOW 로 설정합니다.
bool pinMode(int8_t pin, enum ioDirection direction)
pin 을 direction 방향을 갖는 디지털 핀으로 동작하도록 설정합니다.
@ OUTPUT
Definition nola-common.h:383
bool postTask(void(*func)(void *), void *args)
작업을 나중에 실행되도록 게시합니다.
LoRaBW_t
LoRa Bandwidth Type.
Definition Radio.hpp:107
@ BW_250kHz
Definition Radio.hpp:110
@ BW_125kHz
Definition Radio.hpp:109
@ BW_500kHz
Definition Radio.hpp:111
LoRaCR_t
LoRa Coding Rate Type.
Definition Radio.hpp:93
@ CR_4_5
Definition Radio.hpp:95
LoRaSF_t
LoRa Spreading Factor Type.
Definition Radio.hpp:78
@ SF8
Definition Radio.hpp:83
@ SF12
Definition Radio.hpp:87
@ SF7
Definition Radio.hpp:82
@ SF9
Definition Radio.hpp:84
@ SF11
Definition Radio.hpp:86
@ SF10
Definition Radio.hpp:85
GPIO 인터럽트에 관한 상세정보
Definition nola-common.h:535