Other features of PPS

Besides conveying the values of attributes, PPS can also signal when attributes and objects are deleted and when objects are created or truncated.

You can obtain this extra data by calling the pps_decoder_flags() function, which returns the flags associated with an object or attribute. These flags consist of any combination of the values in the enumeration pps_attrib_flags_t. For example, if it's possible for the gps object to be deleted, then before calling pps_decoder_push(), you might first do the following:

if ( pps_decoder_flags(&decoder, NULL) & PPS_DELETED ) {
   . . .

These flags are important when writing a program that acts as a PPS server. For example, to handle client connections and disconnections, you could use code such as:

char *clientid;
// The data read from pps isn't null-terminated, so we need to
// terminate it now.
buffer[len] = '\0';
pps_decoder_parse_pps_str(&decoder, buffer);
// Get the ID of this client
clientid = pps_decoder_name(&decoder);
if ( pps_decoder_flags(&decoder, NULL) & PPS_CREATED ) {
   // This is a new client
else if ( pps_decoder_flags(&decoder, NULL) & PPS_DELETED ) {
   // The client has just disconnected
else {
   // Regular message from client