/* encode type 1002: extended L1-only gps rtk observables --------------------*/ static int encode_type1002(rtcm_t *rtcm, int sync) { int i, j; int code1, pr1, ppr1, lock1, amb, cnr1; /* encode header */ i = encode_head(1002, rtcm, sync, rtcm->n); for (j = 0; j < rtcm->n; j++) { /* generate obs field data gps */ gen_obs_gps(rtcm, &(rtcm->obs[j]), &code1, &pr1, &ppr1, &lock1, &amb, &cnr1); setbitu(rtcm->buff, i, 6, rtcm->obs[j].prn+1 ); i += 6; setbitu(rtcm->buff, i, 1, code1); i += 1; setbitu(rtcm->buff, i, 24, pr1 ); i += 24; setbits(rtcm->buff, i, 20, ppr1 ); i += 20; setbitu(rtcm->buff, i, 7, lock1); i += 7; setbitu(rtcm->buff, i, 8, amb ); i += 8; setbitu(rtcm->buff, i, 8, cnr1 ); i += 8; } rtcm->nbit = i; return 1; }
/** Encode an RTCMv3 message type 1002 (Extended L1-Only GPS RTK Observables) * Message type 1002 has length `64 + n_sat*74` bits. Returned message length * is rounded up to the nearest whole byte. * * \param buff A pointer to the RTCM data message buffer. * \param id Reference station ID (DF003). * \param t GPS time of epoch (DF004). * \param n_sat Number of GPS satellites included in the message (DF006). * \param nm Struct containing the observation. * \param sync Synchronous GNSS Flag (DF005). * \return The message length in bytes. */ u16 rtcm3_encode_1002(u8 *buff, u16 id, gps_time_t t, u8 n_sat, navigation_measurement_t *nm, u8 sync) { rtcm3_write_header(buff, 1002, id, t, sync, n_sat, 0, 0); u16 bit = 64; /* Start at end of header. */ u32 pr; s32 ppr; u8 amb, lock, cnr; for (u8 i=0; i<n_sat; i++) { gen_obs_gps(&nm[i], &amb, &pr, &ppr, &lock, &cnr); setbitu(buff, bit, 6, nm[i].sid.sat); bit += 6; /* TODO: set GPS code indicator if we ever support P(Y) code measurements. */ setbitu(buff, bit, 1, 0); bit += 1; setbitu(buff, bit, 24, pr); bit += 24; setbits(buff, bit, 20, ppr); bit += 20; setbitu(buff, bit, 7, lock); bit += 7; setbitu(buff, bit, 8, amb); bit += 8; setbitu(buff, bit, 8, cnr); bit += 8; } /* Round number of bits up to nearest whole byte. */ return (bit + 7) / 8; }