-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[gen4] support built-in GNSS in NCP client. #2733
Draft
XuGuohui
wants to merge
3
commits into
develop
Choose a base branch
from
feature/sc115271/orson_builtin_gnss
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "hal_platform.h" | ||
|
||
#if HAL_PLATFORM_GNSS | ||
#include "hal_dynalib_gnss.h" | ||
#endif // HAL_PLATFORM_GNSS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2024 Particle Industries, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation, either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef GNSS_HAL_H | ||
#define GNSS_HAL_H | ||
|
||
#include "hal_platform.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#if HAL_PLATFORM_GNSS | ||
|
||
int hal_gnss_init(void* reserved); | ||
int hal_gnss_pos(void* reserved); | ||
|
||
#endif // HAL_PLATFORM_GNSS | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* GNSS_HAL_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2024 Particle Industries, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation, either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "hal_platform.h" | ||
#include "dynalib.h" | ||
|
||
#if HAL_PLATFORM_GNSS | ||
|
||
#ifdef DYNALIB_EXPORT | ||
#include "gnss_hal.h" | ||
#endif | ||
|
||
// WARNING | ||
// The order of functions must not be changed or older applications will break | ||
// when used with newer system firmware. | ||
// Function signatures shouldn't be changed other than changing pointer types. | ||
// New HAL functions must be added to the end of this list. | ||
// GNINRAW | ||
|
||
DYNALIB_BEGIN(hal_gnss) | ||
|
||
DYNALIB_FN(0, hal_gnss, hal_gnss_init, int(void*)) | ||
DYNALIB_FN(1, hal_gnss, hal_gnss_pos, int(void*)) | ||
|
||
DYNALIB_END(hal_gnss) | ||
|
||
#endif // HAL_PLATFORM_GNSS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2024 Particle Industries, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation, either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHAN'TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "check.h" | ||
#include "delay_hal.h" | ||
#include "service_debug.h" | ||
#include "logging.h" | ||
#include "gnss_hal.h" | ||
|
||
#if HAL_PLATFORM_GNSS | ||
|
||
#include "network/ncp/cellular/cellular_network_manager.h" | ||
#include "network/ncp/cellular/cellular_ncp_client.h" | ||
#include "network/ncp/cellular/ncp.h" | ||
#include "network/ncp_client/quectel/quectel_ncp_client.h" | ||
|
||
using namespace particle; | ||
|
||
// Just for testing purposes | ||
int hal_gnss_init(void* reserved) { | ||
const auto mgr = cellularNetworkManager(); | ||
CHECK_TRUE(mgr, SYSTEM_ERROR_UNKNOWN); | ||
const auto client = reinterpret_cast<QuectelNcpClient*>(mgr->ncpClient()); | ||
CHECK_TRUE(client, SYSTEM_ERROR_UNKNOWN); | ||
|
||
GnssNcpClientConfig config = {}; | ||
config.enableGpsOneXtra(true); | ||
client->gnssConfig(config); | ||
client->gnssOn(); | ||
client->acquireNmeaSentences(GNSS_NMEA_TYPE_GNS, nullptr, 0); | ||
|
||
return 0; | ||
} | ||
|
||
int hal_gnss_pos(void* reserved) { | ||
const auto mgr = cellularNetworkManager(); | ||
CHECK_TRUE(mgr, SYSTEM_ERROR_UNKNOWN); | ||
const auto client = reinterpret_cast<QuectelNcpClient*>(mgr->ncpClient()); | ||
CHECK_TRUE(client, SYSTEM_ERROR_UNKNOWN); | ||
|
||
GnssPositioningInfo info = {}; | ||
client->acquirePositioningInfo(&info); | ||
return 0; | ||
} | ||
|
||
#endif // HAL_PLATFORM_GNSS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright (c) 2024 Particle Industries, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation, either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "time.h" | ||
#include "ncp_client.h" | ||
#include "hal_platform.h" | ||
|
||
#if HAL_PLATFORM_GNSS | ||
|
||
namespace particle { | ||
|
||
enum GnssState { | ||
GNSS_STATE_DISABLED = 0, | ||
GNSS_STATE_INIT = 1, | ||
GNSS_STATE_ON = 2, | ||
GNSS_STATE_OFF = 3, | ||
GNSS_STATE_MAX = 4 | ||
}; | ||
|
||
enum GnssNmeaType { | ||
GNSS_NMEA_TYPE_GGA = 0, | ||
GNSS_NMEA_TYPE_RMC = 1, | ||
GNSS_NMEA_TYPE_GSV = 2, | ||
GNSS_NMEA_TYPE_GSA = 3, | ||
GNSS_NMEA_TYPE_VTG = 4, | ||
GNSS_NMEA_TYPE_GNS = 5, | ||
GNSS_NMEA_TYPE_MAX = 6 | ||
}; | ||
|
||
struct GnssPositioningInfo { | ||
uint16_t version; | ||
uint16_t size; | ||
double latitude; | ||
double longitude; | ||
float accuracy; | ||
float altitude; | ||
float cog; | ||
float speedKmph; | ||
float speedKnots; | ||
struct tm utcTime; | ||
int satsInView; | ||
bool locked; | ||
int posMode; | ||
}; | ||
|
||
class GnssNcpClientConfig { | ||
public: | ||
GnssNcpClientConfig() | ||
: enableGpsOneXtra_(false) { | ||
} | ||
|
||
GnssNcpClientConfig& enableGpsOneXtra(bool enable) { | ||
enableGpsOneXtra_ = enable; | ||
return *this; | ||
} | ||
|
||
bool isGpsOneXtraEnabled() const { | ||
return enableGpsOneXtra_; | ||
} | ||
|
||
private: | ||
bool enableGpsOneXtra_; | ||
}; | ||
|
||
class GnssNcpClient { | ||
public: | ||
virtual int gnssConfig(const GnssNcpClientConfig& conf) = 0; | ||
virtual int gnssOn() = 0; | ||
virtual int gnssOff() = 0; | ||
virtual int acquirePositioningInfo(GnssPositioningInfo* info) = 0; | ||
virtual int acquireNmeaSentences(GnssNmeaType type, char* buf, size_t len) = 0; | ||
virtual uint32_t getTtff() = 0; | ||
virtual GnssState gnssState() = 0; | ||
|
||
#if HAL_PLATFORM_GPS_ONE_XTRA | ||
virtual int injectGpsOneXtraTimeAndData(const uint8_t* buf, size_t size) = 0; | ||
virtual bool isGpsOneXtraEnabled() = 0; | ||
virtual bool isGpsOneXtraDataValid() = 0; | ||
#endif // HAL_PLATFORM_GPS_ONE_XTRA | ||
}; | ||
|
||
} // particle | ||
|
||
#endif // HAL_PLATFORM_GNSS |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add error estimates and DOPs