C Language Development Kit/Functions/ClearGpsReceiver

From OptiWiki

Jump to: navigation, search
Description Clears the GPS receive buffer inside the OPL9713.
Syntax
void ClearGpsReceiver(void);
Arguments None
Returns None
Remarks The GPS module inside the terminal transmits the NMEA-0183 protocol.
Example
//
// gps bluetooth server 
// transmits NMEA-0183 protocol from GPS receiver through bluetooth
// This sample can be used as an external GPS receiver.
//
// REMARK: This sample will drain the batteries quickly!!
//
#include <stdio.h>
#include "lib.h"
 
void main( void )
{
    int ch;
 
    //
    // Set local bluetooth name
    //
    SetBltLocalName("SuperGPS");
 
    //
    // Open the bluetooth port as server
    //
    comopen( COM5 );
    for(;;)
    {
        //
        // Wait for an incomming bluetooth connection
        //
        while( blt_is_connected() != TRUE)
        {
            delay( 50 );
            goodreadled( RED, 20);
            idle();
        }
        sound( TSTANDARD, VHIGH, SERROR, SLOW, SMEDIUM, SHIGH, SLOW, SMEDIUM, SHIGH, 0);
        //
        // Turn the GPS module ON
        //
        GpsPower( ON);
        ClearGpsReceiver(); // Clear the receive buffer
        while( blt_is_connected() == TRUE)
        {
            //
            // All all data from the GPS buffer
            //
            if( ( ch = ReadGps()) < 0)
            {
                idle();
                continue;
            }
            putcom( ch );
        }
        //
        // Bluetooth connection lost, turn the GPS module OFF
        //
        GpsPower( OFF );
        sound( TSTANDARD, VHIGH, SERROR, 0);
    }
}


Views
Personal tools