GPS application and development of Beidou dual-mode technology -data structure extension
or from the Gps.h header file, first of all gpssvstatus structure needs to be modified, gpssvstatus at that time is designed to consider the storage of GPS satellite information, but we are now to store two-mode data, so we need to expand the structure, how to expand it?
Of course, the price is small, can not be completely overturned, the author thought of is to increase the number of Beidou satellite variables, as well as the Beidou Epemeris, Almanac, there is a positioning mask, the former members of the data structure are all using GPS storage, so that they are independent of each other, but sv_ List the author is lazy common, just to expand this array one-fold, the latter half of the information storage Beidou, so that the first step even if completed. Basically the following:
/** Maximum number of SVs for Gps_sv_status_callback (). */-#define GPS_MAX_SVS 32+ #define GPS_MAX_SVS -/** requested operational mode for GPS operation. */typedef uint32_t gpspositionmode;@@ -306,6 +306,25 @@ typedef struct { * were used for computing the most recent position fix. */ uint32_t used_in_fix_mask;++/** number of BD SVs currently visible. */+ int Bd_num_svs; + + /** represents a bit mask indicating which svs+ * have ephemeris data.+ */+ uint32_t bd_ ephemeris_mask;++ /** represents a bit mask indicating which svs+ * have almanac data.+ */+ uint32_t bd_almanac_mask;++ /**+ * Represents a bit mask indicating which svs+ * were used for computing the M OST recent position fix.+ */+ uint32_t bd_used_in_fix_mask; } Gpssvstatus;
The resolution itself is not very difficult, according to gourd painting scoop, are fixed. Then look at GSV how to parse it! as follows:
if (!memcmp (TOK.P, "GSV", 3)) {int nosatellites; Token Satellite_to_view;is_beidou =!memcmp (PTR, "BD", 2); Satellite_to_view = Nmea_tokenizer_get (Tzer, 3); Nosatellites = Str2Int (SATELLITE_TO_VIEW.P, satellite_to_view.end); ALOGV (">>>is_beidou (%d) GSV satellite_to_view=%d", Is_beidou, nosatellites); if (Nosatellites > 0) {//tmp int sentence, totalsentences, Curr, I, bd_cur; Token num_of_msg; Token No; Num_of_msg = Nmea_tokenizer_get (Tzer, 1); No = Nmea_tokenizer_get (Tzer, 2); Sentence = Str2Int (NO.P, no.end); Totalsentences = Str2Int (NUM_OF_MSG.P, num_of_msg.end); D (">>>gsv_index=%d,gsv_total=%d", sentence, totalsentences); if (sentence = = 1 &&!is_beidou) {R->sv_status.num_svs = 0; R->sv_status.ephemeris_mask = 0ul; R->sv_status.almanac_mask = 0ul; r->sv_status.bd_num_svs= 0; R->sv_status.bd_ephemeris_mask= 0ul; R->sv_status.bd_almanac_mask= 0ul;} Curr = R->sv_status.num_svs;bd_cur = R->sv_status.bd_num_svs + 32; i = 0; while (I < 4 && (R->sv_status.num_svs < Nosatellites | | (Is_beidou && R->sv_status.bd_num_svs < nosatellites))) {int prn; Token tok_prn = Nmea_tokenizer_get (Tzer, I * 4 + 4); Token tok_elevation = Nmea_tokenizer_get (Tzer, I * 4 + 5); Token Tok_azimuth = Nmea_tokenizer_get (Tzer, I * 4 + 6); Token Tok_snr = Nmea_tokenizer_get (Tzer, I * 4 + 7); PRN = Str2Int (TOK_PRN.P, tok_prn.end); if (prn <= 0) {i + = 1; continue;} if (Is_beidou) {if (PRN >) PRN-= 400;//m8 BD base 400r->sv_status.sv_list[bd_cur].prn = Prn;r->sv_statUs.sv_list[bd_cur].elevation = Str2float (TOK_ELEVATION.P, tok_elevation.end); R->sv_status.sv_list[bd_cur]. Azimuth = Str2float (TOK_AZIMUTH.P, tok_azimuth.end); R->sv_status.sv_list[bd_cur].snr = Str2float (TOK_SNR.P, Tok_ Snr.end) r->sv_status.bd_ephemeris_mask|= (1ul << (prn-1)) r->sv_status.bd_almanac_mask|= (1ul << (prn-1)); r->sv_status.bd_num_svs+= 1;//bd num R->SV_STATUS.NUM_SVS + = 1;//total num if (r->s V_status.sv_list[bd_cur].snr > 0) alogv ("**bd_cur=%d num_svs:%d prn:%d snr=%f\n", Bd_cur, R->s V_status.num_svs, R->sv_status.sv_list[bd_cur].prn,r->sv_status.sv_list[bd_cur].snr); Bd_cur + = 1; } else {r->sv_status.sv_list[curr].prn = PRN; R->sv_status.sv_list[curr].elevation = Str2float (TOK_ELEVATION.P, tok_elevation.end); R->sv_status.sv_list[curr].azimuth = Str2float (tok_AZIMUTH.P, Tok_azimuth.end); R->sv_status.sv_list[curr].snr = Str2float (TOK_SNR.P, tok_snr.end); R->sv_status.ephemeris_mask |= (1ul << (prn-1)); R->sv_status.almanac_mask |= (1ul << (prn-1)); R->sv_status.num_svs + = 1;if (R->sv_status.sv_list[curr].snr > 0) alogv ("# #curr =%d num_svs:%d P rn:%d snr=%f\n ", Curr, R->sv_status.num_svs, r->sv_status.sv_list[curr].prn,r->sv_ STATUS.SV_LIST[CURR].SNR); Curr + = 1; } i + = 1; }
Other Gga These two-mode non-dual mode are the same. Below we see in Jni, Android_location_gpslocationprovider_read_sv_status reported the situation of the various satellites, show his interface also need to be modified, to expand, as follows:
@@ -465,17 +465,34 @@ -465,17 jint android_location_gpslocationprovider_read_sv_status (jnienv* env, job jfloat* Elev = Env->getfloatarrayelements (Elevarray, 0); jfloat* Azim = env->getfloatarrayelements (azumarray, 0); jint* mask = env->getintarrayelements (Maskarray, 0); + int I, J; int Num_svs = sgpssvstatus.num_svs;-for (int i = 0; i < Num_svs; i++) {+ int bd_num_svs = SGPSSVSTATUS.BD_NUM_SV s;++//gps info+ for (i = 0; i < (NUM_SVS-BD_NUM_SVS); i++) {prns[i] = sgpssvstatus.sv_list[i].prn; Snrs[i] = Sgpssvstatus.sv_list[i].snr; Elev[i] = sgpssvstatus.sv_list[i].elevation; Azim[i] = Sgpssvstatus.sv_list[i].azimuth; }++//bd info+ for (j = 0; J < Bd_num_svs; J + +) {+ Prns[i+j] = sgpssvstatus.sv_list[32+j].prn;+ Snr S[I+J] = sgpssvstatus.sv_list[32+j].snr;+ Elev[i+j] = sgpssvstatus.sv_list[32+j].elevation;+ Azim[i+j] = sGp ssvstatus.sv_list[32+j].azimuth;+}+ Mask[0] = Sgpssvstatus.ephemeris_mask; MASK[1] = Sgpssvstatus.almanac_mask; MASK[2] = sgpssvstatus.used_in_fix_mask;+ mask[3] = Bd_num_svs; + mask[4] = sgpssvstatus.bd_ephemeris_mask;+ mask[5] = sgpssvstatus.bd_almanac_mask;+ mask[6] = SGpsSvStatus.bd_u Sed_in_fix_mask;
This JNI interface directly to the GPS location provider, the same to expand
@@ -1285,7 +1285,9 @@ -1285,7 class Gpslocationprovider implements Locationproviderinterface {try { Listener.mListener.onSvStatusChanged (Svcount, MSVs, Msnrs, Msvelevations, Msvazi Muths, msvmasks[ephemeris_mask],-Msvmasks[almanac_mask], msvmasks[used_for_fix_mask]); + Msvmasks[almanac_mask], msvmasks[used_for_fix_mask],+ Msvmasks[bd_svs_num] , msvmasks[bd_ephemeris_mask],+ Msvmasks[bd_almanac_mask],msvmasks[bd_used_for_fix_mask]); } catch (RemoteException e) {LOG.W (TAG, "remoteexception in Reportsvinfo"); Mlisteners.remove (listener); @@ -1296,22 +1298,33 @@ -1296,22 class Gpslocationprovider implements Locationprovideri Nterface {} if (VERBOSE) {-LOG.V (tag, "SV Count:" + Svcount + + LOG.D (tag, "SV Co UNT: "+ Svcount + "Ephemerismask:" + integer.tohexstring (Msvmasks[ephemeris_mask]) + "Almanacmask:" + I Nteger.tohexstring (Msvmasks[almanac_mask])); for (int i = 0; i < Svcount; i++) {-LOG.V (TAG, "SV:" + msvs[i] + + if (I & Lt (Svcount-msvmasks[bd_svs_num])) {+ LOG.D (TAG, "SV:" + msvs[i] + "Snr:" + MSNRS[I]/10 + " Elev: "+ msvelevations[i] +" azimuth: "+ msvazimuths[i] + ((msvmasks[e Phemeris_mask] & (1 << (msvs[i)-1)) = = 0? "": "E") + ((Msvmasks[almanac_mask] & (1 << (Msvs[i]-1)) = = 0? "": "A") + ((Msvmasks[used_for_fix_mask] & (1 << (msvs[i)-1)) = = 0? "": "U")); +} else {+ + LOG.D (TAG, "BD sv:" + msvs[i) + + "BD Snr:" +MSNRS[I]/10 + + "BD Elev:" + msvelevations[i] + + "BD Azimuth:" + msvazimuths[i] + + ((msvmasks[bd_ephemeris_mask) & (1 <& Lt (Msvs[i]-1))) = = 0? "": "E") + + ((Msvmasks[bd_almanac_mask] & (1 << (Msvs[i]-1)) = = 0? "": "A") + + ((Msvmasks[bd_used_for_fix_mask] & (1 << (Msvs[i]-1))) = = 0? "" ":" U ")); +}}}//Return number of sets used in fix instead of total- UpdateStatus (Mstatus, Integer.bitcount (Msvmasks[used_for_fix_mask])); + UpdateStatus (Mstatus, (Integer.bitCount (MS Vmasks[used_for_fix_mask] + integer.bitcount (Msvmasks[bd_used_for_fix_mask]))); if (mnavigating && mstatus = = locationprovider.available && mlastfixtime > 0 && Sys Tem.currenttimemillis ()-mlastfixtime > Recent_fix_timeout) {@@ -1895,17 +1908,21 @@ -1895,17 class Gpslocationprovider implements Locationpro Viderinterface {}//for GPS SV statistics-private static final int max_svs = 32;+ private static final I NT MAX_SVS = 64; private static final int ephemeris_mask = 0; private static final int almanac_mask = 1; private static final int used_for_fix_mask = 2;+ private static final int bd_svs_num = 3;+ private static final int Bd_ephemeris_mask = 4;+ private static final int bd_almanac_mask = 5;+ private static final int bd_used_for_fix_mask = 6; preallocated arrays, to avoid memory allocation in Reportstatus () private int msvs[] = new INT[MAX_SVS]; private float msnrs[] = new FLOAT[MAX_SVS]; private float msvelevations[] = new FLOAT[MAX_SVS]; private float msvazimuths[] = new float[max_svs];-private int msvmasks[] = new int[3];+ private int msvmasks[] = NE W Int[7]; private int msvcount; // preallocated to avoid memory allocation in REPORTNMEA () private byte[] Mnmeabuffer = new byte[120];
This is already the Java part, finished half, after the second half of the processing, there are also many of the road in the inside.
Application and development of GPS Beidou dual-mode technology-data structure extension