Android Question NTRIP Mount Points

Terradrones

Active Member
Hi All

I have finished all the routines in my Land Surveying Program for a Level and Total Station. Now I am busy with interfacing the GPS for NTRIP firstly.

The problem that I have is that in VB.net I used the SIM Card in the GPS to access NTRIP, which was a mission when you wanted to check your Data Balance as one had to put the SIM Card in a phone to check it.

What I want to do in the Android version is to have the SIM in your phone and access NTRIP.

Here is my VB.net compact code to get all the Mount Points:

B4X:
[/
               Public Overrides Function MountpointsList() As System.Collections.Generic.List(Of GPS_Structure.NTRIP_CasterMountpoint)
                    Dim st As New Stopwatch
                    'Dim m As MatchCollection 'catches the sourcetable of the mountpoints
                    Dim mInternal As MatchCollection 'catches the STR sentences in the source table
                    Dim startString As String = "SOURCETABLE" 'startString for the regex
                    Dim endString As String = "ENDSOURCETABLE" 'endString for the regex
                    Dim pattern As String = "(?<=" & startString & ")(?s)(.*)(?=" & endString & ")" 'the pattern for the regex
                    Dim singleMountPoint As String 'a singleMount point - from STR to vbcrlf
                    Dim splittedMountPoint() As String 'array that contains all the values of a single mount point
                    Dim splittedCorrection() As String 'array that contains all the substrings of the correction of the mountpoint
                    Dim mountPointsData As String = String.Empty 'the raw data between SOURCETABLE and ENDSOURCETABLE
                    Dim success As Boolean = False 'checks if mountPointsData is found
                    Dim listOfMountPoints = New List(Of GPS_Structure.NTRIP_CasterMountpoint) 'list of mountpoints
                    Dim saveCorrection As GPS_Structure.CorrectionEnum 'saves the corrcetion of the mountpoint to a local variable
                    Dim saveName As String = String.Empty 'saves the corrcetio name of the mountpoint to a local variable
                    Dim saveLatitude As Double = 0 'saves the corrcetion latitude of the mountpoint to a local variable
                    Dim saveLongtitude As Double = 0 'saves the corrcetion longtitude of the mountpoint to a local variable
                    Dim saveIsGGANeeded As Integer = 0 'saves isGGANeeded of the mountpoint to a local variable
                    Dim saveSolution As Integer = 0 ''saves the solution of the mountpoint to a local variable
                    Dim tmpStr As String = String.Empty
                    Dim prevKeepAliveSuspend As Boolean = False

                    prevKeepAliveSuspend = COMM.IsKeepingAliveSuspended
                    COMM.IsKeepingAliveSuspended = True

                    Try
                        COMM.ClearOutputData()
                        COMM.SendDataToDevice("UNLOGALL" & vbCrLf)
                        'COMM.SendDataToDevice("SET,NETWORK.DISCONNECT" & vbCrLf)
                        'COMM.SendDataToDevice("SET,NETWORK.RESET" & vbCrLf)
                        'COMM.SendDataToDevice("LOG,GGA,ONTIME,1HZ" & vbCrLf)
                        COMM.SendDataToDevice("GET,NETWORK.MOUNTPOINTLIST" & vbCrLf)
                        COMM.ReadDeviceDataAsync()
                        st.Start()

                        While COMM.IsReading And st.ElapsedMilliseconds < 25000
                            tmpStr = COMM.DataFromDevice
                            mountPointsData += tmpStr
                            If mountPointsData.Length > 20 Then
                                If mountPointsData.Contains("SOURCETABLE") And _
                                mountPointsData.Contains("ENDSOURCETABLE") Then
                                    'm = Regex.Matches(mountPointsData, pattern)
                                    'mountPointsData = m.Item(m.Count - 1).Value
                                    success = True
                                    Debug.WriteLine("NTRIP Found all")
                                    Exit While
                                End If
                            End If
                            IFuncs.WaitSomeTime(1000)
                            'Debug.WriteLine("NTRIP waiting for a data for " + st.ElapsedMilliseconds.ToString)
                        End While

                        st.Stop()
                        st.Reset()
                        COMM.StopReading()

                        If success = False Then
                            COMM.SendDataToDevice("UNLOGALL" & vbCrLf)

                            For I = 0 To 6
                                SleepWithEvents(250)
                                tmpStr = IFuncs.SendAndRead(COMM, "GET,NETWORK.ERRORCODE")
                                If tmpStr <> "" Then
                                    MsgBox("Network Error", MsgBoxStyle.Critical, "NTRIP LIST ERROR")
                                    Exit For
                                End If
                            Next

                            If tmpStr = "" Then tmpStr = "ERROR: Unknown error. Can't get mountpoints."

                            MsgBox("Cannot Connect", MsgBoxStyle.Critical, "NTRIP CONNECT ERROR")


                            Return listOfMountPoints
                        End If

                        startString = "STR"
                        endString = vbCrLf
                        pattern = "(?<=" & startString & ")(.*\n?)(?=" & endString & ")"
                        mInternal = Regex.Matches(mountPointsData, pattern)
                        If mInternal.Count > 0 Then
                            For index As Integer = 0 To mInternal.Count - 1
                                singleMountPoint = mInternal.Item(index).Value
                                splittedMountPoint = singleMountPoint.Split(";")
                                splittedCorrection = splittedMountPoint(3).Split(" ")
                                If splittedCorrection.Length = 1 Then
                                    Select Case splittedCorrection(0)
                                        Case "CMR"
                                            saveCorrection = GPS_Structure.CorrectionEnum.CMR
                                        Case "CMR+"
                                            saveCorrection = GPS_Structure.CorrectionEnum.CMRPlus
                                        Case "RAW"
                                            saveCorrection = GPS_Structure.CorrectionEnum.RAW
                                        Case "RTCA"
                                            saveCorrection = GPS_Structure.CorrectionEnum.RTCA
                                    End Select
                                ElseIf splittedCorrection(1) = "SAPOS" Then
                                    saveCorrection = GPS_Structure.CorrectionEnum.Other
                                Else
                                    Select Case splittedCorrection(1)
                                        Case "2", "2.0", "2.1", "2.2", "2.3"
                                            saveCorrection = GPS_Structure.CorrectionEnum.RTCM23
                                        Case "3", "3.0"
                                            saveCorrection = GPS_Structure.CorrectionEnum.RTCM30
                                        Case "3.1", "3.2"
                                            saveCorrection = GPS_Structure.CorrectionEnum.RTCM31
                                    End Select

                                End If
                                If splittedMountPoint(1) <> String.Empty Then saveName = splittedMountPoint(1)
                                If splittedMountPoint(9) <> String.Empty Then saveLatitude = CDbl(splittedMountPoint(9))
                                If splittedMountPoint(10) <> String.Empty Then saveLongtitude = CDbl(splittedMountPoint(10))
                                If splittedMountPoint(11) <> String.Empty Then saveIsGGANeeded = CInt(splittedMountPoint(11))
                                If splittedMountPoint(12) <> String.Empty Then saveSolution = CInt(splittedMountPoint(12))
                                listOfMountPoints.Add(New GPS_Structure.NTRIP_CasterMountpoint With _
                                                      {.Name = saveName, .Correction = saveCorrection, _
                                                      .Latitude = saveLatitude, _
                                                      .Longtitude = saveLongtitude, _
                                                      .IsGGANeeded = saveIsGGANeeded, .Solution = saveSolution})
                            Next
                        End If

                        COMM.SendDataToDevice("UNLOGALL" & vbCrLf)
                    Catch
                        Return New List(Of GPS_Structure.NTRIP_CasterMountpoint)
                    End Try

                    COMM.IsKeepingAliveSuspended = prevKeepAliveSuspend

                    Return listOfMountPoints
                End Function
]

What would be nice if the Surveyor gets a display of how far away these Mount Points are from his\hers position.

A kick (not too hard please!!) in the right direction will be appreciated.

Michael
 
Top