TactilityC additions (#287)
New TactilityC implementations for: - WiFi - GPS - Preferences - Timezone Also includes: - Some fixes to enums/naming - Cleanup elsewhere
This commit is contained in:
committed by
GitHub
parent
869a56125f
commit
1593eb80ce
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,83 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* Note that on ESP32, there are limitations:
|
||||
* - namespace name is limited by NVS_NS_NAME_MAX_SIZE (generally 16 characters)
|
||||
* - key is limited by NVS_KEY_NAME_MAX_SIZE (generally 16 characters)
|
||||
*/
|
||||
|
||||
/** The handle that represents a Preferences instance */
|
||||
typedef void* PreferencesHandle;
|
||||
|
||||
/**
|
||||
* @param[in] identifier the name of the preferences. This determines the NVS namespace on ESP.
|
||||
* @return a new preferences instance
|
||||
*/
|
||||
PreferencesHandle tt_preferences_alloc(const char* identifier);
|
||||
|
||||
/** Dealloc an existing preferences instance */
|
||||
void tt_preferences_free(PreferencesHandle handle);
|
||||
|
||||
/**
|
||||
* Try to get a boolean value
|
||||
* @param[in] handle the handle that represents the preferences
|
||||
* @param[in] key the identifier that represents the stored value (~variable name)
|
||||
* @param[out] out the output value (only set when return value is set to true)
|
||||
* @return true if "out" was set
|
||||
*/
|
||||
bool tt_preferences_opt_bool(PreferencesHandle handle, const char* key, bool* out);
|
||||
|
||||
/**
|
||||
* Try to get an int32_t value
|
||||
* @param[in] handle the handle that represents the preferences
|
||||
* @param[in] key the identifier that represents the stored value (~variable name)
|
||||
* @param[out] out the output value (only set when return value is set to true)
|
||||
* @return true if "out" was set
|
||||
*/
|
||||
bool tt_preferences_opt_int32(PreferencesHandle handle, const char* key, int32_t* out);
|
||||
|
||||
/**
|
||||
* Try to get a string
|
||||
* @warning outSize must be large enough to include null terminator. This means that your string has to be the expected text length + 1 extra character.
|
||||
* @param[in] handle the handle that represents the preferences
|
||||
* @param[in] key the identifier that represents the stored value (~variable name)
|
||||
* @param[out] out the buffer to store the string in
|
||||
* @param[in] outSize the size of the buffer
|
||||
* @return true if "out" was set
|
||||
*/
|
||||
bool tt_preferences_opt_string(PreferencesHandle handle, const char* key, char* out, uint32_t outSize);
|
||||
|
||||
/**
|
||||
* Store a boolean value
|
||||
* @param[in] handle the handle that represents the preferences
|
||||
* @param[in] key the identifier that represents the stored value (~variable name)
|
||||
* @param[in] value the value to store
|
||||
*/
|
||||
void tt_preferences_put_bool(PreferencesHandle handle, const char* key, bool value);
|
||||
|
||||
/**
|
||||
* Store an int32_t value
|
||||
* @param[in] handle the handle that represents the preferences
|
||||
* @param[in] key the identifier that represents the stored value (~variable name)
|
||||
* @param[in] value the value to store
|
||||
*/
|
||||
void tt_preferences_put_int32(PreferencesHandle handle, const char* key, int32_t value);
|
||||
|
||||
/**
|
||||
* Store a string value
|
||||
* @param[in] handle the handle that represents the preferences
|
||||
* @param[in] key the identifier that represents the stored value (~variable name)
|
||||
* @param[in] value the value to store
|
||||
*/
|
||||
void tt_preferences_put_string(PreferencesHandle handle, const char* key, const char* value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define TT_TIMEZONE_NAME_BUFFER_LENGTH 32
|
||||
#define TT_TIMEZONE_CODE_BUFFER_LENGTH 48
|
||||
|
||||
/**
|
||||
* Set the timezone
|
||||
* @param[in] name human-readable name
|
||||
* @param[in] code the technical code (from timezones.csv)
|
||||
*/
|
||||
void tt_timezone_set(const char* name, const char* code);
|
||||
|
||||
/**
|
||||
* Get the name of the timezone
|
||||
* @param[out] buffer the output buffer which will include a null terminator (should be TT_TIMEZONE_NAME_BUFFER_LENGTH)
|
||||
* @param[in] bufferSize the size of the output buffer
|
||||
*/
|
||||
bool tt_timezone_get_name(char* buffer, size_t bufferSize);
|
||||
|
||||
/**
|
||||
* Get the code of the timezone (see timezones.csv)
|
||||
*/
|
||||
bool tt_timezone_get_code(char* buffer, size_t bufferSize);
|
||||
|
||||
/** @return true when clocks should be shown as a 24 hours one instead of 12 hours */
|
||||
bool tt_timezone_is_format_24_hour();
|
||||
|
||||
/** Set whether clocks should be shown as a 24 hours instead of 12 hours
|
||||
* @param[in] show24Hour
|
||||
*/
|
||||
void tt_timezone_set_format_24_hour(bool show24Hour);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user