Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

メイン電装統合 #19

Merged
merged 26 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/arduino_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ jobs:
version: latest
- name: Adafruit BNO055
version: latest
- name: TinyGPSPlus
version: latest
- source-url: https://github.com/uChip/MCP342X.git
- source-url: https://github.com/core-rocket/CCP.git
- source-url: https://github.com/core-rocket/Opener.git
- source-url: https://github.com/coryjfowler/MCP_CAN_lib.git
- source-url: https://github.com/771-8bit/W25Q512.git
- source-url: https://github.com/sdesalas/Arduino-Queue.h.git
Expand Down
105 changes: 105 additions & 0 deletions Ground/Ground.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#define Serial_ES920 Serial1
bool need_uplink = false;
String uplink_string = "";
typedef enum {
SENDING,
FREE
} MODE;
MODE mode = FREE;
uint32_t send_millis = millis();
uint32_t timeout_ms = 3000;

void setup() {

//Serial.setFIFOSize(64);
Serial.begin(115200);

Serial_ES920.begin(115200);
while (Serial_ES920.available()) {
Serial_ES920.read();
}
}

void loop() {

while (Serial.available()) {
uplink_string = Serial.readStringUntil('\n');
uplink_string.trim();
need_uplink = true;
}

if ((mode == FREE) && Serial_ES920.available()) {
String downlink = Serial_ES920.readStringUntil('\n');
// Serial.print("raw:");
// Serial.println(downlink);
downlink.trim();

char rssi_char[] = "FFFF";
downlink.substring(0, 4).toCharArray(rssi_char, 5);
int16_t rssi_long = rssi(rssi_char);

String downlink_ASCII = downlink.substring(4, downlink.length());

Serial.print(rssi_long);
Serial.print(",");
Serial.println(downlink_ASCII);

if (need_uplink) {
delay(50);
need_uplink = false;
Serial_ES920.println(uplink_string);
mode = SENDING;
send_millis = millis();
Serial.print("uplink ");
Serial.println(uplink_string);
}
}

if (mode == SENDING) {
if (Serial_ES920.available()) {
String response = Serial_ES920.readStringUntil('\n');
response.trim();
mode = FREE;
Serial.print("response from ES920LR:");
Serial.println(response);
}
if (millis() - send_millis > timeout_ms) {
mode = FREE;
Serial.print("timeout");
}
}
}

int16_t rssi(char *_rssi_char) {
char *e;
return strtol(_rssi_char, &e, 16) - 65536;
}

// GROUND
// configuration setting is below.
// -------------------------------------
// Node : EndDevice
// Band Width : 125kHz
// Spreading Factor : 11
// Effective Bitrate : 537bps
// Channel : 2
// PAN ID : 0001
// Own Node ID : 0001
// Destination ID : 0000
// Acknowledge : OFF
// Retry count : 3
// Transfer Mode : Payload
// Receive Node ID information : OFF
// RSSI information : ON
// Config/Operation : Operation
// UART baudrate : 115200
// Sleep Mode : No Sleep
// Sleep Time : 50
// Output Power : 13dBm
// Format : ASCII
// Send Time : 0
// Send Data :
// AES Key : 00000000000000000000000000000000
// RF Mode : TxRx
// Protocol Type : Private LoRa
// Rx Boosted : ON
Loading
Loading