54 lines
1.1 KiB
C
54 lines
1.1 KiB
C
/*
|
|
* cm_nmea_decoder.c
|
|
*
|
|
* Created on: 26 Jun 2025
|
|
* Author: Christian Lind Vie Madsen
|
|
*/
|
|
|
|
#include "cm_nmea_decoder.h"
|
|
#include <string.h>
|
|
#define MAX_NMEA_MSG_TYPES 2
|
|
const char *nmea_msg_types[MAX_NMEA_MSG_TYPES] = {"$GPGLL", "$GPGFF"};
|
|
typedef int (*nmeaDecoder_Evt_fpt)(cm_nmea_msg_t *inst, char *str);
|
|
|
|
static int sGPGLL_decode(char *str){
|
|
|
|
//Move pointer until we meet a "," or NULL!
|
|
while((*str != ",") && (*str != NULL)) str++;
|
|
}
|
|
|
|
|
|
nmeaDecoder_Evt_fpt nmea_decodeFuncs[1] = {
|
|
|
|
};
|
|
|
|
static int sNMEA_getMsgType(char *str){
|
|
|
|
for(int i = 0; i < (MAX_NMEA_MSG_TYPES-1); i++){
|
|
|
|
if(strcmp(nmea_msg_types[i], str)) return i;
|
|
};
|
|
|
|
return -1;
|
|
}
|
|
|
|
int cm_nmea_characterDecode(char in){
|
|
|
|
|
|
|
|
}
|
|
|
|
// This function returns the message type, so the user knows which message has been decoded!
|
|
int cm_nmea_stringDecode(char *str){
|
|
|
|
// Find which type of message we need to decode.
|
|
int nmea_msg_idx = sNMEA_getMsgType(str);
|
|
|
|
// Check if we found a valid NMEA message.
|
|
if(nmea_msg_idx == -1) return nmea_msg_idx;
|
|
|
|
// Use the correct function to decode!
|
|
if(nmea_msg_idx >= 0) nmea_msg_types[nmea_msg](str);
|
|
|
|
}
|