prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
onfig_enable(PWR, RCC_APB1Periph_PWR);
pwr_flash_power_down_stop_mode(true /* power_down */);
periph_config_disable(PWR, RCC_APB1Periph_PWR);
vTaskStartScheduler();
for(;;);
}
static void watchdog_timer_callback(void* data) {
task_watchdog_bit_set(PebbleTask_NewTimers);
}
static void vcom_timer_callback(vo... | events_init() | ;
new_timer_service_init();
regular_timer_init();
clock_init();
task_watchdog_init();
analytics_init();
register_system_timers();
system_task_timer_init();
init_drivers();
#if defined(IS_BIGBOARD)
// Program a random S/N into the Bigboard in case it's not been done yet:
mfg_write_bigboard_serial_... |
void test_bitblt__1bit_to_8bit_src_origin_offset(void) {
GBitmap *src_bitmap =
get_gbitmap_from_pbi("test_bitblt__1bit_to_8bit_src_origin_offset.1bit.pbi");
uint8_t dest_data[100*100];
GBitmap dest_bitmap = {
.addr = dest_data,
.row_size_bytes = 100,
.info.format = GBitmapFormat8Bit,
.info.... | {
GBitmap *src_bitmap =
get_gbitmap_from_pbi("test_bitblt__1bit_to_8bit_src_origin_offset_wrap2.1bit.pbi");
uint8_t dest_data[100*100];
GBitmap dest_bitmap = {
.addr = dest_data,
.row_size_bytes = 100,
.info.format = GBitmapFormat8Bit,
.info.version = GBITMAP_VERSION_CURRENT,
.bounds = ... |
// Setup:
// - Source has 2 lines of white and the rest black.
// - Destination all blue.
// - Use gbitmap_init_as_sub_bitmap to get a sub-bitmap that starts at y = 2
// Result:
// - A 48 x 50 black box starting at y=2 in dest, rest is blue.
void test_bitblt__bitmap_into_bitmap_sub_bitmap(void) {
GBitmap *s... |
.location = location,
},
.text_color = text_color,
};
strncpy(non_local_clock.buffer, text, sizeof(non_local_clock.buffer));
return non_local_clock;
}
// Configure the text displayed on the clock.
static ClockText prv_configure_clock_text(ClockTextType type, ClockTextLocation location,
... | // disable timezones until they can be configured by the user
model.num_non_local_clocks = 0;
// TODO: Don't return a struct here
return model;
} |
static void prv_handle_time_update(struct tm *tick_time, TimeUnits units_changed) {
ClockModel model = prv_clock_model_default(tick_time);
watch_model_handle_change(&model);
}
void watch_model_cleanup() {
tick_timer_service_unsubscribe();
}
static void prv_intro_animation_finished(Animation *animation) {
co... |
uid);
BLE_HEXDUMP((uint8_t *)nsnotification, sizeof(NSNotification));
// Handle the CategoryID
if (nsnotification->category_id == CategoryIDMissedCall) {
properties |= ANCSProperty_MissedCall;
} else if (nsnotification->category_id == CategoryIDIncomingCall) {
properties |= ANCSProperty_IncomingCall;
... | if (error != BLEGATTErrorSuccess) {
PBL_LOG(LOG_LEVEL_ERROR, "Control point error response: %d", error);
prv_reset_due_to_bt_error();
return;
} |
BLE_LOG_DEBUG("Got ACK for Control Point write");
if (s_ancs_client->queue && (s_ancs_client->queue->op == NotificationQueueOpPerformAction)) {
// The action was successful
prv_reset_and_next();
}
}
static bool prv_write_control_point_request(const CPDSMessage *cmd, size_t size) {
const BLECharacter... |
d under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the ... | (37, properties, notif_attributes, app_attributes) | ;
// We just processed an incomming phone call event, there better be a phone event scheduled!
PebbleEvent event = fake_event_get_last();
cl_assert_equal_i(event.type, PEBBLE_PHONE_EVENT);
cl_assert_equal_i(event.phone.type, PhoneEventType_Incoming);
cl_assert_equal_i(event.phone.source, PhoneCallSource_ANC... |
= 0;
s_current_minute = 0;
// Default to Thursday
s_current_day = s_thursday;
timeline_item_destroy(s_last_timeline_item_added);
s_last_timeline_item_added = NULL;
s_last_timeline_item_removed_uuid = (Uuid) {};
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
pfs_format(false);
cron_service_i... | alarm_create(&(AlarmInfo) { .hour = 3, .minute = 14, .kind = ALARM_KIND_CUSTOM, .scheduled_days = &custom_schedule1 }) | |
rt.h"
#include <string.h>
inline static bool action_bar_legacy2_is_highlighted(ActionBarLayerLegacy2 *action_bar,
uint8_t index) {
PBL_ASSERTN(index < NUM_ACTION_BAR_LEGACY2_ITEMS);
return (bool) (action_bar->is_highlighted & (1 << index));
}
inline static voi... | {
return action_bar->context ? action_bar->context : action_bar;
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
button_state |= (button_is_pressed(i) ? 0x01 : 0x00) << i;
} |
return button_state;
}
void button_init(void) {
// Need to disable button wakeup functionality
// or the buttons don't register input
PWR_WakeUpPinCmd(DISABLE);
periph_config_enable(RCC_APB2PeriphClockCmd, RCC_APB2Periph_SYSCFG);
initialize_button_common();
for (int i = 0; i < NUM_BUTTONS; ++i) {
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (data->show_action_bar) {
expandable_dialog_set_select_action(expandable_dialog, RESOURCE_ID_ACTION_BAR_ICON_CHECK,
prv_select_handler);
} |
expandable_dialog_push(expandable_dialog, prv_get_window_stack());
light_enable_interaction();
kernel_free(data);
}
// ---------------------------------------------------------------------------
void health_tracking_ui_show_message(uint32_t res_id, const char *text, bool show_action_bar) {
HealthTrackingUI... |
>= 0);
cl_assert_equal_i(pfs_read(fd, (uint8_t *)rbuf, len), len);
cl_assert(memcmp(rbuf, buf, len) == 0);
cl_assert(fd >= 0);
cl_assert(pfs_close(fd) == S_SUCCESS);
}
}
static uint32_t s_watch_file_callback_called_count = 0;
static void prv_file_changed_callback(void *data) {
s_watch_file_callback... | for (int i = 0; i < pages_to_write; i+=2) {
snprintf(file_small, sizeof(file_small), "file%d", i);
uint8_t buf[PFS_SECTOR_SIZE * 2];
uint8_t bufcmp[PFS_SECTOR_SIZE * 2];
memset(&bufcmp[0], i, sizeof(bufcmp));
int fd = pfs_open(file_small, OP_FLAG_READ, FILE_TYPE_STATIC, 0);
cl_assert(fd >= 0... |
}
static bool prv_filename_filter_a_prefix_cb(const char *name) {
return (strncmp(name, "a_", 2) == 0);
}
static bool prv_find_name(ListNode *node, void *data) {
PFSFileListEntry *entry = (PFSFileListEntry *)node;
return (strcmp(entry->name, (char *)data) == 0);
}
void test_pfs__file_list(void) {
pfs_format... |
gin.y == 0) {
dy = -INITIAL_SCROLL_PX;
} else {
dy = (is_repeating) ? -REPEATING_SCROLL_PX : -SCROLL_PX;
}
}
break;
}
default:
return;
}
const AnimationCurve curve = (is_repeating) ? AnimationCurveLinear : AnimationCurveEaseOut;
prv_scroll(swap_layer,... | prv_remove_old_layout(swap_layer, swap_layer->previous) | ;
swap_layer->previous = NULL;
prv_remove_old_layout(swap_layer, swap_layer->current);
swap_layer->current = NULL;
prv_remove_old_layout(swap_layer, swap_layer->next);
swap_layer->next = NULL;
}
void swap_layer_reload_data(SwapLayer *swap_layer) {
prv_swap_layer_reset(swap_layer);
LayoutLayer *current... |
otocol_id == protocol_id) {
return handler;
}
}
return NULL;
}
// -----------------------------------------------------------------------------------------
void qemu_serial_init(void) {
// Init our state variables
qemu_serial_private_init_state(&s_qemu_state);
// Init the UART
uart_init(QEMU_U... | (QEMU_UART, *data++) | ;
}
uart_wait_for_tx_complete(QEMU_UART);
}
// -----------------------------------------------------------------------------------------
void qemu_serial_send(QemuProtocol protocol, const uint8_t *data, uint32_t len) {
if (!s_qemu_state.initialized) {
return;
}
mutex_lock(s_qemu_state.qemu_comm_lock);
... |
!!");
__disable_irq();
RTC_ITConfig(RTC_IT_WUT, DISABLE);
RTC_WakeUpCmd(DISABLE);
// disable all IRQn_Type >= 0 interrupts
for (size_t i = 0; i < ARRAY_LENGTH(NVIC->ISER); i++) {
NVIC->ICER[i] = NVIC->ISER[i];
}
// disable SysTick
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
enter_stop_mode();
... | {
s_num_sleep_iters = atoi(iters);
// It seems like advertising while doing this makes the issue more likely to happen
// (I suspect because there are even more enters/exits from sleep happening)
if (bt_test_chip_in_test_mode()) {
prompt_send_response("You must run \"bt test stop\" to conduct sleep test!")... |
void command_btle_unmod_tx_start(char *tx_channel) {
bt_driver_start_unmodulated_tx(atoi(tx_channel));
}
void command_btle_unmod_tx_stop(void) {
bt_driver_stop_unmodulated_tx();
}
void command_btle_test_le_tx_start(
char *tx_channel, char *tx_packet_length, char *packet_payload_type) {
bt_driver_le_transm... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
// track (# connection attempts * 10^3) / sec
uint32_t conn_attempts_per_sec = ((1000 * 1000 * 5) / (interval_1_25ms)) / 4;
analytics_stopwatch_start_at_rate(
ANALYTICS_DEVICE_METRIC_BLE_CONN_EVENT_COUNT,
conn_attempts_per_sec, An... | |
ID_ARGUMENT == reminder_db_insert_item(¬_a_reminder));
}
void test_reminder_db__delete_parent(void) {
prv_insert_default_reminders();
const TimelineItemId *parent_id = &item1.header.parent_id;
// cnfirm the two are here
cl_assert(reminder_db_get_len((uint8_t *)&item1.header.id, sizeof(Uuid)) > 0);
cl_ass... | reminder_db_mark_synced((uint8_t *)&item3.header.id, sizeof(TimelineItemId)) | ;
// We should now only have 2 dirty items
cl_assert_equal_i(reminder_db_is_dirty(&is_dirty), S_SUCCESS);
cl_assert(is_dirty);
dirty_list = reminder_db_get_dirty_list();
cl_assert(dirty_list);
cl_assert_equal_i(list_count((ListNode *)dirty_list), 2);
// Mark the final 2 items as synced
reminder_db_ma... |
const uint8_t *key,
int key_len,
const uint8_t *val,
int val_len) {
struct PACKED WritebackMetadata {
BlobDBCommand cmd;
BlobDBToken token;
BlobDBId db_id;
uint32_t last_updated;... | prv_blob_db_msg_decode_and_handle(session, cmd, data, data_length) | ;
}
void blob_db2_set_accepting_messages(bool enabled) {
s_b2db_accepting_messages = enabled;
}
|
R_FRAME);
if (data->circle_origin.y - data->circle_radius < 0 ||
data->circle_origin.y + data->circle_radius > data->window.layer.bounds.size.h) {
data->circle_velocity_y = data->circle_velocity_y * -1;
data->circle_color.argb = (((data->circle_color.argb + 1) & 0x3F) | 0xC0);
}
... | graphics_context_set_stroke_width(ctx, 1) | ;
}
graphics_context_set_antialiased(ctx, data->antialiased);
graphics_fill_rect(ctx, &layer->bounds);
uint8_t color_index = 0;
for (uint8_t shape_index = POINT; shape_index < MAX_SHAPES; shape_index++) {
draw_shape(ctx, data, (DrawShape)shape_index, (GColor)s_display_colors[color_index++]);
}
if ... |
{
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.start_at.max);
} | else if (strcmp(token, "TEST_END_AT") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.end_at.value);
} else if (strcmp(token, "TEST_END_AT_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.end_at.min);
} else if (strcmp(token, "TEST_END_AT_MAX") == ... | |
ta gets modified.
// The only time the data is cooked is when loading a bitmap and the glyph is compressed, in
// which case the `num_rle_units` field is turned back into `height_px`.
keyed_circular_cache_push(&font_cache->line_cache, cache_key, data);
// We return `final_data` though, because that has the act... | prv_load_font_res(app_num, font_resource, &font_info->base, false /* is_extended */) | ) {
return false;
}
// look for an extension font and load it
if (extended_resource) {
// if you want 3rd party apps to use extended fonts, you'll have to unwatch when they unload
// and create a syscall for resource_watch
PBL_ASSERTN(app_num == SYSTEM_APP);
if (font_info->extension_changed_cb... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOG_LEVEL_ERROR, "Failed to query BMA255") | ;
return;
}
const bool pass = bma255_selftest();
if (pass) {
PBL_LOG(LOG_LEVEL_DEBUG, "BMA255 self test pass, all 3 axis");
} else {
PBL_LOG(LOG_LEVEL_ERROR, "BMA255 self test failed one or more axis");
}
// Workaround to fix FIFO Frame Leakage: Disable temperature sensor (we're not using it an... |
-136, -208},
{ -888, 296, -312},
{ -880, 3176, -1104},
{ -456, 4000, -1496},
{ 88, 3280, -272},
{ 576, 1720, 424},
{ 992, 768, 256},
{ 1368, 64, -112},
// 48 seconds
{ 1264, -776, 96},
{ 1320, 128, 152},
{ 984, -216, 216},
{ 840, 336, 152},
{ 1448, 4000, -872},
{ ... | { -1768, -328, -144},
// 53 seconds
{ -1256, -120, -80},
{ -1064, 200, 72},
{ -1480, 2392, -1080},
{ -648, 4000, -2384},
{ 720, 3464, -1336},
{ 728, 1512, 144},
{ 1016, 624, 160},
{ 1560, 0, -256},
{ 1400, -656, -432},
{ 1496, -104, 272},
{ 928, -568, 560},
{ 1336... |
{ 928, 3208, -608},
{ 856, 1040, 432},
{ 1216, 568, 176},
{ 1400, -176, 0},
{ 1312, -568, -64},
{ 1216, 8, 88},
{ 936, -272, 216},
{ 1048, 48, -40},
{ 2344, 4000, -1224},
{ 2056, 4000, -1872},
{ -216, 2712, -1360},
{ -424, 1592, -688},
{ -680, 520, -224},
{ -872,... |
e) {
return; // Gotta wait for remote to subscribe.
}
if (!state->pending_response_data) {
return; // Gotta wait for FW to subscribe / write the emulated CCCD.
}
PBL_LOG(LOG_LEVEL_ALWAYS, "Phone & Watch have hit CCCD, initiate PPoGatt WA!");
hc_protocol_enqueue_with_payload(HcEndpointID_Gatt, HcMessa... | PBL_ASSERTN(msg->command_id == HcMessageID_Gatt_Write) | ;
HcGattHdr *hdr = (HcGattHdr *)&msg->payload[0];
BTErrno rv = BTErrnoOK;
hc_protocol_enqueue_response(msg, (uint8_t *)&rv, sizeof(rv)); // ack the write
prv_build_write_complete_payload(hdr, ((HcGattWriteData *)hdr)->att_handle, state);
prv_enqueue_write_complete_if_ready(state);
return true;
}
static ... |
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, row), MAX_NUM_COLS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_even_offset_odd_clip")));
}
void test_graphics_draw_line___odd_offset_horizontal_dotted(void) {
GContext ctx;
test_graphics_context_init(&ct... | TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_odd_offset_odd_clip") | |
ebble_task_bit_for_client(client),
subscription_type, BLEGATTErrorSuccess);
} else {
// When subscribing, wait for the CCCD Write Response before sending the confirmation event
// to the client.
subscription->pending_confirmation[client] = true;
}
}
if (n... | mutex_create_recursive() | ;
s_gatt_client_subscriptions_semphr = xSemaphoreCreateBinary();
PBL_ASSERTN(s_gatt_client_subscriptions_semphr);
}
//! Only for unit tests
T_STATIC bool gatt_client_get_event_pending_state(GAPLEClient client) {
return s_is_notification_event_pending[client];
}
//! Only for unit tests
SemaphoreHandle_t gatt_cli... |
window, prv_config_provider, expandable_dialog);
}
x = PBL_IF_RECT_ELSE(left_margin_px, (show_action_bar) ?
(frame.size.w - right_margin_px - left_margin_px -
action_bar_offset - right_aligned_box_reduction - icon_size.h) :
(90 - icon_size.h / 2));
y = icon_offset + PBL_IF_RECT_ELSE(0, 5);
i... | {
expandable_dialog_init(expandable_dialog, dialog_name);
} |
return expandable_dialog;
}
void expandable_dialog_close_cb(ClickRecognizerRef recognizer, void *e_dialog) {
expandable_dialog_pop(e_dialog);
}
ExpandableDialog *expandable_dialog_create_with_params(const char *dialog_name, ResourceId icon,
const char *text,... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_equal_i(notif_db_insert((uint8_t *)&hdr2, UUID_SIZE, (uint8_t *)&hdr2, sizeof(hdr2)), 0) | ;
cl_assert_equal_i(notif_db_insert((uint8_t *)&hdr3, UUID_SIZE, (uint8_t *)&hdr3, sizeof(hdr3)), 0);
cl_assert_equal_i(notif_db_flush(), 0);
fake_system_task_callbacks_invoke_pending();
cl_assert_equal_i(notif_db_get_len((uint8_t *)&hdr1, UUID_SIZE), 0);
cl_assert_equal_i(notif_db_get_len((uint8_t *)&hdr2, U... |
nough
if (!is_repeating || swap_layer->swap_delay_remaining <= 0) {
prv_attempt_swap(swap_layer, direction, false /* to_top */);
swap_layer->swap_delay_remaining = MESSAGE_SWAP_DELAY;
} else {
swap_layer->swap_delay_remaining--;
}
}
T_STATIC void prv_attempt_scroll(SwapLayer *swap_layer, ScrollDirect... | PBL_IF_RECT_ELSE(LAYOUT_BANNER_HEIGHT_RECT, LAYOUT_TOP_BANNER_HEIGHT_ROUND) | |
_LEVEL_INFO, "iOS notif pref insert <%s>", buffer);
// All records inserted from the phone are not dirty (the phone is the source of truth)
rv = settings_file_mark_synced(&file, key, key_len);
}
prv_file_close_and_unlock(&file);
return rv;
}
int ios_notif_pref_db_get_len(const uint8_t *key, int key_le... | {
return;
} |
settings_file_each(&file, prv_print_notif_pref_db, NULL);
prv_file_close_and_unlock(&file);
}
|
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (ch >= 'a' && ch <= 'z') {
ch = ch - 'a' + 10;
} else { // This will catch '\0'
break;
} |
if (ch >= base) {
break;
}
value *= base;
value += ch;
if (do_errors) {
if ((sign > 0) && (value > max)) {
value = max;
} else if ((sign < 0) && (-value < min)) {
value = -min;
}
}
nptr++;
}
if (endptr) {
*endptr = (char*)nptr;
}
return va... |
_event;
}
// Fake pins
////////////////////////////////////////////////////////////////
static Attribute title_attr = {
.id = AttributeIdTitle,
.cstring = "title",
};
static TimelineItem item1 = {
.header = {
.id = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x... | fake_event_get_count() | |
AttributeIdTimestamp,
APP_GLANCE_SLICE_NO_EXPIRATION),
.type = (AppGlanceSliceType)serialized_slice->type,
};
// Copy type-specific fields from the serialized slice to the output glance's slice
s_slice_type_impls[serialized_slice->type].init_slice_from_attr_list(&a... | (current_slice, attr_list) | ;
// Record size of the attribute list in the data struct as well as the overall size accumulator
current_attr_list_data->attr_list_size = attribute_list_get_serialized_size(attr_list);
serialized_glance_size += current_attr_list_data->attr_list_size;
}
// Allocate a buffer for the serialized glance
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
return prv_outbox_message_from_app_message_send_job((AppMessageSendJob *)send_job);
} |
// -------------------------------------------------------------------------------------------------
// Interfaces towards Send Queue:
static size_t prv_get_length(AppMessageSendJob *app_message_send_job) {
AppOutboxMessage *outbox_message =
prv_outbox_message_from_app_message_send_job(app_message_send_job)... |
ched_ops = prv_put_bytes_get_max_batched_pb_ops();
int num_ops = 500;
if (max_batched_ops < 2) { // This race condition is not possible if we aren't pre-Acking
return;
}
prv_receive_init(VALID_OBJECT_SIZE * num_ops, ObjectFirmware);
fake_comm_session_process_send_next();
fake_system_task_callbacks_inv... | assert_ack_count(0) | ;
assert_nack_count(1);
}
void test_put_bytes__abort_message_ok(void) {
prv_receive_init_and_put_fw_object();
prv_process_and_reset_test_counters();
prv_receive_abort(s_last_response_cookie);
assert_ack_count(1);
assert_nack_count(0);
assert_cleanup_event(ObjectFirmware, VALID_OBJECT_SIZE);
}
////////... |
(s_list_mutex);
return false;
}
PBL_ASSERTN(session->data);
// Incrementing open_count insures that no one else can do a dls_unlock_session(inactivate=true)
// on it and cause it to be freed before we grab the session->data->mutex below.
session->data->open_count++;
mutex_unlock_recursive(s_list_mutex... | uuid_is_system(&logging_session->app_uuid) | ) {
PBL_LOG(LOG_LEVEL_WARNING, "Deleting the system data logging session with tag %"PRIu32,
logging_session->tag);
}
mutex_lock_recursive(s_list_mutex);
DataLoggingSession **iter = &s_logging_sessions;
while (*iter != NULL) {
if (*iter == logging_session) {
*iter = (*iter)->next;
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
Animation *animation = property_animation_get_animation(
property_animation_create_bounds_origin(&pin_window->layer, from_origin, to_origin));
animation_set_duration(animation, TIMELINE_CARD_TRANSITION_MS / 2);
return animation;
} |
static void prv_pin_window_load(Window *window) {
TimelinePinWindow *pin_window = window_get_user_data(window);
Layer *window_layer = window_get_root_layer(window);
layer_init(&pin_window->layer, &window_layer->bounds);
layer_add_child(window_layer, &pin_window->layer);
TimelineItemLayer *item_layer = &pin... |
size_t alloc_size = sizeof(GAPLEConnectionIntent) +
(request->is_bonding_based ? sizeof(GAPLEConnectionIntentBonding) : 0);
intent = (GAPLEConnectionIntent *) kernel_malloc(alloc_size);
if (!intent) {
return BTErrnoNotEnoughResources;
}
memset(intent, 0, alloc_size);
... | {
// Delete the intent:
prv_intent_remove_and_free(intent);
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_layout_version_add_all_regions(false) | ;
uint8_t flash_version = 0;
uint32_t known_size = 0;
// iterate through all regions idx > 0 and see if PFS is active in the regions. If yes, increment
// flash version.
for (uint8_t i = flash_version; i < TOTAL_NUM_FLASH_REGIONS; i++) {
if ((prv_region_size(i) == 0) ||
pfs_active_in_region(kno... |
ADDR_ACCEL_SAMPLE_IDX, &sample_data, sizeof(sample_data));
}
static void prv_read_hrm_data(HRMDevice *dev, HRMData *data) {
struct PACKED {
uint16_t led_current;
uint8_t hrm_status;
uint8_t bpm;
uint8_t sqi;
} hrm_data_regs;
prv_read_register_block(dev, ADDR_LED_CURRENT_MSB, &hrm_data_regs, siz... | // changes over time.
if (num_intervals == 2 ||
num_intervals == 10 ||
(num_intervals % 30) == 0) {
prv_set_host_one_second_time_register(HRM, average_handshake_interval_ms);
}
// Read the SYNC byte to release handshake signal and enter deep sleep mode.
uint8_t unused;
prv_read_register(HRM... |
static void prv_as7000_interrupt_handler(bool *should_context_switch) {
PPG_DBG("Handshake interrupt");
PROFILER_NODE_START(hrm_handling); // Starting to respond to handshake toggle
// Reset the watchdog counter
s_missing_interrupt_count = 0;
*should_context_switch = new_timer_add_work_callback_from_isr(... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | if (key_len != sizeof(WeatherDBKey) ||
val_len < (int) MIN_ENTRY_SIZE ||
val_len > (int) MAX_ENTRY_SIZE) {
return E_INVALID_ARGUMENT;
} |
const WeatherDBEntry *entry = (WeatherDBEntry *)val;
if (entry->version != WEATHER_DB_CURRENT_VERSION) {
PBL_LOG(LOG_LEVEL_WARNING,
"Version mismatch on insert! Entry version: %" PRIu8 ", WeatherDB version: %u",
entry->version, WEATHER_DB_CURRENT_VERSION);
return E_INVALID_ARGUMENT... |
ve_dma(
const uint8_t *tx_buffer, uint8_t *rx_buffer, size_t length) {
// arbitrary timeout that should give us plenty of time to receieve a response within
const uint32_t tick_timeout = milliseconds_to_ticks(6000);
bool success = false;
if (xSemaphoreTake(s_spi_int_semph, tick_timeout) == pdTRUE) {
di... | (LOG_LEVEL_ERROR, "Insufficient space for BLE core dump -- RAM") | ;
goto powerdown;
}
flash_write_bytes((const uint8_t *)&chunk_hdr, flash_addr, sizeof(chunk_hdr));
flash_addr += sizeof(chunk_hdr);
// Write out a memory chunk header
CoreDumpMemoryHeader mem_hdr;
mem_hdr.start = (uint32_t)region_buf[region].start;
flash_write_bytes((const uint8_t *)&... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | buffer_get_bytes_remaining(b) | < length) {
return 0;
}
uint8_t* cursor = b->data + b->bytes_written;
memcpy(cursor, data, length);
b->bytes_written += length;
return length;
}
size_t buffer_remove(Buffer* const b, const size_t offset, const size_t length) {
PBL_ASSERTN(offset + length <= b->bytes_written);
memmove(&b->data[off... |
d has not been written to (both CRC and field data are blank)
// 2. The CRC and the written data match
static bool prv_field_valid(const uint8_t *field, size_t field_size) {
const bool empty = prv_buffer_empty(field, field_size);
if (empty) {
return true;
}
const uint32_t field_crc = *(uint32_t*)field;
... | ((uint8_t *)data_out, prv_current_page_flash_addr(), sizeof(*data_out)) | ;
if (!prv_valid_struct(data_out)) {
PBL_LOG(LOG_LEVEL_WARNING, "Shared PRF Storage sector # %"PRIu32" is corrupted. Invalidating"
" and starting a new one", s_valid_page_idx);
prv_invalidate_current_page();
memset(data_out, 0xFF, sizeof(*data_out));
}
}
static SharedPRF... |
0xff, sizeof(erased_hdr));
bool region_erased = (memcmp(&erased_hdr, &hdr, sizeof(hdr)) == 0);
if (!region_erased) { // unrecognized format, erase everything
prv_format_flash_logging_region();
return (UINT32_MAX); // no region in use after formatting
}
} else if (first_used_region... | prv_get_next_log_file_id(prev_log_id) | ;
s_curr_state.page_start_addr = flash_addr;
new_log_region_found = true;
break;
}
// everything was in increasing order or there was only one log generation
// if there was only one log generation, we must find the oldest part of it
if (!new_log_region_found) {
if (multiple_gens_found || (prv_... |
ES (0x0e)
#define ADDR_NUM_PPG_SAMPLES (0x0f)
#define ADDR_ACCEL_SAMPLE_IDX (0x14)
#define ADDR_ACCEL_X_MSB (0x15)
#define ADDR_ACCEL_Y_MSB (0x17)
#define ADDR_ACCEL_Z_MSB (0x19)
#define ADDR_PPG_IDX (0x1b)
#define ADDR_PPG_MSB (0x1c)
#define ADDR_PPG_LSB (0x1d)
#define ADDR_TIA_MSB (0x1e)
#define ADDR_TIA_LSB (0x1f)... | {
i2c_use(dev->i2c_slave);
bool rv = i2c_write_register_block(dev->i2c_slave, register_address, length, buffer);
i2c_release(dev->i2c_slave);
return rv;
} |
static bool prv_read_register(HRMDevice *dev, uint8_t register_address, uint8_t *value) {
i2c_use(dev->i2c_slave);
bool rv = i2c_read_register(dev->i2c_slave, register_address, value);
i2c_release(dev->i2c_slave);
return rv;
}
static bool prv_read_register_block(HRMDevice *dev, uint8_t register_address, void... |
LDOFF_TICKS);
cl_assert(!alerts_should_enable_backlight_for_type(AlertReminder));
cl_assert(alerts_should_notify_for_type(AlertOther));
cl_assert(!alerts_should_vibrate_for_type(AlertOther));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl... | (AlertOther) | );
cl_assert(alerts_should_vibrate_for_type(AlertOther));
alerts_set_notification_vibe_timestamp();
fake_rtc_set_ticks(rtc_get_ticks() + NOTIFICATION_VIBE_HOLDOFF_TICKS);
cl_assert(alerts_should_enable_backlight_for_type(AlertOther));
}
|
rcmp(token, "}") == 0) {
PBL_ASSERTN(state->test_entry.name[0] != 0);
break;
}
}
// Did we get samples?
if (state->test_entry.num_samples > 0) {
return true;
} else {
return false;
}
}
// ---------------------------------------------------------------------------------------
static ... | sscanf(token + strlen(token) + 1, "%d", &state->test_entry.cur_state_elapsed.max) | ;
} else if (strcmp(token, "TEST_IN_SLEEP") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.in_sleep.value);
} else if (strcmp(token, "TEST_IN_SLEEP_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.in_sleep.min);
} else if (strcmp(token, "TE... |
pulse_link_max_send_size()) {
// Too big to send and truncation will corrupt the packet.
PBL_LOG(LOG_LEVEL_ERROR, "Configure-Request too large to Ack");
return;
}
struct LCPPacket *packet = pulse_link_send_begin(this->protocol_number);
memcpy(packet, triggering_packet, ntoh16(triggering_packet->length... | {
if (ntoh16(packet->length) == LCP_HEADER_LEN) { // The request has no options
prv_send_configure_ack(this, packet);
return true;
} else {
// Packet has options but we don't support any options yet.
prv_send_configure_reject(this, packet);
return false;
}
} |
static void prv_on_configure_request(PPPControlProtocol *this,
struct LCPPacket *packet) {
switch (this->state->link_state) {
case LinkState_Closing:
case LinkState_Stopping:
// Do nothing
break;
case LinkState_Closed:
prv_send_terminate_ack(this, -... |
window.fly_anim = anim;
animation_schedule((Animation *)anim);
}
// cancel the flying animation
static void prv_stop_fly_dot(VoiceUiData *data) {
if (animation_is_scheduled((Animation *)data->mic_window.fly_anim)) {
GRect to;
property_animation_get_to_grect(data->mic_window.fly_anim, &to);
animation_un... | (BUTTON_ID_BACK, context) | ;
window_single_click_subscribe(BUTTON_ID_BACK, &prv_mic_click_handler);
}
static void prv_enable_select_click(VoiceUiData *data) {
window_set_click_config_provider_with_context(&data->mic_window.window,
prv_back_select_click_config_provider, data);
}
static void prv_disable_select_click(VoiceUiData *data) ... |
MES[] = { "Africa",
"America",
"Antarctica",
"Asia",
"Atlantic",
"Australia",
... | prv_database_read(region_offset + 1 /* continent index */, city_name, remaining_size) | ;
// FIXME: Perhaps we should refactor this to do one read instead of two? The information is
// right beside each other and it's pretty wasteful to do a 1 byte read followed by a 15 byte
// read as separate reads.
return true;
}
bool timezone_database_load_dst_rule(uint8_t dst_id, TimezoneDSTRule *start, Ti... |
e) {
ppogatt_destroy_state(connection->ppogatt_wa_state);
}
kernel_free(connection);
}
}
prv_unlock();
}
bool connection_is_valid(Connection *connection) {
bool rv;
prv_lock();
{
rv = list_contains((ListNode *)s_connections, (const ListNode *)connection);
}
prv_unlock();
re... | prv_unlock() | ;
return rv;
}
PPoGATTWorkAroundState *connection_get_ppogatt_wa_state(Connection *connection) {
PPoGATTWorkAroundState *state;
prv_lock();
{
state = connection->ppogatt_wa_state;
}
prv_unlock();
return state;
}
bool connection_is_gateway(Connection *connection) {
bool val;
prv_lock();
{
v... |
t alignment,
GTextAttributes *text_attributes) {}
void graphics_text_attributes_destroy(GTextAttributes *text_attributes) {}
GSize graphics_text_layout_get_max_used_size(GContext *ctx, const char *text,
GFont const font, const GRect box,
... | GRect(10, 20, 30, 40) | ;
cl_assert(root_layer->update_proc);
GContext ctx = {.lock = true};
root_layer->update_proc(root_layer, &ctx);
if (s_tictoc_callback_is_color) {
cl_assert_equal_i(1, s_graphics_fill_rect.call_count);
cl_assert_equal_i(4, s_graphics_line_draw_precise_stroked.call_count);
cl_assert_equal_i(0, s_grap... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (&timer, 0, UINT32_MAX, 2) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | DIV_X(360 * MULT_X(cur, total)) | ;
return gpoint_from_polar(frame, GOvalScaleModeFitCircle, DEG_TO_TRIGANGLE(angle));
#endif
}
#if PBL_RECT
static GPoint prv_inset_point(GRect *frame, GPoint outer_point, int32_t inset_amount) {
// Insets the given point by the specified amount
return (GPoint) {
.x = MAX(inset_amount - 1, MIN(outer_point.x, ... |
on(&config->common, config->id);
PebbleEvent e = {
.type = PEBBLE_APP_LAUNCH_EVENT,
.launch_app = {
.id = config->id,
.data = data
},
};
event_put(&e);
}
// ---------------------------------------------------------------------------------------------
bool app_manager_launch_new_app(cons... | {
destination_app_id = system_app_state_machine_get_last_registered_app();
} | else {
// If we get here, s_next_app is already setup and so we can call prv_app_switch() directly
// and return
prv_app_switch(gracefully);
return;
}
}
app_manager_set_minimum_run_level(ProcessAppRunLevelNormal);
process_manager_launch_process(&(ProcessLaunchConfig) {
.id = dest... |
----------------------------------------------------------------------------------------
CompassServiceConfig **kernel_applib_get_compass_config(void) {
static CompassServiceConfig *s_compass_config;
return &s_compass_config;
}
// ------------------------------------------------------------------------------------... | prv_get_current_task() | ;
s_log_state_task_entered[task] = false;
}
// ---------------------------------------------------------------------------------------------
EventServiceInfo* kernel_applib_get_event_service_state(void) {
static EventServiceInfo s_event_service_state;
return &s_event_service_state;
}
// -----------------------... |
_MAKE(input);
// Exercise ROCKY_ARG (automatic binding creation, defaults to malloc'd string for char *):
{
char *output = NULL;
ROCKY_ARGS_ASSIGN(ROCKY_ARG(output));
cl_assert_equal_s(output, cases[i].expected_output);
ASSERT_JS_ERROR(error_value, NULL /* Never errors out! */);
t... | cl_assert_equal_i(output.size.w.raw_value, cases[i].expected_output.size.w.raw_value) | ;
cl_assert_equal_i(output.size.h.raw_value, cases[i].expected_output.size.h.raw_value);
}
for (uint32_t j = 0; j < argc; ++j) {
jerry_release_value(argv[j]);
}
}
}
void test_rocky_api_util_args__gcolor(void) {
const char *type_error_msg =
"TypeError: Argument at index 0 is not a Str... |
ow_utc);
{ // Create a 2 hour session at 1pm ==> should be a nap
ActivitySession sessions[] = {
{
.start_utc = start_of_today + (13 * SECONDS_PER_HOUR), // 1pm
.length_min = 2 * MINUTES_PER_HOUR,
.type = ActivitySessionType_Sleep,
},
{
.start_utc = start_of_toda... | { // Create a 2h 39m session that starts at 11:59pm ==> should be regular sleep
ActivitySession sessions[] = {
{
.start_utc = start_of_today - (1 * SECONDS_PER_MINUTE), // 11:59pm
.length_min = (2 * MINUTES_PER_HOUR) + 39,
.type = ActivitySessionType_Sleep,
},
};
uint1... |
}
// ---------------------------------------------------------------------------------------
// Test to make sure we don't get steps counted while sleeping
void test_activity_algorithm_kraepelin__steps_during_sleep(void) {
const int num_minutes = 120;
// The test data
AlgMinuteDLSSample minute_data[num_minute... |
sion = sessions;
for (uint32_t i = 0; i < num_sessions; i++, session++) {
char *prefix = "";
switch (session->type) {
case ActivitySessionType_Sleep:
case ActivitySessionType_Nap:
case ActivitySessionType_RestfulSleep:
case ActivitySessionType_RestfulNap:
continue;
case A... | {
ActivityDemoAppData *data = context;
bool success;
const uint32_t k_size = 1000;
HealthMinuteData *minute_data = app_malloc(k_size * sizeof(HealthMinuteData));
if (!minute_data) {
snprintf(data->debug_card.dialog_text, sizeof(data->debug_card.dialog_text),
"Out of memory");
prv_display... |
uint32_t chunk = k_print_batch_size;
success = activity_get_minute_history(minute_data, &chunk, &utc_start);
if (!success) {
snprintf(data->debug_card.dialog_text, sizeof(data->debug_card.dialog_text),
"Failed");
prv_display_alert(data->debug_card.dialog_text);
goto exit;
}
PBL_LOG(... |
tem/hexdump.h"
#include "system/logging.h"
#include "system/testinfra.h"
#include "util/attributes.h"
#include "util/math.h"
typedef struct PACKED {
uint16_t version;
} PersistMapHeader;
#define EOF_PERSIST_ID_TAG ((int)(~0))
typedef struct PACKED {
int id;
Uuid uuid;
} PersistMapIdField;
typedef bool (*Search... | pfs_get_file_size(*fd) | |
{ 1295, 440, 114},
{ 1236, 402, 144},
{ 1064, 353, 185},
{ 879, 312, 158},
{ 778, 254, 163},
{ 793, 220, 188},
{ 862, 193, 222},
{ 850, 166, 214},
{ 809, 163, 192},
{ 914, 155, 236},
{ 1092, 144, 269},
{ 1109, 239, 152},
{ 1150, 246, 105},
{ 1259, 312, 93},
{... | { 886, 183, 212},
{ 814, 175, 175},
{ 788, 174, 183},
{ 915, 149, 238},
{ 1039, 154, 232},
{ 1115, 232, 126},
{ 1322, 256, 143},
{ 1123, 323, 18},
{ 1127, 478, -186},
{ 1072, 365, 22},
{ 1046, 270, 133},
{ 934, 259, 72},
{ 871, 283, 77},
{ 809, 346, 104},
{ 83... | |
CommSession *session = comm_session_open(transport, &s_transport_imp,
TransportDestinationSystem);
cl_assert_equal_b(comm_session_is_valid(session), true);
// Expect assert when Transport didn't clean up after itself:
cl_assert_passert(comm_session_deinit());
comm_sess... | cl_assert_equal_b(comm_session_is_current_task_send_next_task(session), false) | ;
comm_session_close(session, CommSessionCloseReason_UnderlyingDisconnection);
}
void test_session__reset_valid_session(void) {
Transport *transport = (Transport *) TransportID1;
CommSession *session = comm_session_open(transport, &s_transport_imp,
TransportDestinationS... |
bar_fill(ctx, &data->progress_bar, PROGRESS_TYPICAL_COLOR,
typical_start, sleep_start);
} else {
health_progress_bar_mark(ctx, &data->progress_bar, PROGRESS_TYPICAL_COLOR, typical_start);
}
const bool woke_up_early = (typical_sleep_end_24h > sleep_end_24h);
if (woke... | (0, y, base_layer->bounds.size.w, 60) | ;
const char *text = i18n_get("No sleep data,\nwear your watch\nto sleep", base_layer);
graphics_context_set_text_color(ctx, NO_DATA_TEXT_COLOR);
graphics_draw_text(ctx, text, data->typical_font,
rect, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
static bool prv_has_sleep_data... |
, 10 * SECONDS_PER_MINUTE + 10);
cl_assert(workout_service_stop_workout());
cl_assert(!workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone));
}
// ---------------------------------------------------------------------------... | (110, HRMQuality_Good) | ;
cl_assert(workout_service_get_current_workout_info(&steps, &duration_s, &distance_m,
&bpm, &hr_zone));
cl_assert_equal_i(steps, 10);
cl_assert_equal_i(duration_s, 10);
cl_assert_equal_i(bpm, 110);
// Get some more new data and out stats still shouldn't c... |
ession/session.h"
#include "services/common/comm_session/session_remote_version.h"
#include "services/common/comm_session/session_send_buffer.h"
#include "services/common/comm_session/session_transport.h"
#include "kernel/events.h"
extern void comm_session_set_capabilities(CommSession *session,
... | {
stub_app_init();
comm_session_init();
fake_kernel_malloc_init();
fake_kernel_malloc_mark();
fake_session_send_buffer_init();
s_send_queue_length = 0;
memset(s_transport_uuid, 0, sizeof(s_transport_uuid));
s_send_next_count = 0;
s_reset_count = 0;
s_close_count = 0;
s_last_closed_transport = NULL... | |
qual_i(4, string_list_count(list));
cl_assert_equal_s("", string_list_get_at(list, 0));
cl_assert_equal_s("", string_list_get_at(list, 1));
cl_assert_equal_s("", string_list_get_at(list, 2));
cl_assert_equal_s("", string_list_get_at(list, 3));
// non-null-terminated string is treated as one string - this is ... | (timeline_item_find_action_with_id(&item, 3), NULL) | ;
item.header.id = UUID_INVALID;
cl_assert_equal_p(timeline_item_find_action_with_id(&item, 0), NULL);
}
void test_timeline_item__find_action_by_type(void) {
// Make sure we're resilient to NULL items
cl_assert_equal_p(timeline_item_find_action_by_type(NULL, TimelineItemActionTypeGeneric), NULL);
// Make s... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
UTIL_ASSERT(iter->prev);
return iter->prev(iter->state);
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
prv_init();
Window *window = window_create();
app_window_stack_push(window, false /*animated*/);
app_event_loop();
prv_deinit();
} |
const PebbleProcessMd *idl_demo_get_app_info() {
static const PebbleProcessMdSystem s_app_data = {
.common = {
.main_func = prv_app_main,
// UUID: 101a32d95-1234-46d4-1234-854cc62f97f9
.uuid = {0x99, 0xa3, 0x2d, 0x95, 0x12, 0x34, 0x46, 0xd4,
0x12, 0x34, 0x85, 0x4c, 0xc6, 0x2f, 0... |
bytes_written += bytes_to_write;
file->offset += bytes_to_write;
if (bytes_written == size) {
break;
}
pg_offset = 0; // first usable byte next page
if (get_next_page(file->curr_page, &file->curr_page) != S_SUCCESS) {
PBL_LOG(LOG_LEVEL_WARNING, "W:Couldn't find next page for %d",
... | prv_write_erased_header_on_page_range(start_page,
start_page + PFS_PAGES_PER_ERASE_SECTOR, max_erase) | ;
if (last_written_pg != INVALID_PAGE) {
hdr.last_written = LAST_WRITTEN_TAG;
prv_flash_write((uint8_t *)&hdr.last_written, sizeof(hdr.last_written),
prv_page_to_flash_offset(last_written_pg) +
offsetof(PageHeader, last_written));
}
}
static bool prv_update_gc_reserved_region(void) {
if ... |
void prv_update_active_gateway_if_needed(BTBondingID bonding, BtPersistBondingOp op) {
// Invalidate the active gateway if it is getting deleted
if (op == BtPersistBondingOpWillDelete) {
BTBondingID current_active_gateway;
bt_persistent_storage_get_active_gateway(¤t_active_gateway, NULL);
if (curr... | {
return prv_file_get(key, key_len, data_out, buf_len);
} |
bool bt_persistent_storage_set_ble_pinned_address(const BTDeviceAddress *addr) {
GapBondingFileSetStatus rv = prv_file_set(&BLE_PINNED_ADDRESS_KEY, sizeof(BLE_PINNED_ADDRESS_KEY),
addr, addr ? sizeof(*addr) : 0);
bool success = (rv != GapBondingFileSetFail);
if (!succ... |
tic BMI160GyroPowerMode s_gyro_power_mode = BMI160_Gyro_Mode_Suspend;
static bool s_accel_outstanding_motion_work = false;
static bool s_accel_outstanding_data_work = false;
static bool s_fifo_in_use = false;
static uint8_t curr_fifo_num_samples_wm = 0;
static bool s_double_tap_detection_enabled = false;
static bool ... | ARRAY_LENGTH(readings) | |
("Battery change period: %"PRIu32"\n", got_value) | ;
cl_assert(got_value == expected_value);
dls_log_called = true;
return DATA_LOGGING_SUCCESS;
}
DataLoggingSession *dls_create(uint32_t tag, DataLoggingItemType item_type, uint16_t item_size,
bool buffered, bool resume, const Uuid *uuid) {
// We want a truthy value where derefer... | |
bool_to_str(matches_prf));
} else if (data->type == BtPersistBondingTypeBLE) {
prompt_send_response_fmt(display_buf, DISPLAY_BUF_LEN, "LE Key %d",
(int)bond_id);
prompt_send_response_fmt(display_buf, DISPLAY_BUF_LEN, " ANCS: %d Gateway: %d Req Pin: %d",
... | memcmp(key, DEVICE_NAME_KEY, info->key_len) | == 0) {
char dev_name[info->val_len + 1];
memcpy(&dev_name, val, info->val_len);
prompt_send_response_fmt(display_buf, DISPLAY_BUF_LEN, "Device Name: %s",
dev_name);
} else if (memcmp(key, BLE_PINNED_ADDRESS_KEY, info->key_len) == 0) {
if (info->val_len == sizeof(BTDeviceAddr... |
/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations un... | {
s_curr_buf = NULL;
s_no_buffer_count = 0;
s_dropped_char_count = 0;
for (int i = 0; i < NUM_RX_BUFFERS; ++i) {
prv_reset_buffer(&s_buffers[i]);
}
accessory_manager_set_state(AccessoryInputStateImaging);
accessory_use_dma(true);
s_timeout_timer = new_timer_create();
new_timer_start(s_timeout_time... |
static void prv_stop(void *context) {
if (s_no_buffer_count > 0) {
PBL_LOG(LOG_LEVEL_ERROR, "Ran out of buffers %d times and dropped %d bytes while imaging",
s_no_buffer_count, s_dropped_char_count);
}
flash_prf_set_protection(true);
accessory_use_dma(false);
accessory_manager_set_state(Acce... |
_node->node);
graphics_text_node_container_add_child(&horizontal_container_node->container,
vertically_centered_battery_icon_node);
if (settings_glance->glance_state.battery_charge_state.is_plugged) {
GTextNodeCustom *charging_icon_node =
graphics_text_node_crea... | PBL_ASSERTN(structured_glance) | ;
LauncherAppGlanceSettings *settings_glance =
launcher_app_glance_structured_get_data(structured_glance);
PBL_ASSERTN(settings_glance);
switch (event->type) {
case PEBBLE_BATTERY_STATE_CHANGE_EVENT:
settings_glance->glance_state.battery_charge_state = battery_state_service_peek();
break;
... |
zeof(addr_out));
cl_assert_equal_m(&link_key_1, &link_key_out, sizeof(link_key_out));
cl_assert_equal_s(name_1, name_out);
cl_assert_equal_i(platform_bits_1, platform_bits_out);
ret = bt_persistent_storage_get_bt_classic_pairing_by_id(id_2, &addr_out, &link_key_out,
... | {
// Output variables
SM128BitKey link_key_out;
char name_out[BT_DEVICE_NAME_BUFFER_SIZE];
uint8_t platform_bits_out;
// Store a new pairing
BTDeviceAddress addr_in = {{0x11, 0x12, 0x13, 0x14, 0x15, 0x16}};
SM128BitKey link_key_in = {{0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
... |
void test_bluetooth_persistent_storage__delete_bt_classic_pairing_by_id(void) {
bool ret;
// Output variables
BTDeviceAddress addr_out;
SM128BitKey link_key_out;
char name_out[BT_DEVICE_NAME_BUFFER_SIZE];
uint8_t platform_bits_out;
// Store a new pairing
BTDeviceAddress addr_in = {{0x11, 0x12, 0x13,... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
alerts_preferences_init();
do_not_disturb_init();
vibe_intensity_init();
} | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
GContext *context = sdl_graphics_get_gcontext();
graphics_context_set_stroke_color(context, GColorBrightGreen);
graphics_context_set_stroke_width(context, 2);
graphics_draw_line(context, (GPoint){0, 0}, (GPoint){100, 100});
graphics_draw_line(context, (GPoint){0, 10}, (GPoint){100, 10});
graphics_draw_lin... | |
Node) {
.event = *e,
};
s_event_head = (EventNode *)list_prepend((ListNode *)s_event_head, (ListNode *)node);
}
return s_can_send_event;
}
static void prv_process_callback_events_alt(bool should_execute_callback) {
EventNode *node = s_event_head;
while (node) {
EventNode *next = (EventNode *)... | {
void *result = app_inbox_create_and_register(BUFFER_SIZE, 0,
test_message_handler, test_dropped_handler);
cl_assert_equal_p(result, NULL);
} |
void test_app_inbox__app_inbox_create_and_register_null_message_handler(void) {
void *result = app_inbox_create_and_register(BUFFER_SIZE, 1, NULL, test_dropped_handler);
cl_assert_equal_p(result, NULL);
}
void test_app_inbox__app_inbox_create_and_register_oom(void) {
// FIXME: No support for OOM simulation in ... |
activity
time_t day_start = time_util_get_midnight_of(rtc_get_time());
ActivitySession walk_activity = {
.start_utc = day_start + 12 * SECONDS_PER_HOUR,
.length_min = 120,
.type = ActivitySessionType_Walk,
.step_data = {
.steps = 100,
.active_kcalories = 200,
.resting_kcalories = 3... | ASSERT_STEP_ACTIVITY_SESSION_PRESENT(&walk_activity) | ;
// Pretend that 24 hours has elapsed since we saved prefs. This should put both the step and
// sleep history 1 day behind
struct tm time_tm = s_init_time_tm;
time_tm.tm_mday += 1;
time_t utc_sec = mktime(&time_tm);
rtc_set_time(utc_sec);
prv_activity_init_and_set_enabled(true);
ASSERT_EQUAL_METRIC_... |
r ? (Uuid *)uuid_attr->data : NULL;
if (result != VoiceEndpointResultSuccess) {
voice_handle_dictation_result(result, session_id, NULL, app_initiated, app_uuid);
return false;
}
if (attr_list->num_attributes == 0) {
PBL_LOG(LOG_LEVEL_WARNING, "No attributes in message");
voice_handle_dictation_r... | (LOG_LEVEL_WARNING, "Invalid size for session setup result message") | |
distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "applib/app_message/app_message_internal.h"
#include "kern... | (MAX_HEADER_SIZE, total_payload_size) | ;
rcv->header_bytes_remaining = header_bytes_remaining;
// Always forward the header to default system receiver as well, we'll cancel it later on if the
// message was written succesfully to the app inbox.
if (!prv_fwd_prepare(rcv, session, header_bytes_remaining)) {
kernel_free(rcv);
return NULL;
}
... |
clude "stubs_pebble_tasks.h"
#include "stubs_sleep.h"
bool weather_service_supported_by_phone(void) {
return true;
}
// Setup
////////////////////////////////////////////////////////////////
void test_weather_db__initialize(void) {
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
weather_db_init();
weath... | cl_assert_equal_i(num_keys, WEATHER_DATA_SHARED_WEATHER_DB_NUM_DB_ENTRIES) | ;
}
status_t weather_db_get_keys(WeatherDBKey *keys);
void test_weather_db__test_get_keys(void) {
WeatherDBKey keys[WEATHER_DATA_SHARED_WEATHER_DB_NUM_DB_ENTRIES];
cl_assert_equal_i(S_SUCCESS, weather_db_get_keys(keys));
for(int x = 0; x < WEATHER_DATA_SHARED_WEATHER_DB_NUM_DB_ENTRIES; x++) {
cl_assert(wea... |
cs_context_init(&ctx, fb);
// TODO: Remove these #ifdefs in PBL-15916 when support for non-antialiased rounded rect
#if SCREEN_COLOR_DEPTH_BITS == 8
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 1);
graphics_fill_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, ((MIN(RECT_WIDTH, RECT_HEIGHT... | prv_clamp_corner_radius(GSize(8, 10), GCornersAll, 4) | , 4);
cl_assert_equal_i(prv_clamp_corner_radius(GSize(9, 10), GCornersAll, 4), 4);
cl_assert_equal_i(prv_clamp_corner_radius(GSize(10, 10), GCornersAll, 4), 4);
}
#define BOX_SIZE 10
#define CLIP_RECT_DRAW_BOX GRect(10, 10, 140, 30)
#define CLIP_RECT_CLIP_BOX GRect(10, 10, 120, 2*BOX_SIZE + 4)
#define CLIP_RECT_RE... |
#include <string.h>
static bool s_comm_initialized = false;
static bool s_comm_airplane_mode_on = false;
static bool s_comm_enabled = false;
static bool s_comm_is_running = false;
static bool s_comm_state_change_eval_is_scheduled;
static BtCtlModeOverride s_comm_override = BtCtlModeOverrideNone;
static PebbleMutex *s... | (s_comm_state_change_mutex) | ;
s_comm_enabled = enabled;
mutex_unlock(s_comm_state_change_mutex);
prv_comm_state_change(NULL);
}
void bt_ctl_set_override_mode(BtCtlModeOverride override) {
if (!s_comm_initialized) {
PBL_LOG(LOG_LEVEL_ERROR, "Error: Bluetooth isn't initialized yet");
return;
}
mutex_lock(s_comm_state_change_mut... |
other corners. This is used by
// bezel mode to replicate the behavior of the FPGA.
static const uint32_t s_rounded_corner_width[6] = { 6, 4, 3, 2, 1, 1 };
//! This is our root framebuffer that everything gets composited into.
static FrameBuffer DMA_BSS s_framebuffer;
typedef enum {
//! Render the app with no tran... | (compositor) | ;
// Don't trust the size field within the app framebuffer as the app could modify it.
GSize app_framebuffer_size;
app_manager_get_framebuffer_size(&app_framebuffer_size);
const FrameBuffer *app_framebuffer = app_state_get_framebuffer();
if (gsize_equal(&app_framebuffer_size, &s_framebuffer.size)) {
#if CAP... |
{ 1072, 784, -96},
{ 1160, 712, -80},
{ 1520, 616, -144},
{ 1488, 336, -88},
{ 1360, 288, -128},
{ 1472, 224, -144},
// 57 seconds
{ 1536, 280, -112},
{ 1528, 264, -88},
{ 1328, 160, -96},
{ 1088, 160, -104},
{ 888, -200, -96},
{ 752, -240, -32},
{ 672, -264, -8},
... | { 1176, 144, -88},
{ 1088, 168, -88},
{ 928, -80, -96},
{ 792, -240, 128},
{ 832, -8, -352},
{ 1224, -96, -232},
{ 1280, 208, -296},
{ 1136, 32, -272},
{ 1016, 248, -328},
{ 1208, 336, -200},
{ 1584, 512, -256},
{ 1792, 728, -184},
{ 1544, 1000, -56},
{ 1272, 896,... | |
r_timer.h"
#include "stubs_sleep.h"
#include "stubs_task_watchdog.h"
extern TimerID get_reminder_timer_id(void);
static TimelineItem item1 = {
.header = {
.id = {0x6b, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4},
.timestamp = 0,
.duration = 0,
... | cl_assert(stub_new_timer_timeout(get_reminder_timer_id()) == 1037 * 1000) | ;
now += 1037;
stub_pebble_tasks_set_current(PebbleTask_NewTimers);
cl_assert(stub_new_timer_fire(get_reminder_timer_id()));
stub_pebble_tasks_set_current(PebbleTask_KernelBackground);
fake_system_task_callbacks_invoke(1);
cl_assert_equal_i(num_events_put, 5);
cl_assert(!new_timer_scheduled(get_reminder_... |
_clone(void) {
#ifdef TEST_INCLUDE_COMPLEX
const int duration_a = 300;
const int duration_b = 200;
const int duration_c = 500;
const int repeat_count = 5;
int duration_total = duration_a + MAX(duration_b, duration_c);
// Create 3 animations
Animation *a = prv_create_test_animation();
animation_set_dura... | animation_set_handlers(spawn_b, handlers, (void *)spawn_a) | ;
break;
}
}
// Create the sequence
Animation *seq = animation_sequence_create(spawn_a, spawn_b, NULL);
// Schedule it
prv_clear_handler_histories();
uint64_t start_ms = prv_now_ms();
animation_schedule(seq);
fake_rtc_auto_increment_ticks(0);
// Let the first spawn finish
prv_advanc... |
t_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
case 2:
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE);
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_TWO);
break;
case 3:
boot_bit_set(BOOT_BIT_RESET_LOOP_DETECT_ONE);
break;
case 4:
boot_bit_clear(BOOT_BIT_RESET_LOOP_DETECT_ONE);
boot_b... | if (RCC_GetFlagStatus(RCC_FLAG_BORRST) == SET) {
dbgserial_putstr("Brown out reset");
} |
}
// SystemInit does this for the firmware, but since the bootloader isn't using
// the vendor SystemInit, initialize the flash cache here
static void prv_configure_system_flash(void) {
// Enable flash instruction and data caches
FLASH->ACR = FLASH_ACR_ICEN | FLASH_ACR_DCEN;
}
// RTC and bootbit assume access to... |
EOC = 3.82V + 0.02V * N
prv_write_register(PmicRegisters_CHARGE_VOLTAGE_CNTL, 0x18 | (1 << 6));
}
pmic_set_charger_state(true);
// Enable AutoResume: Resumes charging on voltage drop after EOC
prv_set_register_bit(PmicRegisters_CHARGE_CNTL, 6, true);
}
static void prv_configure_battery_measure(void) {
... | {
// ResetControl (Fig. 79)
// Bit 1: power_off - Start a reset cycle, and wait for ON or charger to complete the reset.
if (prv_set_register_bit(PmicRegisters_RESET_CNTL, 1, true)) {
while (1) {}
__builtin_unreachable();
}
return false;
} |
// We have no way of directly reading Vsup with as3701b on Silk. Just assume
// that we are getting what we've configured as regulated Vsup.
uint16_t pmic_get_vsys(void) {
uint8_t cfg;
prv_read_register(PmicRegisters_CHARGE_CONFIG_1, &cfg);
const uint8_t vsup_voltage = (cfg & 0x6) >> 1;
switch (vsup_voltage) ... |
torage, key, key_len,
val, val_len, mark_synced);
if (rv == S_SUCCESS) {
TimelineItemId parent_id = ((CommonTimelineItemHeader *)val)->parent_id;
if (timeline_get_private_data_source(&parent_id)) {
goto done;
}
// Not a private data source, must be a... | (pin, header, payload) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (LOW_POWER_APP_STATE_UPDATE_TIME_MS, prv_refresh_state, data) | ;
}
static void prv_prf_low_power_app_window_push(void) {
LowPowerAppData *data = app_malloc_check(sizeof(LowPowerAppData));
*data = (LowPowerAppData){};
Window* window = &data->window;
window_init(window, WINDOW_NAME("Low Power App"));
window_set_user_data(window, data);
window_set_overrides_back_button... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | gbitmap_get_data_row_info(&bmp, 3) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | system_flash_erase(FLASH_BASE, 1, NULL, NULL) | );
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_system_flash__erase_one_byte_in_middle_of_sector(void) {
cl_assert(system_flash_erase(FLASH_BASE + 12345, 1, NULL, NULL));
cl_assert_equal_i(BITS_BETWEEN(0, 0), erased_sector);
cl_assert(flash_locked);
}
void test_... |
// we ought to change our local MTU according to the requested MTU size.
// However, if we call ble_gap_mtu_size_set() here, we'd reset the ATT table... :(
// For now, stick to the configured maximum and just re-negotiate:
ble_error_t e = ble_gattc_exchange_mtu(evt->conn_idx);
if (e != BLE_STATUS_OK) {
P... | prv_handle_ple_update_request(evt->conn_idx, &conn_params->ple_req, length) | ;
break;
case PebblePairingServiceConnParamsWriteCmd_InhibitBLESleep:
power_inhibit_sleep();
rv = (length >= sizeof(PebblePairingServiceInhibitBLESleep)) ?
ATT_ERROR_OK : ATT_ERROR_INVALID_VALUE_LENGTH;
break;
default:
rv = (att_error_t)PebblePairingServiceGATTError_Unkno... |
(&connection->device.opaque, &intent->bonding->device.opaque,
sizeof(connection->device.opaque)) | );
}
return false;
}
return (0 == memcmp(connection->irk, &intent->bonding->irk, sizeof(*connection->irk)));
} else {
return bt_device_equal(&connection->device.opaque, &intent->device.opaque);
}
}
static void prv_intent_remove_and_free(GAPLEConnectionIntent *intent) {
list_remove(&inten... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | kino_reel_get_data_size(kino_reel) | , 0);
kino_reel_draw(kino_reel, &ctx, GPointZero);
}
void test_kino_reel__resource_pdci(void) {
// Test loading PDCI Kino Reel
uint32_t resource_id = sys_resource_load_file_as_resource(
TEST_IMAGES_PATH, "test_kino_reel__resource_pdci.pdc");
cl_assert(resource_id != UINT32_MAX);
KinoReel *kino_reel =... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (dest + buffer_length, GUARD_REFERENCE, buffer_length) | ;
}
void test_phone_formatting__overflowing_multibyte_initial(void) {
const size_t buffer_length = 9;
char dest[NAME_LENGTH];
memset(dest, GUARD_CHAR, NAME_LENGTH);
// This wouldn't overflow if E_ACUTE was one byte.
phone_format_caller_name("Donut " E_ACUTE "clair", dest, buffer_length);
cl_assert_equal_... |
(&l.scroll_layer).y);
cl_assert_equal_b(false, s_content_available[ContentIndicatorDirectionUp]);
cl_assert_equal_b(true, s_content_available[ContentIndicatorDirectionDown]);
const int FOCUSED = MENU_CELL_ROUND_FOCUSED_TALL_CELL_HEIGHT;
const int NORMAL = menu_cell_basic_cell_height();
cl_assert_equal_i(FOC... | (2 * NORMAL, l.selection.y) | |
ed by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "... | attribute_get_string(¬ification.attr_list, AttributeIdBody, "") | ;
// Determine which string we should use in the glance subtitle
const char *string_to_use_in_glance_subtitle = "";
if (!IS_EMPTY_STRING(title)) {
string_to_use_in_glance_subtitle = title;
} else if (!IS_EMPTY_STRING(subtitle)) {
// Fallback to the subtitle
string_to_use_in_glance_subtitle = subtit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.