Skip to content

Commit

Permalink
iridium driver updates, SBDIX parsing broken but basics confirmed wor…
Browse files Browse the repository at this point in the history
…king
  • Loading branch information
Michael Shipman committed Mar 26, 2024
1 parent aab0c42 commit 05d6790
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
8 changes: 7 additions & 1 deletion Code/BITS/BITSv5/BITSv5.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@
#define LED_PIN 0

#define FRAM_CS 29

#define LOG_INIT_ADDR 8192

#define IR_TX_PIN 12
#define IR_RX_PIN 1
#define IR_CTS_PIN 2
#define IR_RTS_PIN 3
#define IR_NETAV_PIN 4
#define IR_RING_PIN 5

#define INCLUDE_DEBUG \
1 // controls if debug conditionals are included at compile time

Expand Down
35 changes: 31 additions & 4 deletions Code/BITS/BITSv5/iridium-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,27 @@
#define SBDRB_CMD "AT+SBDRB\r"
#define SBDRT_CMD "AT+SBDRT\r"
#define CGMR_CMD "AT+CGMR\r"
#define CGMM_CMD "AT+CGMM\r"
#define SBDWB_CMD "AT+SBDWB="

char sbd_rx_buf[120] = {0};
char sbd_tx_buf[120] = {0};

void IridiumSBD::get_info() {
printf("Writing CGMM\n");

uart_write_blocking(uart, (uint8_t *)CGMM_CMD, strlen(CGMM_CMD));

read_uart_until_return();
printf("%s\n", sbd_rx_buf);
read_uart_until_return();
printf("%s\n", sbd_rx_buf);
read_uart_until_return();
printf("%s\n", sbd_rx_buf);
read_uart_until_return();
printf("%s\n", sbd_rx_buf);
}

void IridiumSBD::start_session() {
int mo = 0;
int momsn = 0;
Expand All @@ -26,17 +42,26 @@ void IridiumSBD::start_session() {
int mt_queued = 0;
char trash[10] = {0};

uart_write_blocking(uart, SBDIX_CMD, strlen(SBDIX_CMD));
printf("Writing SBDIX\n");

read_uart_until_return();
uart_write_blocking(uart, (uint8_t *)SBDIX_CMD, strlen(SBDIX_CMD));

read_uart_until_return();
printf("%s\n", sbd_rx_buf);
read_uart_until_return();
printf("%s\n", sbd_rx_buf);

sscanf(sbd_rx_buf, "%s %d, %d, %d, %d, %d, %d", trash, mo, momsn, mt, mtmsn,
mt_len, mt_queued);

printf("Parsed values: %d, %d, %d, %d, %d, %d\n", mo, momsn, mt, mtmsn,
mt_len, mt_queued);

read_uart_until_return();
printf("%s\n", sbd_rx_buf);

read_uart_until_return();
printf("%s\n", sbd_rx_buf);
}

void IridiumSBD::write_SBD_text(char *data, uint len) {
Expand All @@ -54,7 +79,7 @@ void IridiumSBD::write_SBD_text(char *data, uint len) {
void IridiumSBD::get_SBD_status() {}

void IridiumSBD::read_SBD_text() {
uart_write_blocking(uart, SBDRT_CMD, strlen(SBDRT_CMD));
uart_write_blocking(uart, (uint8_t *)SBDRT_CMD, strlen(SBDRT_CMD));

read_uart_until_return();

Expand All @@ -66,7 +91,8 @@ void IridiumSBD::read_uart_until_return() {
uint pos = 0;

c = uart_getc(uart);
while (c != '\n' && c != '\r') {
// printf("%c", c);
while (c != '\n') { // c != '\n' && c != '\r' //c != '\n'
if (pos >= 119) {
printf("SBD read buf full\n");
pos = 119;
Expand All @@ -75,6 +101,7 @@ void IridiumSBD::read_uart_until_return() {
sbd_rx_buf[pos] = c;
pos++;
c = uart_getc(uart);
// printf("%c", c);
}
sbd_rx_buf[pos] = '\0';
}
21 changes: 12 additions & 9 deletions Code/BITS/BITSv5/iridium-lib.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef IRIDIUM_LIB_H
#define IRIDIUM_LIB_H

#include "hardware/uart.h"

// AT+SBDIX - Initiate an Short Burst Data session, i.e. talk to the satellites.
// Make sure you have loaded message data first. AT+SBDWT - Write text message
// into outbound buffer AT+SBDWB - Write binary data into outbound buffer
Expand All @@ -23,6 +25,15 @@ class IridiumSBD {
uint tx_pin;
uart_inst_t* uart;

struct sbd_status {
bool out_stat;
int next_seq_num;
bool in_stat;
int last_seq_num;
bool ring_alert;
int msg_waiting;
};

IridiumSBD(uart_inst_t* p, const uint rx, const uint cts, const uint rts,
const uint netav, const uint ring, const uint tx) {
rx_pin = rx;
Expand All @@ -32,15 +43,6 @@ class IridiumSBD {
ring_pin = ring;
tx_pin = tx;
uart = p;

struct sbd_status {
bool out_stat;
int next_seq_num;
bool in_stat;
int last_seq_num;
bool ring_alert;
int msg_waiting;
};
}

void start_session(void);
Expand All @@ -49,6 +51,7 @@ class IridiumSBD {
void read_SBD_text(void);
void read_SBD_binary(void);
void get_SBD_status(void);
void get_info(void);

private:
void read_uart_until_return(void);
Expand Down

0 comments on commit 05d6790

Please sign in to comment.