summaryrefslogtreecommitdiff
path: root/gnss/gnssUmdf/FixHandler.cpp
diff options
context:
space:
mode:
authorCheoljin Lee <[email protected]>2018-11-28 11:08:27 -0800
committerCheoljin Lee <[email protected]>2018-11-28 11:08:27 -0800
commit964d0d1e461e7a9af0f9045a7f192acd74999843 (patch)
treeb8169004db5fc67fd4f45b2f7999ea6e70865ab4 /gnss/gnssUmdf/FixHandler.cpp
parent0990b0cbbd460336036dc6ec71cb8e2a8403e287 (diff)
Initial version of GPS/GNSS UMDF Sample Driver (UMDF Version 2)
Diffstat (limited to 'gnss/gnssUmdf/FixHandler.cpp')
-rw-r--r--gnss/gnssUmdf/FixHandler.cpp168
1 files changed, 168 insertions, 0 deletions
diff --git a/gnss/gnssUmdf/FixHandler.cpp b/gnss/gnssUmdf/FixHandler.cpp
new file mode 100644
index 00000000..0336dc89
--- /dev/null
+++ b/gnss/gnssUmdf/FixHandler.cpp
@@ -0,0 +1,168 @@
+/*++
+
+Copyright (c) Microsoft Corporation. All rights reserved.
+
+Module Name:
+
+ fixhandler.cpp
+
+Abstract:
+
+ This file contains the Fix handler and contains logic to provide position.
+
+Environment:
+
+ Windows User-Mode Driver Framework
+
+--*/
+
+#include "precomp.h"
+#include "Trace.h"
+#include "Defaults.h"
+#include "NmeaProcessor.h"
+#include "FixSession.h"
+#include "FixHandler.h"
+
+#include "FixHandler.tmh"
+
+
+NTSTATUS
+CFixHandler::Initialize(
+ _In_ WDFQUEUE Queue
+)
+{
+ NTSTATUS status = STATUS_SUCCESS;
+
+ status = _SingleShotSession.Initialize(Queue);
+
+ return status;
+}
+
+NTSTATUS
+CFixHandler::StartFix(
+ _In_ WDFREQUEST Request
+)
+{
+ NTSTATUS status = STATUS_SUCCESS;
+ PGNSS_FIXSESSION_PARAM fixSessionParameters = nullptr;
+
+ status = WdfRequestRetrieveInputBuffer(Request, sizeof(GNSS_FIXSESSION_PARAM), (void**)&fixSessionParameters, nullptr);
+ if (!NT_SUCCESS(status))
+ {
+ TraceEvents(TRACE_LEVEL_ERROR, TRACE_FIX, "WdfRequestRetrieveInputBuffer failed with %!STATUS!", status);
+ goto Exit;
+ }
+
+ if (fixSessionParameters->SessionType != GNSS_FixSession_SingleShot)
+ {
+ status = STATUS_UNSUCCESSFUL;
+ TraceEvents(TRACE_LEVEL_ERROR, TRACE_FIX, "Session type is not GNSS_FixSession_SingleShot");
+ goto Exit;
+ }
+
+ _CurrentSinglsShotSessionId = fixSessionParameters->FixSessionID;
+
+ status = _SingleShotSession.StartAcquiringFix(fixSessionParameters);
+ if (!NT_SUCCESS(status))
+ {
+ TraceEvents(TRACE_LEVEL_ERROR, TRACE_FIX, "StartFix failed with %!STATUS!", status);
+ goto Exit;
+ }
+
+Exit:
+ return status;
+}
+
+NTSTATUS
+CFixHandler::StopFix(
+ _In_ WDFREQUEST Request
+)
+{
+ NTSTATUS status = STATUS_SUCCESS;
+ PGNSS_STOPFIXSESSION_PARAM StopFixSessionParam = nullptr;
+
+ status = WdfRequestRetrieveInputBuffer(Request, sizeof(GNSS_STOPFIXSESSION_PARAM), (void**)&StopFixSessionParam, nullptr);
+ if (!NT_SUCCESS(status))
+ {
+ TraceEvents(TRACE_LEVEL_ERROR, TRACE_FIX, "WdfRequestRetrieveInputBuffer failed with %!STATUS!", status);
+ goto Exit;
+ }
+
+ // Send the session parameters to the right session based on the ID
+ if (StopFixSessionParam->FixSessionID != _CurrentSinglsShotSessionId)
+ {
+ status = STATUS_UNSUCCESSFUL;
+ TraceEvents(TRACE_LEVEL_ERROR, TRACE_FIX, "Session type is not GNSS_FixSession_SingleShot");
+ goto Exit;
+ }
+
+ _CurrentSinglsShotSessionId = INVALID_SESSION_ID;
+
+ status = _SingleShotSession.StopAcquiringFix(StopFixSessionParam);
+ if (!NT_SUCCESS(status))
+ {
+ TraceEvents(TRACE_LEVEL_ERROR, TRACE_FIX, "StopFix failed with %!STATUS!", status);
+ goto Exit;
+ }
+
+Exit:
+ return status;
+}
+
+NTSTATUS
+CFixHandler::ModifyFix(
+ _In_ WDFREQUEST /*Request*/
+)
+{
+ NTSTATUS status = STATUS_SUCCESS;
+
+ //
+ // TODO: Currently not doing anything yet
+ //
+
+ return status;
+}
+
+NTSTATUS
+CFixHandler::GetFixRequest(
+ _In_ WDFREQUEST Request
+)
+{
+ NTSTATUS status = STATUS_SUCCESS;
+ ULONG sessionId = INVALID_SESSION_ID;
+ ULONG *pSessionId = nullptr;
+
+ // Get the session ID this get fix is for
+ status = WdfRequestRetrieveInputBuffer(Request, sizeof(sessionId), (void**)&pSessionId, nullptr);
+ if (!NT_SUCCESS(status))
+ {
+ TraceEvents(TRACE_LEVEL_ERROR, TRACE_FIX, "Could not retrieve input sessionID for request");
+ goto Exit;
+ }
+
+ // Should do this check at the FixHandler Level.
+ sessionId = *pSessionId;
+
+ status = _SingleShotSession.GetFix(Request);
+ if (!NT_SUCCESS(status))
+ {
+ TraceEvents(TRACE_LEVEL_ERROR, TRACE_FIX, "SinglShotSession.GetFix failed with %!STATUS!", status);
+ goto Exit;
+ }
+
+Exit:
+ return status;
+}
+
+NTSTATUS
+CFixHandler::SetCurrentPosition(
+ _In_ PGNSS_FIXDATA GnssFixData
+)
+{
+ NTSTATUS status = STATUS_SUCCESS;
+
+ // Update the current sessions.
+ status = _SingleShotSession.UpdateCurrentPosition(GnssFixData);
+
+ return status;
+}