@@ -114,6 +114,15 @@ typedef enum
114114 SFE_UBLOX_PACKET_NOTACKNOWLEDGED // This indicates that we received a NACK
115115} sfe_ublox_packet_validity_e;
116116
117+ // Identify which packet buffer is in use:
118+ // packetCfg (or a custom packet), packetAck or packetBuf
119+ typedef enum
120+ {
121+ SFE_UBLOX_PACKET_PACKETCFG,
122+ SFE_UBLOX_PACKET_PACKETACK,
123+ SFE_UBLOX_PACKET_PACKETBUF
124+ } sfe_ublox_packet_buffer_e;
125+
117126// Registers
118127const uint8_t UBX_SYNCH_1 = 0xB5 ;
119128const uint8_t UBX_SYNCH_2 = 0x62 ;
@@ -729,13 +738,21 @@ class SFE_UBLOX_GPS
729738
730739 boolean _printDebug = false ; // Flag to print the serial commands we are sending to the Serial port for debug
731740
741+ // The packet buffers
732742 // These are pointed at from within the ubxPacket
733- uint8_t payloadAck[2 ];
734- uint8_t payloadCfg[MAX_PAYLOAD_SIZE];
743+ uint8_t payloadAck[2 ]; // Holds the requested ACK/NACK
744+ uint8_t payloadCfg[MAX_PAYLOAD_SIZE]; // Holds the requested data packet
745+ uint8_t payloadBuf[2 ]; // Temporary buffer used to screen incoming packets (same size as Ack)
735746
736- // Init the packet structures and init them with pointers to the payloadAck and payloadCfg arrays
747+ // Init the packet structures and init them with pointers to the payloadAck, payloadCfg and payloadBuf arrays
737748 ubxPacket packetAck = {0 , 0 , 0 , 0 , 0 , payloadAck, 0 , 0 , SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
738749 ubxPacket packetCfg = {0 , 0 , 0 , 0 , 0 , payloadCfg, 0 , 0 , SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
750+ ubxPacket packetBuf = {0 , 0 , 0 , 0 , 0 , payloadBuf, 0 , 0 , SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
751+
752+ // Identify which buffer is in use
753+ // Data is stored in packetBuf until the requested class and ID can be validated
754+ // If a match is seen, data is diverted into packetAck or packetCfg
755+ sfe_ublox_packet_buffer_e activePacketBuffer = SFE_UBLOX_PACKET_PACKETBUF;
739756
740757 // Limit checking of new data to every X ms
741758 // If we are expecting an update every X Hz then we should check every half that amount of time
0 commit comments