Werkend proto

master
marcel 3 years ago
parent 0445ec5ab9
commit 1736691e77
  1. 2
      build/src/CMakeFiles/main.dir/CXX.includecache
  2. BIN
      build/src/CMakeFiles/main.dir/main.cpp.obj
  3. BIN
      build/src/main.bin
  4. 45806
      build/src/main.dis
  5. BIN
      build/src/main.elf
  6. 1420
      build/src/main.elf.map
  7. 7273
      build/src/main.hex
  8. BIN
      build/src/main.uf2
  9. 14
      src/Config.h
  10. 149
      src/main.cpp

@ -231,6 +231,8 @@ stdio.h
- -
string.h string.h
- -
time.h
-
pico/stdlib.h pico/stdlib.h
/home/marcel/Documents/electronische_projecten/lora_aprs_node_pico/src/pico/stdlib.h /home/marcel/Documents/electronische_projecten/lora_aprs_node_pico/src/pico/stdlib.h
pico/binary_info.h pico/binary_info.h

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

@ -18,6 +18,9 @@
#endif #endif
#define OFF 0
#define ON 1
const long serialBaudRate = 38400; const long serialBaudRate = 38400;
const int rssiOffset = 292; const int rssiOffset = 292;
@ -28,7 +31,7 @@
int loraPreamble = 8; int loraPreamble = 8;
int loraCodingRate = 5; int loraCodingRate = 5;
int loraTxPower = 17; int loraTxPower = 17;
int LoRaPaSelect = 0; int LoRaPaSelect = 1;
uint32_t loraBandwidth = 125E3; uint32_t loraBandwidth = 125E3;
uint32_t loraFrequency = 433775000; uint32_t loraFrequency = 433775000;
@ -67,4 +70,13 @@
uint8_t FirmwareVersion[20] = { 'V','1',',','C','o','n','t','r', 'o','l','l','e','r',' ','0','1', 0} ; uint8_t FirmwareVersion[20] = { 'V','1',',','C','o','n','t','r', 'o','l','l','e','r',' ','0','1', 0} ;
} AprsSettings; } AprsSettings;
struct status {
bool PowerSupply24V;
bool PowerSupply12V;
bool PowerSupply5V;
bool ControlRelay;
uint8_t StatusString[6] = { '0','0','0','0','0',0};
} Status;
#endif #endif

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <time.h>
#include "pico/stdlib.h" #include "pico/stdlib.h"
#include "pico/binary_info.h" #include "pico/binary_info.h"
#include "LoRa-RP2040.h" #include "LoRa-RP2040.h"
@ -12,14 +13,24 @@ void getPacketData(int packetLength);
int compare_strings(uint8_t a[], uint8_t b[]); int compare_strings(uint8_t a[], uint8_t b[]);
bool is_message_for_me (uint8_t data[], uint8_t mycall[]); bool is_message_for_me (uint8_t data[], uint8_t mycall[]);
/* declaration for receive functions */
uint16_t decode_packet (); uint16_t decode_packet ();
void ComposeAprsFrame(uint8_t payload[]);
/* declaration for transmit functions */
void ComposeAprsFrame(uint8_t payload[]);
bool TransmitRequest = false;
void transmit(); void transmit();
const uint PowerSupply24VControl = 6;
const uint PowerSupply12VControl = 5;
const uint PowerSupply5VControl = 4;
const uint RelayOffControl = 2;
const uint RelayOnControl = 3;
int main() { int main() {
uint16_t ServerCommand = 0; uint16_t ServerCommand = 0;
uint16_t TxDelay = 0;
/* Among others, this initializes the USB-serial port at 115200bps 8N1 */ /* Among others, this initializes the USB-serial port at 115200bps 8N1 */
stdio_init_all(); stdio_init_all();
@ -28,6 +39,31 @@ int main() {
memset(rxBuffer, 0, sizeof(rxBuffer)); memset(rxBuffer, 0, sizeof(rxBuffer));
memset(txBuffer, 0, sizeof(txBuffer)); memset(txBuffer, 0, sizeof(txBuffer));
gpio_init(PowerSupply24VControl);
gpio_init(PowerSupply12VControl);
gpio_init(PowerSupply5VControl);
gpio_init(RelayOffControl);
gpio_init(RelayOnControl);
gpio_set_dir(PowerSupply24VControl, GPIO_OUT);
gpio_set_dir(PowerSupply12VControl, GPIO_OUT);
gpio_set_dir(PowerSupply5VControl, GPIO_OUT);
gpio_set_dir(RelayOffControl, GPIO_OUT);
gpio_set_dir(RelayOnControl, GPIO_OUT);
gpio_put(PowerSupply24VControl, 0);
Status.PowerSupply24V = OFF;
gpio_put(PowerSupply12VControl, 0);
Status.PowerSupply12V = OFF;
gpio_put(PowerSupply5VControl, 1);
Status.PowerSupply5V = OFF;
gpio_put(RelayOffControl, 1);
sleep_ms(250);
gpio_put(RelayOffControl, 0);
gpio_put(RelayOnControl, 0);
Status.ControlRelay = OFF;
sleep_ms(5000); sleep_ms(5000);
LoadSettings(); LoadSettings();
@ -58,20 +94,101 @@ int main() {
if (ServerCommand) { if (ServerCommand) {
if (ServerCommand == 1) { switch(ServerCommand) {
ComposeAprsFrame(AprsSettings.FirmwareVersion);
// Wait for 100ms before responding case 1 :
sleep_ms(5000); ComposeAprsFrame(AprsSettings.FirmwareVersion);
transmit(); break;
sleep_ms(5000); // Send status of output pins
transmit(); case 6 :
sleep_ms(5000); if (Status.PowerSupply24V == ON)
transmit(); Status.StatusString[3] = '1';
sleep_ms(5000); else
transmit(); Status.StatusString[3] = '0';
if (Status.PowerSupply12V == ON)
Status.StatusString[2] = '1';
else
Status.StatusString[2] = '0';
if (Status.PowerSupply5V == ON)
Status.StatusString[1] = '1';
else
Status.StatusString[1] = '0';
if (Status.ControlRelay == ON)
Status.StatusString[0] = '1';
else
Status.StatusString[0] = '0';
ComposeAprsFrame(Status.StatusString);
// Switch off 24V power supply
case 30 :
gpio_put(PowerSupply24VControl, 0);
Status.PowerSupply24V = OFF;
break;
// Switch on 24V power supply
case 31 :
gpio_put(PowerSupply24VControl, 1);
Status.PowerSupply24V = ON;
break;
// Switch off 12V power supply
case 32 :
gpio_put(PowerSupply12VControl, 0);
Status.PowerSupply12V = OFF;
break;
// Switch on 12V power supply
case 33 :
gpio_put(PowerSupply12VControl, 1);
Status.PowerSupply12V = ON;
break;
// Switch off 5V power supply
case 34 :
gpio_put(PowerSupply5VControl, 1);
Status.PowerSupply5V = OFF;
break;
// Switch on 5V power supply
case 35 :
gpio_put(PowerSupply5VControl, 0);
Status.PowerSupply5V = ON;
break;
// Switch off relay
case 36 :
gpio_put(RelayOffControl, 1);
sleep_ms(250);
gpio_put(RelayOffControl, 0);
Status.ControlRelay = OFF;
break;
// Switch on 24V relay
case 37 :
gpio_put(RelayOnControl, 1);
sleep_ms(250);
gpio_put(RelayOnControl, 0);
Status.ControlRelay = ON;
break;
default :
break;
} }
ServerCommand = 0; ServerCommand = 0;
} }
/* A message is ready to be send */
if (TransmitRequest) {
if ( TxDelay == 0 ) {
// Generate pseudo random value between 0-1024
TxDelay = time_us_32()&0x3FF;
}
/* If TxDelay times out: send message */
if ( TxDelay-- == 1 ) {
transmit();
TransmitRequest = false;
}
}
} }
return 0; return 0;
@ -290,9 +407,6 @@ uint16_t decode_packet ()
printf("Message from server: %s (command %u)\n", aprs_message, aprs_server_command); printf("Message from server: %s (command %u)\n", aprs_message, aprs_server_command);
if (aprs_acknowledge_request) { if (aprs_acknowledge_request) {
ComposeAprsFrame(aprs_acknowledge_number); ComposeAprsFrame(aprs_acknowledge_number);
// Wait for 100ms before responding with acknowledge
sleep_ms(100);
transmit();
printf("Acknowledge request: %s\n", aprs_acknowledge_number); printf("Acknowledge request: %s\n", aprs_acknowledge_number);
} }
@ -364,6 +478,8 @@ void ComposeAprsFrame(uint8_t payload[])
uint16_t BufferPosition = 0; uint16_t BufferPosition = 0;
uint16_t cnt = 0; uint16_t cnt = 0;
memset(txBuffer, 0, sizeof(txBuffer));
// APRS header // APRS header
txBuffer[BufferPosition++] = '<'; txBuffer[BufferPosition++] = '<';
txBuffer[BufferPosition++] = 0xff; txBuffer[BufferPosition++] = 0xff;
@ -411,6 +527,9 @@ void ComposeAprsFrame(uint8_t payload[])
txBuffer[BufferPosition++] = payload[cnt]; txBuffer[BufferPosition++] = payload[cnt];
cnt++; cnt++;
} }
// Set variable to indicate a send request
TransmitRequest = true;
printf("%s\n", txBuffer); printf("%s\n", txBuffer);
} }

Loading…
Cancel
Save