Commit 4b537b27 authored by Guillaume Gonnet's avatar Guillaume Gonnet
Browse files

Start implementing GPS decoder.

parent fc39198b
......@@ -29,6 +29,9 @@ USEMODULE += loramac-mac
USEMODULE += loramac-region
USEMODULE += loramac-crypto
# Application dependencies.
USEMODULE += periph_uart
# Source directory is "src".
DIRS += src
......
# Benchmark with IM880B / RIOT OS
https://drive.google.com/drive/folders/1O97FAvNMbrU97v5Ol_Z1yQX8Y1GhPaNc?usp=sharing
## Cloning this repository
```sh
git clone --recurse-submodules git@gitlab.ensimag.fr:lorawan-bm/riot-im880b.git
cd riot-im880b
chmod u+x ./apply-patches.sh
./apply-patches.sh
```
## Architecture of the application
```sh
▶ RIOT # Submodule containing RIOT OS
▶ patches # Patches to apply on RIOT sources
▶ src
├── app # Application sources
├── loramac # LoRaMAC-node sources
└── lorariot # RIOT adapter for LoRaMAC-node
```
#!/bin/bash
#
# Apply Git patches on RIOT repository.
#
# Copyright (C) 2019, ENSIMAG students
# This project is under the MIT license
cd "$(dirname "$0")"
for patch in ./patches/*.patch; do
git apply "$patch"
done
#
# LoRaMAC-node MAC module.
# Main sources module.
#
# Copyright (C) 2019, ENSIMAG students
# This project is under the MIT license
......
/*
Manage device activation via OTAA or ABP.
Copyright (C) 2019, ENSIMAG students
This project is under the MIT license
*/
\ No newline at end of file
typedef struct {
mutex_t mutex;
bool is_parsing;
} gps_isr_info_t;
extern gps_isr_info_t gps_isr_info;
/*
Decode GPS data.
Copyright (C) 2019, ENSIMAG students
This project is under the MIT license
*/
gps_isr_info_t gps_isr_info = { MUTEX_INIT };
uint8_t gps_parse_data()
{
}
/*
Implement stdio and fetch GPS data.
Manage UART: implement stdio and fetch GPS data.
Copyright (C) 2019, ENSIMAG students
This project is under the MIT license
......@@ -8,39 +8,54 @@ This project is under the MIT license
*/
#include <mutex.h>
#include <periph/uart.h>
#include <stdio.h>
#include <stdbool.h>
typedef struct {
mutex_t mutex = MUTEX_INIT;
} gps_isr_info_t;
// UART configuration.
#define STD_DEV UART_DEV(0)
#define STD_BAUDRATE 9600
static gps_isr_info_t gps_isr_info;
//
// Handle
static void gps_isr(gps_isr_info_t *info, char c)
{
mutex_unlock(&info->mutex);
if (info->is_parsing)
return; // Ignore new GPS data while parsing an old one.
if ((c == '$') || (c->line_length >= 127))
c->line_length = 0;
c->line[c->line_length++] = c;
if (c == '\n') {
c->line[c->line_length++] = '\0';
mutex_unlock(&info->mutex);
}
}
// STDIN is disabled in our application.
ssize_t stdio_read(void *buffer, size_t count)
{
(void)buffer; (void)count;
return 0;
}
// Write STDOUT data to serial port 0.
ssize_t stdio_write(const void *buffer, size_t len)
{
uart_write(STDIO_UART_DEV, (const uint8_t *)buffer, len);
uart_write(STD_DEV, (const uint8_t *)buffer, len);
return len;
}
// Initialize STDIO module.
void stdio_init(void)
{
uart_init(STDIO_UART_DEV, STDIO_UART_BAUDRATE, (uart_rx_cb_t)gps_isr, &gps_isr_info);
uart_init(STD_DEV, STD_BAUDRATE, (uart_rx_cb_t)gps_isr, &gps_isr_info);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment