struct timeval tRxStarted, tRxDone;
int16_t rssiRxStarted;
char buf[20];
int8_t modem;
bool iqInverted;
uint8_t syncword;
uint32_t freq;
static void printRxDone(void *args) {
static uint16_t success = 0;
printf(
"[%lu.%06lu] Rx is done!: RSSI:%d dB, SNR:%d, CRC:%s, Length:%u, (",
(uint32_t) tRxDone.tv_sec, tRxDone.tv_usec,
);
uint16_t i;
for (i = 0; i < rxFrame->len; i++)
printf(
"%02X ", rxFrame->
buf[i]);
delete rxFrame;
}
if (!rxFrame) {
printf("Out of memory to read frame\n");
SubGHzRadio.flushBuffer();
return;
}
SubGHzRadio.readFrame(rxFrame);
postTask(printRxDone, (
void *) rxFrame);
}
printf("Channel Busy!!\n");
}
static void printRxStarted(void *args) {
printf(
"[%lu.%06lu] Rx is started... (%d dB)\n",
(uint32_t) tRxStarted.tv_sec, tRxStarted.tv_usec, rssiRxStarted
);
}
static void taskRSSI(void *) {
struct timeval tNow;
gettimeofday(&tNow, nullptr);
printf("[%lu.%06lu] RSSI: %d dB\n", (uint32_t) tNow.tv_sec, tNow.tv_usec, SubGHzRadio.getRssi());
}
}
static void appStart() {
Serial.stopInput();
Serial.onReceive(eventKeyStroke);
SubGHzRadio.begin();
if (modem == 0) {
SubGHzRadio.setRadio(sf, bw, cr, true, iqInverted);
} else {
}
SubGHzRadio.setChannel(freq);
SubGHzRadio.onRxDone = eventOnRxDone;
SubGHzRadio.onChannelBusy = eventOnChannelBusy;
SubGHzRadio.wakeup();
}
static void askFrequency() {
printf("Enter frequency in unit of Hz [917100000]:");
Serial.onReceive(inputFrequency);
Serial.inputKeyboard(buf, sizeof(buf));
}
if (strlen(buf) == 0) {
freq = 917100000;
} else {
freq = (uint32_t) strtoul(buf, NULL, 0);
if (freq == 0) {
printf("* Invalid frequency.\n");
askFrequency();
return;
}
}
printf("* Frequency: %lu\n", freq);
appStart();
}
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);
askFrequency();
}
static void askIQ() {
printf("Set IQ (1:normal, 2:inverted) [1]:");
Serial.onReceive(inputIQ);
Serial.inputKeyboard(buf, sizeof(buf));
}
if (strlen(buf) == 0 || strcmp(buf, "1") == 0) {
printf("* Normal selected.\n");
iqInverted = false;
} else if (strcmp(buf, "2") == 0) {
printf("* Inverted selected.\n");
iqInverted = true;
} else {
printf("* Unknown IQ mode\n");
askIQ();
return;
}
askSyncword();
}
static void askBW() {
printf("Set bandwidth (1:125kHz, 2:250kHz, 3:500kHz) [1]:");
Serial.onReceive(inputBW);
Serial.inputKeyboard(buf, sizeof(buf));
}
if (strlen(buf) == 0 || strcmp(buf, "1") == 0) {
printf("* 125kHz selected.\n");
} else if (strcmp(buf, "2") == 0) {
printf("* 250kHz selected.\n");
} else if (strcmp(buf, "3") == 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: ");
for (uint8_t i = 0; i < strlen(buf); i++) {
printf(" 0x%02x", buf[i]);
}
printf("\n");
askSF();
return;
}
askBW();
}
static void askModem() {
printf("Select modem (1: LoRa, 2:FSK) [1]:");
Serial.onReceive(inputModem);
Serial.inputKeyboard(buf, sizeof(buf));
}
if (strlen(buf) == 0 || strcmp(buf, "1") == 0) {
printf("* LoRa selected.\n");
modem = 0;
askSF();
} else if (strcmp(buf, "2") == 0) {
printf("* FSK selected.\n");
modem = 1;
appStart();
} else {
printf("* Unknown modem\n");
askModem();
}
}
void setup(void) {
Serial.begin(115200);
printf("\n*** [PLM150] Sub GHz Radio Rx Control Example ***\n");
#if 1
Serial.listen();
askModem();
#else
modem = 0;
iq = true;
syncword = 0x12;
appStart();
#endif
}
무선 패킷
Definition RadioPacket.hpp:59
int8_t snr
수신시의 Signal-to-Noise Ratio (SNR)
Definition RadioPacket.hpp:197
struct RadioPacket::@261372047013264035370155367365124341065140254135::@317161317014221262277246104165151362370372262302 LoRa
modulation 이 Radio::MOD_LORA 인 경우 사용되는 변수
union RadioPacket::@261372047013264035370155367365124341065140254135 meta
변복조 방식에 대한 속성
@ 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)
타이머 만료시 실행시킬 작업함수를 지정합니다.
void reboot()
소프트웨어 리셋을 통하여 시스템을 재시작합니다.
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
struct timeval timeEnteredISR
인터럽트가 발생하고 MCU가 ISR에 진입했을 때의 timestamp.
Definition nola-common.h:570