Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hal-dynalib/src/hal_gnss.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "hal_dynalib_gnss.h"
31 changes: 31 additions & 0 deletions hal/inc/gnss_hal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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

#ifdef __cplusplus
extern "C" {
#endif

int hal_gnss_init(void* reserved);

#ifdef __cplusplus
}
#endif

#endif /* GNSS_HAL_H */
38 changes: 38 additions & 0 deletions hal/inc/hal_dynalib_gnss.h
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/>.
*/

#pragma once

#include "hal_platform.h"
#include "dynalib.h"

#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_END(hal_gnss)
4 changes: 4 additions & 0 deletions hal/inc/hal_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,8 @@
#define HAL_PLATFORM_AUTOMATIC_CONNECTION_MANAGEMENT (0)
#endif // HAL_PLATFORM_AUTOMATIC_CONNECTION_MANAGEMENT

#ifndef HAL_PLATFORM_GPS_ONE_XTRA
#define HAL_PLATFORM_GPS_ONE_XTRA (0)
#endif // HAL_PLATFORM_GPS_ONE_XTRA

#endif /* HAL_PLATFORM_H */
43 changes: 43 additions & 0 deletions hal/network/ncp/gnss/gnss_hal.cpp
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
* 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"

#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);

return 0;
}
75 changes: 75 additions & 0 deletions hal/network/ncp/gnss/gnss_ncp_client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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 "wifi_network_manager.h"

namespace particle {

struct GnssPositioningInfo {
Copy link
Contributor

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

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;

#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
Loading