p2p+rssi

Dependencies:   pulga-lorawan-drv SX1272

serial_cmds.cpp

Committer:
afzalsamira
Date:
2021-07-08
Revision:
20:0f0e32d0332c
Parent:
18:245a2285053c

File content as of revision 20:0f0e32d0332c:

#include "serial.h"

bool SerialCommandRun(const char *msg, int msg_len)
{
    char Option = msg[1]; /// recebo opcao
    
    switch (Option)
    {
    case CMD_PRINT_GPS:
        {
            gps_navPVT gps_data;
            gps_data = get_struct();
            pc.printf("<s%d,%d+%d/%d/%d-%d:%d:%d>\n", (int)gps_data.lat, (int)gps_data.lon, (int)gps_data.year, (int)gps_data.month,(int)gps_data.day, (int)gps_data.hour, (int)gps_data.min, (int)gps_data.sec);
        
        break;}
        
    case CMD_SEND_HELLO:
        {
            pc.printf("hello word!\n");
        break;}
        
    case CMD_SEND_LORA_P2P:
        {
            pc.printf("\nmsg CMD_SEND_LORA_P2P: ");
            for (int i = 0; i < msg_len; i++)
                pc.printf("%c ", msg[i]);

            pc.printf("\n");
            // msg = <p2DATA, so + 3 selects only DATA\0, and -3 discounts the chars <p2
            send_msg((char*)(msg + 3), (uint8_t)(msg_len - 3));
        break;}
    }
    
    return true;
}