<commit_before>#include "simple-app-message.h"

#include "simple-app-message-namespace.h"

#include "pebble-events/pebble-events.h"

#include <pebble.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))

typedef struct SimpleAppMessageState {
  bool initialized;
  LinkedRoot *namespace_list;
  uint32_t chunk_size;
} SimpleAppMessageState;

static SimpleAppMessageState s_sam_state;

static void prv_app_message_inbox_received_callback(DictionaryIterator *iterator, void *context) {
  // TODO update our message assembly state
  // TODO if we're done processing chunks, pass the resulting StringDict to the appropriate callback
}
<commit_msg>Send back chunk size if requested (untested)<commit_after>#include "simple-app-message.h"

#include "simple-app-message-namespace.h"

#include "pebble-events/pebble-events.h"

#include <pebble.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))

typedef struct SimpleAppMessageState {
  bool initialized;
  LinkedRoot *namespace_list;
  uint32_t chunk_size;
} SimpleAppMessageState;

static SimpleAppMessageState s_sam_state;

static void prv_send_chunk_size_response(void) {
  DictionaryIterator *chunk_size_message_iter;
  const AppMessageResult chunk_size_begin_result =
      app_message_outbox_begin(&chunk_size_message_iter);
  if(chunk_size_begin_result != APP_MSG_OK) {
    APP_LOG(APP_LOG_LEVEL_ERROR, "Failed to begin writing chunk size response, error code: %d",
            chunk_size_begin_result);
    return;
  }

  dict_write_uint32(chunk_size_message_iter, MESSAGE_KEY_SIMPLE_APP_MESSAGE_CHUNK_SIZE,
                    s_sam_state.chunk_size);
  const AppMessageResult chunk_size_send_result = app_message_outbox_send();
  if (chunk_size_send_result != APP_MSG_OK) {
    APP_LOG(APP_LOG_LEVEL_ERROR, "Failed to send chunk size response, error code: %d",
            chunk_size_send_result);
  }
}

static void prv_app_message_inbox_received_callback(DictionaryIterator *iterator, void *context) {
  if (!s_sam_state.initialized) {
    return;
  }

  // Send back the chunk size, if requested, and return
  if (dict_find(iterator, MESSAGE_KEY_SIMPLE_APP_MESSAGE_CHUNK_SIZE)) {
    APP_LOG(APP_LOG_LEVEL_INFO, "Received request for Simple App Message chunk size");
    prv_send_chunk_size_response();
    return;
  }
  // TODO update our message assembly state
  // TODO if we're done processing chunks, pass the resulting StringDict to the appropriate callback
}

{'fraction_non_alphanumeric': 0.08879668049792531, 'fraction_numerical': 0.0024896265560165973, 'mean_word_length': 5.088383838383838, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3365744', 'n_tokens_mistral': 800, 'n_tokens_neox': 783, 'n_words': 185}