mirror of
https://github.com/pebble-dev/clay.git
synced 2026-08-27 20:36:33 -04:00
[WIP] - refactor and code format
This commit is contained in:
+12
-9
@@ -6,7 +6,7 @@
|
||||
static ClayCallbacks s_callbacks;
|
||||
|
||||
static uint32_t prv_hash_key(const char *key) {
|
||||
return hash((uint8_t *)key, strlen(key));
|
||||
return hash((uint8_t *)key, (uint32_t)strlen(key));
|
||||
}
|
||||
|
||||
static bool prv_read(const char *key, void *value_out, size_t size) {
|
||||
@@ -15,19 +15,21 @@ static bool prv_read(const char *key, void *value_out, size_t size) {
|
||||
return bytes_read >= 0 && (size_t)bytes_read == size;
|
||||
}
|
||||
|
||||
static bool prv_write(const char *key, const SimpleDictDataType type, const void *data, size_t size, void *context) {
|
||||
static bool prv_write(const char *key, const void *data, size_t size) {
|
||||
uint32_t persist_key = prv_hash_key(key);
|
||||
int bytes_written = persist_write_data(persist_key, data, size);
|
||||
return bytes_written >= 0 && (size_t)bytes_written == size;
|
||||
}
|
||||
|
||||
static void prv_simple_app_message_received_callback(const SimpleDict *message, void *context) {
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
static bool prv_simple_dict_foreach_callback(
|
||||
const char *key, SimpleDictDataType type, const void *data, size_t size, void *context) {
|
||||
return prv_write(key, data, size);
|
||||
}
|
||||
|
||||
APP_LOG(APP_LOG_LEVEL_INFO, "CLAY: Received SimpleAppMessage");
|
||||
simple_dict_foreach(message, prv_write, NULL);
|
||||
static void prv_simple_app_message_received_callback(const SimpleDict *message, void *context) {
|
||||
if (!message) return;
|
||||
|
||||
simple_dict_foreach(message, prv_simple_dict_foreach_callback, NULL);
|
||||
s_callbacks.settings_updated(context);
|
||||
}
|
||||
|
||||
@@ -58,7 +60,8 @@ void clay_register_callbacks(const ClayCallbacks *callbacks, void *context) {
|
||||
SIMPLE_APP_MESSAGE_NAMESPACE, &simple_app_message_callbacks, context);
|
||||
|
||||
if (!register_success) {
|
||||
APP_LOG(APP_LOG_LEVEL_ERROR, "CLAY: Failed to register callbacks for namespace %s", SIMPLE_APP_MESSAGE_NAMESPACE);
|
||||
APP_LOG(APP_LOG_LEVEL_ERROR, "CLAY: Failed to register callbacks for namespace %s",
|
||||
SIMPLE_APP_MESSAGE_NAMESPACE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user