111 lines
2.2 KiB
C++
111 lines
2.2 KiB
C++
#include "RadioLib/Module.h"
|
|
#include "RadioLib/modules/SX126x/SX1262.h"
|
|
#include "RadioLib/protocols/PhysicalLayer/PhysicalLayer.h"
|
|
#include "pico/stdlib.h"
|
|
// #include "FreeRTOS.h"
|
|
// #include "task.h"
|
|
#include <pico/error.h>
|
|
#include <pico/stdio.h>
|
|
#include <pico/time.h>
|
|
#include <RadioLib/RadioLib.h>
|
|
#include <RadioLib/>
|
|
#include <stddef.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/_intsup.h>
|
|
#include <sys/_types.h>
|
|
#include "stdio.h"
|
|
|
|
const char NULLCHAR = '\0';
|
|
|
|
char* read_buffer;
|
|
/*
|
|
int readInput() {
|
|
unsigned int len = 0;
|
|
int ret;
|
|
unsigned char ret_char;
|
|
while(true) {
|
|
ret = getchar_timeout_us(0);
|
|
if (ret == PICO_ERROR_TIMEOUT) {
|
|
continue;
|
|
} else {
|
|
ret_char = (char)ret;
|
|
printf("%c", ret);
|
|
sleep_ms(50);
|
|
if (ret_char & 0xE0) {
|
|
memcpy(read_buffer+len*sizeof(char), &ret_char, sizeof(char));
|
|
sleep_ms(50);
|
|
len++;
|
|
} else {
|
|
bool should_break = false;
|
|
if (len==0) { continue; }
|
|
switch(ret_char) {
|
|
case 8:
|
|
len--;
|
|
break;
|
|
case 10:
|
|
case 13:
|
|
should_break = true;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
if (should_break) { break; }
|
|
}
|
|
}
|
|
}
|
|
memcpy(read_buffer+len*sizeof(char), &NULLCHAR, sizeof(char));
|
|
sleep_ms(50);
|
|
return len;
|
|
}
|
|
|
|
int main2() {
|
|
stdio_init_all();
|
|
int num;
|
|
int len;
|
|
read_buffer = malloc(256 * sizeof(char));
|
|
while(true) {
|
|
printf("Give a number: \n");
|
|
sleep_ms(50);
|
|
num = readInput();
|
|
if (num) {
|
|
printf("Printed %d characters: ", num);
|
|
printf("%s\n", read_buffer);
|
|
} else {
|
|
printf("Got empty line\n");
|
|
}
|
|
sleep_ms(50);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
*/
|
|
|
|
int main() {
|
|
// Currently written as numbered 1-40th pin on Pico
|
|
SX1262 radio = new Module(5, 26, 20, 4);
|
|
ConfigLoRa_t config;
|
|
config.frequency = 915;
|
|
int state = radio.begin(config);
|
|
if (state == RADIOLIB_ERR_NONE) {
|
|
printf("LoRa module initialized\n");
|
|
while(true) {
|
|
state = radio.startTransmit("Howdiddly doo");
|
|
if (state == RADIOLIB_ERR_NONE) {
|
|
printf("Transmitted properly!\n");
|
|
} else {
|
|
printf("Transmission failed\n");
|
|
}
|
|
sleep_ms(2000);
|
|
}
|
|
} else {
|
|
printf("Could not initialize LoRa module\n");
|
|
while(true) {
|
|
printf("Fuuuuuck\n");
|
|
sleep_ms(2000);
|
|
}
|
|
}
|
|
|
|
|
|
}
|