mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
Compare commits
4 Commits
7e7b50910c
...
deb3c85466
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
deb3c85466 | ||
|
|
5071c390d4 | ||
|
|
ea88165b08 | ||
|
|
a170dfe8a9 |
@ -24,8 +24,6 @@ extern const AppManifest manifest;
|
||||
|
||||
class GpsSettingsApp final : public App {
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr<Timer> timer;
|
||||
std::shared_ptr<GpsSettingsApp*> appReference = std::make_shared<GpsSettingsApp*>(this);
|
||||
lv_obj_t* statusWrapper = nullptr;
|
||||
@ -96,7 +94,7 @@ private:
|
||||
memcpy(&index, &index_as_voidptr, sizeof(int));
|
||||
|
||||
std::vector<tt::hal::gps::GpsConfiguration> configurations;
|
||||
auto gps_service = tt::service::gps::findGpsService();
|
||||
auto gps_service = service::gps::findGpsService();
|
||||
if (gps_service && gps_service->getGpsConfigurations(configurations)) {
|
||||
TT_LOG_I(TAG, "Found service and configs %d %d", index, configurations.size());
|
||||
if (index <= configurations.size()) {
|
||||
|
||||
@ -18,7 +18,7 @@ BundleHandle _Nullable tt_app_get_parameters(AppHandle handle);
|
||||
* @param[in] result the result state to set
|
||||
* @param[in] bundle the result bundle to set
|
||||
*/
|
||||
void tt_app_set_result(AppHandle handle, Result result, BundleHandle _Nullable bundle);
|
||||
void tt_app_set_result(AppHandle handle, AppResult result, BundleHandle _Nullable bundle);
|
||||
|
||||
/** @return true if a result was set for this app context */
|
||||
bool tt_app_has_result(AppHandle handle);
|
||||
|
||||
@ -9,14 +9,14 @@ extern "C" {
|
||||
|
||||
/** Important: These values must map to tt::app::Result values exactly */
|
||||
typedef enum {
|
||||
AppResultOk = 0,
|
||||
AppResultCancelled = 1,
|
||||
AppResultError = 2
|
||||
} Result;
|
||||
APP_RESULT_OK = 0,
|
||||
APP_RESULT_CANCELLED = 1,
|
||||
APP_RESULT_ERROR = 2
|
||||
} AppResult;
|
||||
|
||||
typedef void* AppHandle;
|
||||
|
||||
typedef unsigned int LaunchId;
|
||||
typedef unsigned int AppLaunchId;
|
||||
|
||||
/** Important: These function types must map to t::app types exactly */
|
||||
typedef void* (*AppCreateData)();
|
||||
@ -25,7 +25,7 @@ typedef void (*AppOnCreate)(AppHandle app, void* _Nullable data);
|
||||
typedef void (*AppOnDestroy)(AppHandle app, void* _Nullable data);
|
||||
typedef void (*AppOnShow)(AppHandle app, void* _Nullable data, lv_obj_t* parent);
|
||||
typedef void (*AppOnHide)(AppHandle app, void* _Nullable data);
|
||||
typedef void (*AppOnResult)(AppHandle app, void* _Nullable data, LaunchId launchId, Result result, BundleHandle resultData);
|
||||
typedef void (*AppOnResult)(AppHandle app, void* _Nullable data, AppLaunchId launchId, AppResult result, BundleHandle resultData);
|
||||
|
||||
typedef struct {
|
||||
/** The application's human-readable name */
|
||||
|
||||
21
TactilityC/Include/tt_gps.h
Normal file
21
TactilityC/Include/tt_gps.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool tt_gps_has_coordinates();
|
||||
|
||||
bool tt_gps_get_coordinates(
|
||||
float& longitude,
|
||||
float& latitude,
|
||||
float& speed,
|
||||
float& course,
|
||||
int& day,
|
||||
int& month,
|
||||
int& year
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
74
TactilityC/Include/tt_wifi.h
Normal file
74
TactilityC/Include/tt_wifi.h
Normal file
@ -0,0 +1,74 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define TT_WIFI_SSID_LIMIT 32 // 32 characters/octets, according to IEEE 802.11-2020 spec
|
||||
#define TT_WIFI_CREDENTIALS_PASSWORD_LIMIT 64 // 64 characters/octets, according to IEEE 802.11-2020 spec
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Important: These values must map to tt::service::wifi::RadioState values exactly */
|
||||
typedef enum {
|
||||
WIFI_RADIO_STATE_ON_PENDING,
|
||||
WIFI_RADIO_STATE_ON,
|
||||
WIFI_RADIO_STATE_CONNECTION_PENDING,
|
||||
WIFI_RADIO_STATE_CONNECTION_ACTIVE,
|
||||
WIFI_RADIO_STATE_OFF_PENDING,
|
||||
WIFI_RADIO_STATE_OFF,
|
||||
} WifiRadioState;
|
||||
|
||||
/** @return the state of the WiFi radio */
|
||||
WifiRadioState tt_wifi_get_radio_state();
|
||||
|
||||
/** @return a textual representation of the WiFi radio state */
|
||||
const char* tt_wifi_radio_state_to_string(WifiRadioState state);
|
||||
|
||||
/** Start scanning */
|
||||
void tt_wifi_scan();
|
||||
|
||||
/** @return true if a scan is active/pending */
|
||||
bool tt_wifi_is_scanning();
|
||||
|
||||
/**
|
||||
* Return the WiFi SSID that the system tries to connect to, or is connected to.
|
||||
* @param[out] buffer an allocated string buffer. Its size must be (WIFI_SSID_LIMIT + 1).
|
||||
*/
|
||||
void tt_wifi_get_connection_target(char* buffer);
|
||||
|
||||
/**
|
||||
* @brief Enable/disable the radio. Ignores input if desired state matches current state.
|
||||
* @param[in] enabled
|
||||
*/
|
||||
void tt_wifi_set_enabled(bool enabled);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ssid The access point identifier - maximal 32 characters/octets
|
||||
* @param password the password - maximum 64 characters/octets
|
||||
* @param channel 0 means "any"
|
||||
* @param autoConnect whether we want to automatically reconnect if a disconnect occurs
|
||||
* @param remember whether the record should be stored permanently on the device (it is only stored if this connection attempt succeeds)
|
||||
*/
|
||||
void tt_wifi_connect(const char* ssid, const char* password, int32_t channel, bool autoConnect, bool remember);
|
||||
|
||||
/**
|
||||
* If WiFi is connected, this disconnects it.
|
||||
*/
|
||||
void tt_wifi_disconnect();
|
||||
|
||||
/**
|
||||
* @return true if WiFi is active and encrypted
|
||||
*/
|
||||
bool tt_wifi_is_connnection_secure();
|
||||
|
||||
/**
|
||||
* @return the current radio connection link quality
|
||||
*/
|
||||
int tt_wifi_get_rssi();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@ -10,9 +10,9 @@ BundleHandle _Nullable tt_app_get_parameters(AppHandle handle) {
|
||||
return (BundleHandle)HANDLE_AS_APP_CONTEXT(handle)->getParameters().get();
|
||||
}
|
||||
|
||||
void tt_app_set_result(AppHandle handle, Result result, BundleHandle _Nullable bundle) {
|
||||
auto shared_bundle = std::unique_ptr<tt::Bundle>((tt::Bundle*)bundle);
|
||||
HANDLE_AS_APP_CONTEXT(handle)->getApp()->setResult((tt::app::Result)result, std::move(shared_bundle));
|
||||
void tt_app_set_result(AppHandle handle, AppResult result, BundleHandle _Nullable bundle) {
|
||||
auto shared_bundle = std::unique_ptr<tt::Bundle>(static_cast<tt::Bundle*>(bundle));
|
||||
HANDLE_AS_APP_CONTEXT(handle)->getApp()->setResult(static_cast<tt::app::Result>(result), std::move(shared_bundle));
|
||||
}
|
||||
|
||||
bool tt_app_has_result(AppHandle handle) {
|
||||
@ -24,7 +24,7 @@ void tt_app_start(const char* appId) {
|
||||
}
|
||||
|
||||
void tt_app_start_with_bundle(const char* appId, BundleHandle parameters) {
|
||||
tt::app::start(appId, std::shared_ptr<tt::Bundle>((tt::Bundle*)parameters));
|
||||
tt::app::start(appId, std::shared_ptr<tt::Bundle>(static_cast<tt::Bundle*>(parameters)));
|
||||
}
|
||||
|
||||
void tt_app_stop() {
|
||||
|
||||
45
TactilityC/Source/tt_gps.cpp
Normal file
45
TactilityC/Source/tt_gps.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include "tt_gps.h"
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
|
||||
using namespace tt::service;
|
||||
|
||||
extern "C" {
|
||||
|
||||
bool tt_gps_has_coordinates() {
|
||||
auto service = gps::findGpsService();
|
||||
return service != nullptr && service->hasCoordinates();
|
||||
}
|
||||
|
||||
bool tt_gps_get_coordinates(
|
||||
float& longitude,
|
||||
float& latitude,
|
||||
float& speed,
|
||||
float& course,
|
||||
int& day,
|
||||
int& month,
|
||||
int& year
|
||||
) {
|
||||
auto service = gps::findGpsService();
|
||||
|
||||
if (service == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
minmea_sentence_rmc rmc;
|
||||
|
||||
if (!service->getCoordinates(rmc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
longitude = minmea_tocoord(&rmc.longitude);
|
||||
latitude = minmea_tocoord(&rmc.latitude);
|
||||
speed = minmea_tocoord(&rmc.speed);
|
||||
course = minmea_tocoord(&rmc.course);
|
||||
day = rmc.date.day;
|
||||
month = rmc.date.month;
|
||||
year = rmc.date.year;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,6 +5,7 @@
|
||||
#include "tt_app_manifest.h"
|
||||
#include "tt_app_selectiondialog.h"
|
||||
#include "tt_bundle.h"
|
||||
#include "tt_gps.h"
|
||||
#include "tt_hal_i2c.h"
|
||||
#include "tt_lvgl_keyboard.h"
|
||||
#include "tt_lvgl_spinner.h"
|
||||
@ -16,6 +17,7 @@
|
||||
#include "tt_thread.h"
|
||||
#include "tt_time.h"
|
||||
#include "tt_timer.h"
|
||||
#include "tt_wifi.h"
|
||||
|
||||
#include <private/elf_symbol.h>
|
||||
|
||||
@ -41,6 +43,8 @@ const struct esp_elfsym elf_symbols[] {
|
||||
ESP_ELFSYM_EXPORT(tt_bundle_put_bool),
|
||||
ESP_ELFSYM_EXPORT(tt_bundle_put_int32),
|
||||
ESP_ELFSYM_EXPORT(tt_bundle_put_string),
|
||||
ESP_ELFSYM_EXPORT(tt_gps_has_coordinates),
|
||||
ESP_ELFSYM_EXPORT(tt_gps_get_coordinates),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_start),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_stop),
|
||||
ESP_ELFSYM_EXPORT(tt_hal_i2c_is_started),
|
||||
@ -114,6 +118,16 @@ const struct esp_elfsym elf_symbols[] {
|
||||
ESP_ELFSYM_EXPORT(tt_timezone_get_code),
|
||||
ESP_ELFSYM_EXPORT(tt_timezone_is_format_24_hour),
|
||||
ESP_ELFSYM_EXPORT(tt_timezone_set_format_24_hour),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_get_radio_state),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_radio_state_to_string),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_scan),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_is_scanning),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_get_connection_target),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_set_enabled),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_connect),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_disconnect),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_is_connnection_secure),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_get_rssi),
|
||||
// tt::lvgl
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_spinner_create),
|
||||
// lv_event
|
||||
|
||||
@ -7,7 +7,6 @@ struct TimerWrapper {
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
TimerHandle tt_timer_alloc(TimerType type, TimerCallback callback, void* callbackContext) {
|
||||
auto wrapper = std::make_shared<TimerWrapper>();
|
||||
wrapper->timer = std::make_unique<tt::Timer>((tt::Timer::Type)type, [callback, callbackContext](){ callback(callbackContext); });
|
||||
@ -54,4 +53,3 @@ void tt_timer_set_thread_priority(TimerHandle handle, ThreadPriority priority) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
55
TactilityC/Source/tt_wifi.cpp
Normal file
55
TactilityC/Source/tt_wifi.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "tt_wifi.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
#include <Tactility/service/wifi/WifiSettings.h>
|
||||
|
||||
using namespace tt::service;
|
||||
|
||||
extern "C" {
|
||||
|
||||
WifiRadioState tt_wifi_get_radio_state() {
|
||||
return static_cast<WifiRadioState>(wifi::getRadioState());
|
||||
}
|
||||
const char* tt_wifi_radio_state_to_string(WifiRadioState state) {
|
||||
return wifi::radioStateToString(static_cast<wifi::RadioState>(state));
|
||||
}
|
||||
|
||||
void tt_wifi_scan() {
|
||||
wifi::scan();
|
||||
}
|
||||
|
||||
bool tt_wifi_is_scanning() {
|
||||
return wifi::isScanning();
|
||||
}
|
||||
|
||||
void tt_wifi_get_connection_target(char* buffer) {
|
||||
auto target = wifi::getConnectionTarget();
|
||||
strcpy(buffer, target.c_str());
|
||||
}
|
||||
|
||||
void tt_wifi_set_enabled(bool enabled) {
|
||||
wifi::setEnabled(enabled);
|
||||
}
|
||||
|
||||
void tt_wifi_connect(const char* ssid, const char* password, int32_t channel, bool autoConnect, bool remember) {
|
||||
wifi::settings::WifiApSettings settings;
|
||||
strcpy(settings.ssid, ssid);
|
||||
strcpy(settings.password, password);
|
||||
settings.channel = channel;
|
||||
settings.auto_connect = autoConnect;
|
||||
}
|
||||
|
||||
void tt_wifi_disconnect() {
|
||||
wifi::disconnect();
|
||||
}
|
||||
|
||||
bool tt_wifi_is_connnection_secure() {
|
||||
return wifi::isConnectionSecure();
|
||||
}
|
||||
|
||||
int tt_wifi_get_rssi() {
|
||||
return wifi::getRssi();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user