Commit 65c85224 authored by Guillaume Gonnet's avatar Guillaume Gonnet
Browse files

Example tmp app.

parent f09418e6
......@@ -52,6 +52,9 @@ USEMODULE += periph_eeprom
USEMODULE += periph_uart
USEMODULE += periph_i2c
# TMP.
FEATURES_REQUIRED += periph_rtc
# Source directory is "src".
DIRS += src
......
......@@ -14,6 +14,8 @@ This project is under the MIT license
#include "commands/commands.h"
#include "benchmark/benchmark.h"
#include <periph/rtc.h>
#include <periph/uart.h>
#include <xtimer.h>
extern gps_data_t gps_data;
......@@ -23,13 +25,35 @@ extern gps_data_t gps_data;
// TMP: send a ping message.
static void send_message(void)
{
bm_encode_payload(9, 0, 1);
bm_encode_payload(9, 5, 1);
puts("Sending message ...");
pvd_send(&pvd_orange_cmd, &bm_payload);
puts("Message sent!");
xtimer_usleep(50 * 1000); // 50 ms
}
static kernel_pid_t pid;
static void rtc_cb(void *arg)
{
(void) arg;
uart_poweron(UART_DEV(0));
thread_wakeup(pid);
}
static void setup_rtc(void)
{
struct tm time;
rtc_get_time(&time);
time.tm_min += 3;
mktime(&time);
rtc_set_alarm(&time, rtc_cb, NULL);
}
// Entry point of the whole application.
int main(void)
......@@ -40,21 +64,35 @@ int main(void)
lorariot_init();
ds75_init();
cmds_init();
// cmds_init();
#if RESET_ON_START
// If enable, reset all providers when the application starts.
// pvd_reset_all();
#endif
xtimer_sleep(3);
uint32_t start = xtimer_now_usec();
pid = thread_getpid();
while (true) {
xtimer_sleep(15);
for (int i = 0; i < 3; i++)
send_message();
for (int i = 0; i < 1; i++) {
send_message();
//xtimer_usleep(50 * 1000); // 50 ms
setup_rtc();
uart_poweroff(UART_DEV(0));
thread_sleep();
}
uint32_t stop = xtimer_now_usec();
printf("Time: %ld ms\n", (stop - start) / 1000);
// xtimer_sleep(3);
// uint32_t start = xtimer_now_usec();
// for (int i = 0; i < 10; i++) {
// send_message();
// //xtimer_usleep(50 * 1000); // 50 ms
// }
// uint32_t stop = xtimer_now_usec();
// printf("Time: %ld ms\n", (stop - start) / 1000);
}
......@@ -31,3 +31,9 @@ This project is under the MIT license
#define TTN_BM_NWKSKEY { 0xFC, 0x68, 0xF3, 0xCE, 0xB2, 0x02, 0xBE, 0xAE, 0x8E, 0xB3, 0x22, 0xC5, 0xE1, 0x62, 0x83, 0xFC }
#define TTN_BM_APPSKEY { 0x2B, 0x3F, 0xC3, 0xAB, 0xD1, 0x94, 0xE4, 0xCE, 0x11, 0x61, 0xA8, 0xE1, 0xE0, 0xFD, 0x59, 0xE1 }
// TTN provider for ping.
#define TTN_PING_DEVADDR 0x26011C80
#define TTN_PING_NWKSKEY { 0xAC, 0x9C, 0xA3, 0x48, 0x5A, 0x3B, 0xCA, 0x61, 0xA1, 0xEB, 0x67, 0x8F, 0xDB, 0xC9, 0x15, 0x39 }
#define TTN_PING_APPSKEY { 0x5F, 0x7D, 0xC6, 0xE6, 0x99, 0x06, 0xF1, 0x53, 0x45, 0xE5, 0xFD, 0x06, 0x83, 0x3F, 0x96, 0x33 }
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