1 #ifndef GMWEBSERVER_HPP_
2 #define GMWEBSERVER_HPP_
4 #ifndef _GEO_APPDEFS_HPP
5 #include <GmCommon/GeoAppDefs.hpp>
10 #include <xdc/cfg/global.h>
11 #include <xdc/runtime/System.h>
15 #include <ti/sysbios/BIOS.h>
16 #include <ti/sysbios/knl/Task.h>
17 #include <ti/sysbios/knl/Clock.h>
20 #include <inc/hw_memmap.h>
21 #if GEO_NET_NDK == GEO_TRUE
24 #include "GmEth/http-port/rhc_usertype.h"
25 #include "GmEth/http-port/rhc_osif.h"
26 #include "GmEth/http-port/rhc_httpif.h"
27 #include "GmEth/http-port/rhc_http.h"
35 #if GEO_NET_3100 == GEO_TRUE
37 #include <simplelink.h>
38 #include "GmEth/http-port/rhc_usertype.h"
39 #include "GmEth/http-port/rhc_osif.h"
40 #include "GmEth/http-port/rhc_httpif.h"
41 #include "GmEth/http-port/rhc_http.h"
44 #include <TezzeretBoardAliases.h>
46 #if UNMIRRORED_STORAGE == GEO_TRUE
47 #include <GmCharRingBufferStorage.hpp>
49 #if GEO_SDCARD == GEO_TRUE
50 #include <GmTivaSDStorage.hpp>
52 #if GEO_USB_STORAGE == GEO_TRUE
53 #include <GmTivaUsbStorage.hpp>
56 #include <GmSdStorage.hpp>
57 #include <GmError.hpp>
58 #include <GmStatus.hpp>
61 #if MFAM_SYS_MGMT == GEO_TRUE
62 #include "GmSysMgmt.hpp"
65 #if MFAM_MODULE == GEO_TRUE
66 #include <GmMFAMDataSource.hpp>
69 #include <TezzeretApp.hpp>
89 static int ProcessAcquisitionDataFiles (
char *pSurveyId,
char *strAcquisitionId,
90 Bool isPreprocessingStage,
91 const int filesReported,
92 const int kbytesInFiles,
93 std::function<
int (
const char * buffer)> handler,
94 std::function<
int (
const int filesReported,
95 const int kbytesInFiles)> finalReport);
99 static Int WebCommand (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
100 static Int ListAcquisitionDataFilesJsonEx (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
101 static Int ListAcquisitionDataFiles (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
102 static Int ListSurveys (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
103 static Int ListSurveysJsonEx (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
104 static Int ListAcquisitionsJson (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
105 static Int ListAcquisitionsJsonEx (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
106 static Int CloseCurrentSurveyExJson (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
107 static Int CloseCurrentAcqExJson (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
108 static Int NewAcquisition (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
109 static Int SelectSurveyJsonEx (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
110 static Int SelectAcqJsonEx (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
111 static Int NewAcqJsonEx (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
112 static Int NewAcquisitionJson (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
113 static Int NewSurveyJson (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
114 static Int DeleteSurvey (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
115 static Int SetActiveAcquisition (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
116 static Int NameActiveAcquisitionJson (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
117 static Int SetActiveAcquisitionNameJson (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
118 static Int AddAcquisitionInfoJson (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
119 static Int GetActiveAcquisitionNameJson (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
120 static Int WebDeleteSession (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
121 static int ShowLoggingConfig (SOCKET s,
char* buf);
122 static int StatusJsonEx (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
123 static Int JsonGet (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
124 static Int GetTestFileUploadForm (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
125 static Int statusDetails (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
126 static Int getStatus (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
127 static Int getStatusInternal (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args, Bool autoRefresh = FALSE);
128 static Int sysInfo (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
129 static Int CleanOldFiles (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
130 static Int ShutdownSystem (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
131 static Int ResetSystem (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
132 static Int TestFileUpload (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
133 static Int getStatusTxt (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
134 static Int WifiCheck (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
139 static Int DiagnosticsJsonEx (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
140 #if (GEO_7998_BATTERY_MONITOR == GEO_TRUE)||(GEO_7993_BATTERY_MONITOR == GEO_TRUE)||(MFAM_SYS_MGMT == GEO_TRUE)
141 static Int BatteryJsonEx (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
143 #if (GEO_4151_BATTERY_MONITOR == GEO_TRUE)||(GEO_7998_BATTERY_MONITOR == GEO_TRUE)||(GEO_7993_BATTERY_MONITOR == GEO_TRUE)
144 static int Batteries (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
146 static int StatusJsonEx2 (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
153 static int SysInfoJsonEx (SOCKET s,
struct rhc_http_msg *pMsg, UINT8* args);
154 static int GpsJsonEx (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
155 static int Mark (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
156 static int MarkTarget (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
158 static int Destination (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
160 static int RequestSynch (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
161 static int RequestDeleteSegment (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
162 static int SetSamplePeriod (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
163 static int AcquisitionsJsonEx2 (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
164 static int MagnetometersJsonEx (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
168 static int AcquisitionEx (SOCKET s,
const char *strSurveyId,
const char *strAcquisitionId, RHC_HTTP_MSG *pMsg, UINT8* args);
169 static int FilesJsonEx (SOCKET s,
const char *strSurveyId,
const char *strAcquisitionId, RHC_HTTP_MSG *pMsg, UINT8* args);
170 static Bool UriIsAcquisition (
const char *strUri,
172 char *strAcquisitionId);
173 static Bool GetSurveyIdFromUri (
const char *strUri,
175 static int DownloadDataFile (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
176 static int DownloadAcquisition (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args,
177 const char *strSurveyId,
const char *strAcquisitionId);
182 static int StreamFileContents (SOCKET s,
const char *strSurveyId,
const char *strAcquisitionId,
183 const char *strFileName);
184 static int StreamFileContents (SOCKET s,
const char *strSurveyId,
const char *strAcquisitionId,
185 const int fileIndex,
const bool filesInDirectories,
186 const int directorySize);
188 static Int SystemTest (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
190 #if MFAM_SYS_MGMT == GEO_TRUE
195 static Int RunSystemTests (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
202 static Bool GetAcquisitionIdFromUri (
const char *strUri,
205 static int DownloadAcquisitionData(SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
209 #if (EMULATE_MFAM_SENSOR == GEO_TRUE) || (MFAM_MODULE == GEO_TRUE)
210 static void AppendMagStatus (
char *buffer);
211 static int AppendShortInstrumentStatus (
char *buffer);
213 static Int StatusObject (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8 *args,
const char *strName,
217 static int AppendStorageIfFailed (
char *buffer);
218 static int AppendApplicationName (
char *buffer);
219 static int GetGetParameter (
char *dest,
int iBufferSize,
const char *szArgName, UINT8* args);
220 static Int getEmptyList (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
221 static UInt32 GetCommandFromQueryString (
char* szArgs);
224 #if (GEO_4151_BATTERY_MONITOR == GEO_TRUE)||(GEO_7998_BATTERY_MONITOR == GEO_TRUE)||(GEO_7993_BATTERY_MONITOR == GEO_TRUE)||(MFAM_SYS_MGMT == GEO_TRUE)
225 static void ReportBatteryMonitor (SOCKET s, RHC_HTTP_MSG *pMsg, UINT8* args);
231 static int SearchStringWithEnd (
const char *strHaystack,
232 const char *strNeedle,
int iLengthOfHaystack,
int *piLengthFound);
233 static int SearchAndShiftString (SOCKET s, RHC_HTTP_MSG *pMsg,
char *pData,
234 const char *strBoundary,
int iSizeData,
int iSizeBuffer,
235 int iContentBytesRead,
int *piDataRemainingInBuffer,
236 int *piDataReadFromNetwork);
237 static int FindPostBoundary (SOCKET s, RHC_HTTP_MSG *pMsg,
char *pData,
238 const char *strBoundary,
int iSizeData,
int iContentBytesRead,
239 int *piDataRemainingInBuffer,
int *piBytesReadFromNetwork,
241 static int ScanToDelimiter (SOCKET s,
char* caMetaData,
242 int iMetadataBufferFree,
int iDataSize,
char *pData,
243 int iDataBufferSize,
const char *strDelimiter,
int iDelimiterSize,
244 int iContentLengthStillInNetwork,
int *piDataCopied,
245 int *piDataReadFromNetwork);
246 static int ReadFormMetadata (SOCKET s,
char* caMetaData,
247 int iMetadataBufferSize,
char *pData,
int iDataBufferSize,
248 int iDataInBuffer,
int iTotalContentLengthStillInNetwork,
249 const char *strTerminator,
int iDelimiterSize,
int *piDataCopied,
250 int *piDataReadFromNetwork);
251 static int DiscardToDelimiter ( SOCKET s,
258 int *piDataReadFromNetwork);
An HTTP server is an integral part of the framework, both to display UI in a browser and to provide a...
Definition: GmWebServer.hpp:83
static int GenericJsonRequest(SOCKET s, RHC_HTTP_MSG *pMsg, UINT8 *args)
Definition: GmWebServer.cpp:2944
GmApp/GmLoggingApp.hpp>
Definition: Analogs.hpp:47