prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
/*
* 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... | PBL_LOG_SYNC(LOG_LEVEL_INFO, ">>>> Address 0x%lx failed to erase: 0x%lx", i, read) | |
nment);
TextLayoutExtended *layout = (TextLayoutExtended *)layout_ref;
cl_assert_equal_p(text_node->line_spacing_delta, layout->line_spacing_delta);
layout->max_used_size = s_data.max_used_size;
return layout->max_used_size;
}
// Setup and Teardown
////////////////////////////////////
void test_graphics_tex... | task_strdup("B") | ;
GTextNodeText *text_b = graphics_text_node_create_text(0);
cl_assert(text_b->node.free_on_destroy);
text_b->text = (char *)str_b;
const char *str_c = "C";
GTextNodeText text_c = {
.text = (char *)str_c,
};
cl_assert(!text_c.node.free_on_destroy);
GTextNodeCustom *custom_a = graphics_text_node_cr... |
{ 784, -352, -280},
{ 1024, -240, -384},
{ 1072, -72, -424},
{ 1088, 160, -456},
{ 1224, 184, -440},
{ 1360, 344, -552},
{ 1344, 368, -496},
{ 1184, 392, -680},
{ 1032, 464, -696},
{ 960, 504, -592},
{ 1136, 696, -696},
{ 1040, 600, -592},
{ 1256, 576, -480},
{ 1440, ... | { 1080, 528, -640},
{ 1344, 568, -544},
{ 1336, 440, -472},
{ 1224, 280, -400},
{ 992, 128, -304},
{ 960, 80, -288},
{ 1104, 136, -216},
{ 1336, 176, -248},
{ 1600, 136, -176},
// 155 seconds
{ 1368, 88, -8},
{ 1112, 96, 16},
{ 1016, -16, 72},
{ 864, -104, 0},
... |
{ 1072, 72, -568},
{ 1088, 88, -528},
{ 1176, 184, -528},
{ 1168, 264, -720},
{ 1064, 328, -792},
{ 880, 456, -840},
{ 976, 528, -808},
{ 936, 440, -576},
{ 1056, 624, -512},
{ 1136, 544, -440},
{ 1320, 592, -312},
{ 1600, 600, -288},
{ 1344, 368, -184},
{ 1048, ... |
PutRequest) + payload_size];
PutRequest *put_msg = (PutRequest *)buffer;
*put_msg = (PutRequest) {
.cmd = CmdPut,
.cookie = htonl(s_last_response_cookie),
.payload_size = htonl(payload_size) + 1 /* one off! */,
};
memcpy(&put_msg->payload[0], chunk, payload_size);
prv_receive_data(s_session, buff... | (&buffer[i], &towrite, sizeof(towrite)) | |
(window, &(WindowHandlers) {
.load = prv_chaining_window_load,
.unload = prv_chaining_window_unload,
}) | ;
window_stack_push(window_stack, window, true);
}
| |
/*
* 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... | ("pileOfPooCESU8.charCodeAt(0).toString(16)", "d83d") | |
t);
// Draw the two variations of the test image at GPointZero
prv_composite_test_draw_bitmap(&s_ctx, bitmap, GPointZero, compositing_mode);
// Then redraw the two variations offset so the bottom right edge of the right variation
// is aligned with the bottom right edge of the framebuffer
const GP... | (gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE)) | ;
}
void test_graphics_draw_bitmap__offset_bitmap_layer_across_x(void) {
prv_offset_bitmap_layer_test(GPoint(25, 0));
cl_check(gbitmap_pbi_eq(&s_ctx.dest_bitmap, TEST_PBI_FILE));
}
void test_graphics_draw_bitmap__offset_bitmap_layer_across_nx(void) {
prv_offset_bitmap_layer_test(GPoint(-25, 0));
cl_check(gbit... |
/*
* 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 localtime_r(timep, result);
} |
// Tests
////////////////////////////////////
void test_pbl_std__get_id(void) {
const int STR_SIZE = 100;
char str[STR_SIZE];
// This is the message we should get back if we try and use floating point
const char* fp_msg = "floating point not supported in snprintf";
//-------------------------------------... |
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 in writing, software
* dist... | grect_inset_internal(rect, 0, 20) | );
cl_assert_equal_grect(GRectZero, grect_inset_internal(rect, 0, 21));
cl_assert_equal_grect(GRectZero, grect_inset_internal(rect, 16, 21));
}
void test_gtypes__grect_crop_asserts_for_large_insets(void) {
GRect rect = GRect(10, 20, 30, 40);
cl_assert_equal_grect(GRect(25, 35, 0, 10), grect_crop(rect, 15));
... |
/*
* 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... | ("", 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 the standard case
// please note that the string will only be terminated if there's another \0 following
// when deserializing the data, the deserializer will append the needed \0
list->seri... |
/*
* 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_get_mask() == AlertMaskAllOn) | |
lue = persist_read_int(42);
// APP_LOG(APP_LOG_LEVEL_INFO, "Updating persist value from %d to %d", value, value + 1);
persist_write_int(42, value + 1);
}
}
static void health_event_handler(HealthEventType event, void *context) {
APP_LOG(APP_LOG_LEVEL_INFO, "app: Got health event update. event_id: %"PRIu32"... | {
handle_init();
app_event_loop();
handle_deinit();
} | |
{ -160, -96, -992},
{ -152, -88, -968},
{ -184, -112, -976},
{ -200, -128, -992},
{ -160, -136, -1000},
{ -144, -144, -1024},
{ -144, -104, -992},
{ -152, -104, -976},
{ -160, -104, -984},
{ -152, -96, -1008},
{ -160, -120, -1008},
{ -168, -120, -992},
{ -152, -120, -1... | { -208, -136, -984},
{ -200, -136, -984},
{ -176, -128, -984},
{ -184, -144, -992},
{ -200, -144, -1000},
{ -192, -160, -976},
{ -184, -144, -984},
{ -200, -144, -984},
{ -184, -144, -992},
{ -184, -152, -992},
{ -176, -144, -992},
{ -192, -136, -1008},
{ -192, -136, ... | |
(const uint8_t *) &s_meta_v0_system,
sizeof(s_meta_v0_system),
BLEGATTErrorSuccess);
// Still one client:
cl_assert_equal_i(ppogatt_client_count(), 1);
cl_assert_equal_b(ppogatt_has_client_for_uuid(&s_meta_v0_system.app_uuid), tru... | (s_characteristics[0][PPoGATTCharacteristicData],
BLESubscriptionNotifications,
GAPLEClientKernel) | ;
// Simulate getting the subscription confirmation:
ppogatt_handle_subscribe(s_characteristics[0][PPoGATTCharacteristicData],
BLESubscriptionNotifications, BLEGATTErrorSuccess);
// Expect Reset to be initiated ("Reset Request" sent by FW):
prv_assert_sent_reset_request(s_characteris... |
sed_sector = 0;
flash_locked = true;
flash_flags_set = false;
return_status = FLASH_COMPLETE;
flash_written_data = NULL;
flash_written_flag = NULL;
flash_data_start = 0;
flash_data_length = 0;
callback_called = false;
}
void test_system_flash__cleanup(void) {
free(flash_written_data);
free(flash_wr... | {
flash_locked = false;
} |
extern void FLASH_ClearFlag(uint32_t FLASH_FLAG) {
flash_flags_set = false;
}
extern FLASH_Status FLASH_EraseSector(uint32_t sector, uint8_t voltage_range) {
// Pretty sure FLASH_Sector_N defines are simply 8*N, at least for the first
// twelve sectors.
cl_assert_(!flash_locked, "Attempted to erase a locked ... |
ation = animation->parent;
}
return false;
}
// -------------------------------------------------------------------------------------------
static int32_t prv_get_elapsed(AnimationPrivate *animation, uint32_t now) {
// Compute the absolute start time of this animation, backing it up by the
// delay and any re... | if (prv_animation_is_scheduled(state, child)
|| prv_animation_children_scheduled(state, child)) {
return true;
} | |
_aa_sw(&ctx, fb, RECT_TEXT_0_0, RECT_TEXT_0_0, false, 1);
graphics_context_set_text_color(&ctx, GColorBlack);
graphics_draw_text(&ctx, "jja", &s_font_info, RECT_NEG,
GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL);
cl_check(framebuffer_is_empty("draw_text_neg", fb, GColorWhite));... | GRect(10, 70, 100, 30) | |
m digits output (zero digits)
snprintf(dstbuf, 256, "%.0uzero%.0u", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (unspecified digits, acts as zero)
snprintf(dstbuf, 256, "%.uzero%.u", 0, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Minimum digits output (negative digits, acts as zero)... | (dstbuf, "360,157360,23257157360,23257157360") | ;
snprintf(dstbuf, 256, "%llo,%jo", hurf, hurf);
cl_assert_equal_s(dstbuf, "110642547423257157360,110642547423257157360");
snprintf(dstbuf, 256, "%zo,%to", hurf, hurf);
cl_assert_equal_s(dstbuf, "23257157360,23257157360");
}
void test_sprintf__percent_x(void) {
char dstbuf[256];
// Simple %x
snprintf(ds... |
rtc_set_time(jun10th_noon_2015);
// Our test event is at June 9th 2015, 16:00:00
// Now - one day
const time_t event_time = jun10th_noon_2015 - SECONDS_PER_DAY + (4 * SECONDS_PER_HOUR);
time_t format_time;
clock_set_24h_style(true);
// June 9th 2015, 12:00:00 (-07:00:00)
format_time = event_time + SEC... | (morning, daypart_string) | ;
// (4pm today) time between 12pm and 6pm is this afternoon
daypart_string = clock_get_relative_daypart_string(timestamp, 12 /* hours_in_the_future */);
cl_assert_equal_s(afternoon, daypart_string);
// (8pm today) time between 6pm and 9pm is this evening
daypart_string = clock_get_relative_daypart_string(t... |
rg/licenses/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
* lim... | {
return attribute_group_serialize_payload(GROUP_TYPE,
attr_list,
action_group,
buffer,
buffer_size);
} |
size_t attributes_actions_get_buffer_size(AttributeList *attr_list,
TimelineItemActionGroup *action_group) {
size_t data_size = 0;
if (attr_list) {
data_size += attribute_list_get_buffer_size(attr_list);
}
if (action_group) {
data_size += sizeof(TimelineItemAc... |
/*
* 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... | {
s_periph_config_mutex = mutex_create();
} |
void periph_config_acquire_lock(void) {
mutex_lock(s_periph_config_mutex);
}
void periph_config_release_lock(void) {
mutex_unlock(s_periph_config_mutex);
}
void periph_config_enable(void *periph, uint32_t rcc_bit) {
ClockCmd clock_cmd = prv_get_clock_cmd((uintptr_t)periph);
#if PERIPH_CONFIG_DEBUG
if (prv_s... |
E_DUMP_MAX_SIZE);
s_flash_addr += prv_flash_write_bytes(&chunk_hdr, s_flash_addr,
sizeof(chunk_hdr));
s_flash_addr += prv_flash_write_bytes(&s_saved_registers.extra_reg,
s_flash_addr, chunk_hdr.size);
// Write out each of the thread ... | {
bool status = true;
uint32_t flash_addr, flash_addr_base;
// Use the standard flash driver
s_use_cd_flash_driver = false;
flash_addr_base = prv_flash_start_address(true /*new*/);
if (flash_addr_base == CORE_DUMP_FLASH_INVALID_ADDR) {
status = false;
goto cleanup;
}
flash_addr = flash_addr_b... |
// --------------------------------------------------------------------------------------------------
// Used by unit tests in to cause fw/apps/demo_apps/test_core_dump_app to encounter a bus fault during the core dump
void core_dump_test_force_bus_fault(void) {
s_test_force_bus_fault = true;
}
void core_dump_test... |
ager_get_task_context()->closing_state != ProcessRunState_Running) {
// Ignore if the app is not running (such as if it is in the process of closing)
return true;
}
if (low_power_is_active()) {
// If we're in low power mode we dont allow any interaction
return true;
}
return false;
}
static voi... | prv_configure_click_handler(BUTTON_ID_DOWN, prv_launch_timeline) | ;
prv_configure_click_handler(BUTTON_ID_SELECT, prv_launch_launcher_app);
prv_configure_click_handler(BUTTON_ID_BACK, prv_dismiss_timeline_peek);
}
void watchface_init(void) {
click_manager_init(&s_click_manager);
prv_watchface_configure_click_handlers();
}
void watchface_handle_button_event(PebbleEvent *e) {... |
/*
* 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... | (fb, &(GSize) {DISP_COLS, DISP_ROWS}) | ;
}
// Teardown
void test_graphics_draw_line__cleanup(void) {
free(fb);
}
// Tests
////////////////////////////////////
void inside_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_context_set_antialiased(ctx, false);
graphics_draw_line(ctx, GPoi... |
;
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));
s_dnd_active = true;
alerts_set_dnd_mask(AlertMaskAllOff);
alerts_set... | rtc_get_ticks() | |
storage_store_bt_classic_pairing_data(
BTDeviceAddress *addr, const char *device_name, SM128BitKey *link_key,
uint8_t platform_bits) {
if (link_key) {
// New pairing
BTClassicPairingData data;
prv_load_bt_classic_pairing_data(&data, addr, device_name, link_key, platform_bits);
prv_update_and_... | prv_shared_prf_storage_store_ble_pairing_data(&data->ble_data) | ;
}
memset(&s_pending_bondings, 0x00, sizeof(s_pending_bondings));
}
prv_unlock_pending_bonding();
}
static void prv_async_shared_prf_update_timer_cb(void *data) {
system_task_add_callback(prv_system_task_prf_update_cb, NULL);
prv_lock_pending_bonding();
{
regular_timer_remove_callback(&s_share... |
/*
* 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... | (S_SUCCESS == reminders_insert(&item3)) | ;
}
void test_reminders__cleanup(void) {
//nada
}
// Tests
////////////////////////////////////////////////////////////////
void test_reminders__timer_test(void) {
cl_assert(stub_new_timer_timeout(get_reminder_timer_id()) == 0);
cl_assert(memcmp(&item1.header.id, stub_new_timer_callback_data(get_reminder_timer... |
ue;
}
return false;
}
static bool prv_reassembly_append(const uint8_t* const data, const size_t length) {
PBL_ASSERTN(s_ancs_client->state == ANCSClientStateReassemblingNotification);
return (buffer_add(&s_ancs_client->reassembly_ctx.buffer, data, length) != 0);
}
static uint8_t prv_current_command_id(const u... | (data,
length,
s_fetched_app_attributes,
NUM_FETCHED_APP_ATTRIBUTES,
app_attrs,
... | ;
if (!complete || error) {
PBL_LOG(LOG_LEVEL_WARNING, "Error parsing app attributes");
goto fail;
}
// cache the app name
ANCSAttribute *app_id = s_ancs_client->attributes[FetchedNotifAttributeIndexAppID];
ANCSAttribute *app_name = app_attrs[FetchedAppAttributeIndexDisplayName];
ancs_app_name_stor... |
version occurs, so this is a no-op
snprintf(dstbuf, 256, "There are % x lights, the absolute value of % x", 16, -4);
cl_assert_equal_s(dstbuf, "There are 10 lights, the absolute value of fffffffc");
// Plus for positive signed
// No signed conversion occurs, so this is a no-op
snprintf(dstbuf, 256, "There ar... | cl_assert_equal_s(dstbuf, "There are 10 lights") | ;
// Variable length digits output
snprintf(dstbuf, 256, "There are %.*X lights", 3, 16);
cl_assert_equal_s(dstbuf, "There are 010 lights");
// Variable length digits output (negative digits, acts as zero)
snprintf(dstbuf, 256, "%.*Xzero%.*X", -3, 0, -3, 1);
cl_assert_equal_s(dstbuf, "zero1");
// Lengt... |
rame_time);
BMI160_DBG("Reading %d bytes", len);
uint8_t fifo_frame_len = prv_get_fifo_frame_size();
bmi160_begin_burst(BMI160_REG_FIFO_DATA | BMI160_READ_FLAG);
uint8_t curr_num_samples = (len / fifo_frame_len);
uint32_t curr_sampling_interval_us = prv_get_min_sampling_interval_us();
uint64_t start_time... | {
gpio_input_init(&BOARD_CONFIG_ACCEL.accel_int_gpios[0]);
gpio_input_init(&BOARD_CONFIG_ACCEL.accel_int_gpios[1]);
exti_configure_pin(BOARD_CONFIG_ACCEL.accel_ints[0], ExtiTrigger_Rising,
bmi160_IRQ1_handler);
exti_configure_pin(BOARD_CONFIG_ACCEL.accel_ints[1], ExtiTrigger_Rising,
bmi160_IRQ2_han... |
bool bmi160_query_whoami(void) {
uint8_t whoami = bmi160_read_reg(BMI160_REG_CHIP_ID);
PBL_LOG(LOG_LEVEL_DEBUG, "Read BMI160 whoami byte 0x%"PRIx8", expecting 0x%"PRIx8,
whoami, BMI160_CHIP_ID);
return (whoami == BMI160_CHIP_ID);
}
// TODO/NOTE: The accel & gyro self test routines changes some of the... |
static void prv_app_fetch_binaries_system_task_cb(void *data) {
AppFetchInstallRequest *request = (AppFetchInstallRequest *)data;
// check if Bluetooth is active. If so, this will send.
bool successful = comm_session_send_data(comm_session_get_system_session(), APP_FETCH_ENDPOINT_ID,
(uint8_t*)request, si... | prv_cancel_fetch_from_system_task((void *)(uintptr_t)app_id) | ;
}
void app_fetch_cancel(AppInstallId app_id) {
// Everything within app fetch happens on the background task
system_task_add_callback(prv_cancel_fetch_from_system_task, (void *)(uintptr_t)app_id);
}
bool app_fetch_in_progress(void) {
return s_fetch_state.in_progress;
}
////////////////////////////
// Exporte... |
_count; pg++) {
uint8_t page_flags = prv_get_page_flags(pg);
if ((IS_PAGE_TYPE(page_flags, PAGE_FLAG_START_PAGE)) ||
(IS_PAGE_TYPE(page_flags, PAGE_FLAG_CONT_PAGE))) {
allocated_space += free_bytes_in_page(pg);
}
}
// A full filesystem is bad for wear leveling since the same sectors will... | (display_buf) | ;
}
// Dump the first n bytes of a file (from current seek position)
void pfs_debug_dump(int fd, int num_bytes) {
char buf[16];
uint8_t *bytes = kernel_malloc(num_bytes);
if (bytes == NULL) {
prompt_send_response("malloc error");
goto cleanup;
}
memset(bytes, 0x00, num_bytes);
if ((num_bytes = pf... |
prv_get_window_stack(void) {
if (pebble_task_get_current() == PebbleTask_App) {
return app_state_get_window_stack();
}
return modal_manager_get_window_stack(ModalPriorityNotification);
}
static void prv_push_snooze_dialog(void) {
SimpleDialog *simple_dialog = simple_dialog_create("Snooze");
Dialog *dialo... | {
prv_mute_notification(action_menu_item, MuteBitfield_Weekdays);
} |
static void prv_mute_notification_weekends(ActionMenu *action_menu,
const ActionMenuItem *action_menu_item,
void *context) {
prv_mute_notification(action_menu_item, MuteBitfield_Weekends);
}
static bool prv_has_mute_action(Timeli... |
10), 4, GCornersAll);
}
void across_ny_layer_update_callback(Layer* me, GContext* ctx) {
graphics_context_set_antialiased(ctx, false);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_round_rect(ctx, &GRect(4, -5, 18, 10), 4, GCornersAll);
}
void corners_all_update_callback(Layer* me, GContext* ... | (&ctx, fb) | ;
layer_init(&layer, &GRect(0, 0, 100, 100));
layer_set_update_proc(&layer, &corners_clipped_update_callback);
layer_render_tree(&layer, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_clipped.${BIT_DEPTH_NAME}.pbi"));
}
void test_graphics_fill_rect_${BIT_DEPTH_NAME}__color(void) {
GContext ctx;
... |
/*
* 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... | gmtime_r(t, lcltime) | ;
}
void launcher_task_add_callback(void (*callback)(void *data), void *data) {
callback(data);
}
// Tests
///////////////////////////
void test_clock__basic_no_timezone_set_time(void) {
s_prefs_24h_style = false;
fake_rtc_init(0, 0);
rtc_timezone_clear();
clock_init();
static const time_t jan1st_noon_200... |
_ODD, OFFSET_RECT_EVEN, false, 1);
for (int16_t col = 0; col < MAX_NUM_COLS; col++) {
graphics_draw_vertical_line_dotted(&ctx, GPoint(col, 0), MAX_NUM_ROWS);
}
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_even_offset_odd_clip")));
}
void test_graphics_draw_line... | (gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_vert_dotted_line_odd_offset_odd_clip"))) | ;
}
void test_graphics_draw_line__dotted_cross(void) {
GContext ctx;
test_graphics_context_init(&ctx, fb);
// Test horizontal and vertical lines cross appropriately
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
// cross - even vert, odd horiz
graphics_draw_vertical_line_d... |
;
app_message_ctx->inbox.user_context = context;
app_message_ctx->outbox.user_context = context;
return retval;
}
AppMessageInboxReceived app_message_register_inbox_received(
AppMessageInboxReceived received_callback) {
AppMessageCtx *app_message_ctx = app_state_get_app_message_ctx();
AppMessageInboxRece... | app_message_outbox_close(&app_message_ctx->outbox) | |
available);
const uint8_t num_samples_available = fifo_status & 0x3f;
if (num_samples_available == 0) {
return;
}
bma255_prepare_txn(BMA255Register_FIFO_DATA | BMA255_READ_FLAG);
for (int i = 0; i < num_samples_available; ++i) {
uint8_t buf[BMA255_FIFO_FRAME_SIZE_BYTES];
for (int j = 0; j < BMA2... | exti_disable(BOARD_CONFIG_ACCEL.accel_ints[0]) | ;
exti_disable(BOARD_CONFIG_ACCEL.accel_ints[1]);
}
}
uint32_t accel_get_sampling_interval(void) {
BMA255ODR odr_max = 0;
for (uint32_t i = 0; i < ARRAY_LENGTH(s_operating_states); i++) {
if (s_operating_states[i].enabled) {
odr_max = MAX(odr_max, s_operating_states[i].odr);
}
}
uint32_t 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... | {
mutex_unlock(s_buffer_mutex);
// Note that this buffer read really should be done with the buffer mutex held.
// This works only because writes to the buffer do not advance slackers.
result = shared_circular_buffer_read(&s_buffer, &s_buffer_client, msg_length, &data_read, &read_length);
PBL_ASSER... |
// We should still be holding the buffer lock here...
}
static void handle_buffer_sync(void *data) {
const bool is_async = (uintptr_t) data;
mutex_lock(s_flash_write_mutex);
mutex_lock(s_buffer_mutex);
while (shared_circular_buffer_get_read_space_remaining(&s_buffer, &s_buffer_client) > 0) {
write_me... |
he 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 "health_sleep_summary_card.h"
#include "health_sleep_summary_card_segments.h"
... | health_data_sleep_get_typical_start_time(data->health_data) | ;
const int typical_sleep_start_12h = typical_sleep_start_24h % TWELVE_HOURS;
const int typical_sleep_end_24h = health_data_sleep_get_typical_end_time(data->health_data);
const int typical_sleep_end_12h = typical_sleep_end_24h % TWELVE_HOURS;
const int typical_start =
(typical_sleep_start_12h *... |
5, too_big);
gatt_client_subscriptions_handle_server_notification(s_connection, s_handle,
value, too_big);
prv_assert_no_event();
// Receive a GATT notification that is supposed to fill up the buffer entirely:
const size_t fill_entirely_size = (GATT_CLIENT... | cl_assert_equal_i(next_length, 0) | |
TaskTimer* timer = (TaskTimer*)node;
return timer->id == (uint32_t) data;
}
static TaskTimer* prv_find_timer(TaskTimerManager *manager, TaskTimerID timer_id) {
PBL_ASSERTN(timer_id != TASK_TIMER_INVALID_ID);
// Look for this timer in either the running or idle list
ListNode* node = list_find(manager->running_... | {
mutex_lock(manager->mutex);
// Find this timer in our list
TaskTimer* timer = prv_find_timer(manager, timer_id);
PBL_ASSERTN(!timer->defer_delete);
// If expire timer is not 0, it means we are scheduled
bool retval = (timer->expire_time != 0);
// Figure out expire timer?
if (expire_ms_p != NULL && ... |
// --------------------------------------------------------------------------------
// Stop a timer. If the timer callback is currently executing, return false, else return true.
bool task_timer_stop(TaskTimerManager *manager, TaskTimerID timer_id) {
mutex_lock(manager->mutex);
// Find this timer in our list
... |
i == 0 ? &layout->icon_layer :
layout->metric_icon_layers[i - 1],
},
};
GTextNodeText *metric_node =
(GTextNodeText *)layout_create_text_node_from_config(
layout_ref, &metric_config.extent.node);
prv_add_metric(layout, vertical_node, i, &metric_node... | layer_set_frame(&kino_layer->layer, &frame) | ;
}
if (size_out) {
*size_out = frame.size;
}
}
GTextNodeCustom *layout_node_create_kino_layer_wrapper(KinoLayer *kino_layer) {
return graphics_text_node_create_custom(prv_kino_layer_wrapper_callback, (void *)kino_layer);
}
|
ootReasonCode_LauncherPanic, 0 };
reboot_reason_set(&reason);
system_reset();
}
void command_hard_crash() {
prompt_command_finish();
RebootReason reason = { RebootReasonCode_HardFault, 0 };
reboot_reason_set(&reason);
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
boot_bit_set(BOOT_BIT_SOFTWARE_FAILUR... | (timeout_string, &end, 10) | );
return (*end == '\0');
}
//! Press a button multiple times.
//! @param button_index The index of the button in \ref ButtonId to press.
//! @param presses The number of times to press the button. If NULL, defaults to 1. If <= 0, errors.
//! @param hold_down_time_ms The time (in ms) to hold down the button for each... |
const ActivitySettingsValueHistory *step_history) {
bool tracking = s_activity_state.started || tracking_on;
bool test_mode = s_activity_state.test_mode;
activity_stop_tracking();
while (s_activity_state.started) {
// Wait for stop_tracking KernelBG callback to run
sys_psleep(1);
}
cron_job_u... | for (ActivitySessionType activity = ActivitySessionType_Sleep;
activity < ActivitySessionTypeCount; activity++) {
ActivitySession session = {
.start_utc = session_start_utc,
.length_min = 10,
.type = activity,
};
activity_sessions_prv_send_activity_session_to_data_logging(&session);... |
// Send a fake minute-data record
activity_algorithm_test_send_fake_minute_data_dls_record();
}
bool activity_test_send_fake_dls_records(void) {
// Enqueue it for KernelBG to process
return system_task_add_callback(prv_send_fake_dls_records_system_cb, NULL);
}
// -------------------------------------------... |
rn ((AppInboxNode *)found_node)->buffer.storage == (uint8_t *)data;
}
static AppInboxNode *prv_find_inbox_by_storage(uint8_t *storage) {
return (AppInboxNode *) list_find((ListNode *)s_app_inbox_head,
prv_list_filter_by_storage, storage);
}
static bool prv_list_filter_by_tag(List... | (LOG_LEVEL_ERROR, "No AppInbox message handler!") | ;
return;
}
if (!info.num_success && !info.num_failed) {
// Shouldn't ever happen, but better not PBL_ASSERTN on app task
PBL_LOG(LOG_LEVEL_ERROR, "Got callback, but zero messages!?");
// fall-through
}
// These conditions are redundant, just for safety:
while ((num_message_consumed < info.nu... |
_write(&buffer, (uint8_t*) "789", 3)); // too big
cl_assert_equal_i(circular_buffer_get_write_space_remaining(&buffer), 2);
cl_assert(circular_buffer_read(&buffer, 4, &out_buffer, &out_length));
cl_assert_equal_i(out_length, 4);
cl_assert(memcmp(out_buffer, "1234", 4) == 0);
cl_assert_equal_i(circular_buffer... | cl_assert_equal_i(circular_buffer_copy_offset(&buffer, 4 /* start_offset */,
data_out, data_out_size), 0) | ;
// Free up 2 bytes at the beginning:
circular_buffer_consume(&buffer, 2);
// Write data that will be wrapped:
cl_assert_equal_b(circular_buffer_write(&buffer, (uint8_t *)"456789", 6), true);
cl_assert_equal_i(circular_buffer_copy_offset(&buffer, 2 /* start_offset */,
... |
and yellow on bottom because data rows are vertically flipped)
const GSize right_rects_size = GSize(bitmap_bounds_size->w * 2 / 5, bitmap_bounds_size->h / 4);
const int16_t right_rects_x = bitmap_bounds->size.w * 3 / 5;
const int16_t right_rects_y_offset = ((bitmap_bounds_size->h / 2) - right_rects_size.h) / 2;
... | {
const Fixed_S16_3 x1_fixed = (Fixed_S16_3) { .integer = x1 };
Fixed_S16_3 x2_fixed = (Fixed_S16_3) { .integer = x2 };
const uint8_t gradient_width = (x2 - x1) / 6;
x2_fixed.integer -= gradient_width;
prv_assign_horizontal_line_delta_raw(&ctx->dest_bitmap, y, x1_fixed, x2_fixed, gradient_width,
... | |
/*
* 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... | framebuffer_clear(fb) | ;
// Setup resources
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
pfs_format(true /* write erase headers */);
load_resource_fixture_in_flash(RESOURCES_FIXTURE_PATH, SYSTEM_RESOURCES_FIXTURE_NAME,
false /* is_next */);
resource_init();
ContentIndicatorsBuffer *buf... |
/*
* 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... | (testbuf, expectbuf, 8) | ;
}
|
string_list_get_at(headings, i) | ;
const char *paragraph = string_list_get_at(paragraphs, i);
if (!heading || !paragraph) {
break;
}
GTextNodeText *heading_node =
(GTextNodeText *)layout_create_text_node_from_config(
layout, &s_heading_config.extent.node);
GTextNodeText *paragraph_node =
(GTextNod... | |
VENT,
.media.type = PebbleMediaEventTypeNowPlayingChanged
};
event_put(&e);
}
bool music_set_connected_server(const MusicServerImplementation *implementation, bool connected) {
enum {
Disconnected = -1,
None = 0,
Connected = 1,
} change_type = None;
mutex_lock_recursive(s_music_ctx.mutex);
... | prv_update_string_and_put_event(album, album_length, o) | ;
}
static void prv_put_pos_changed_event(void) {
PebbleEvent e = {
.type = PEBBLE_MEDIA_EVENT,
.media.type = PebbleMediaEventTypeTrackPosChanged,
};
event_put(&e);
}
void music_update_track_position(uint32_t track_pos_ms) {
mutex_lock_recursive(s_music_ctx.mutex);
s_music_ctx.track_pos_ms = track_... |
ttings_key, sizeof(m_info.settings_key),
m_info.value_p, sizeof(*m_info.value_p));
activity_private_settings_close(file);
}
// ------------------------------------------------------------------------------------------
// The median HR should get updated before calling this
static void prv_update_... | activity_private_state() | ;
return state->step_data.steps;
}
static uint8_t prv_get_hr_quality_weight(HRMQuality quality) {
static const struct {
HRMQuality quality;
uint8_t weight_x100;
} s_hr_quality_weights_x100[] = {
{HRMQuality_NoAccel, 0 },
{HRMQuality_OffWrist, 0 },
{HRMQuality_NoSignal, 0 },
{HRMQuality_Wo... |
L);
if (is_existing_intent) {
if (intent->client[c].is_used) {
return BTErrnoInvalidState;
}
} else {
// Create intent for device and add to list:
const size_t alloc_size = sizeof(GAPLEConnectionIntent) +
(request->is_bonding_based ? sizeof(GAPLEConnectionIntentBon... | {
// Send virtual disconnection event:
const PebbleTaskBitset task_mask = ~gap_le_pebble_task_bit_for_client(c);
prv_put_connection_event(task_mask, device, hci_reason, false /* connected */, bonding_id);
} |
if (should_remove_and_free) {
// Delete the intent:
prv_intent_remove_and_free(intent);
}
return BTErrnoOK;
}
// -------------------------------------------------------------------------------------------------
void gap_le_connect_handle_bonding_change(BTBondingID bonding_id, BtPersistBondingOp op) {... |
if (menu_layer->callbacks.get_num_rows == NULL) {
PBL_LOG(LOG_LEVEL_ERROR, "Please set menu layer callbacks before running menu_layer_set_selected_index.");
return;
} |
const uint16_t num_rows = menu_layer->callbacks.get_num_rows(menu_layer, index.section, menu_layer->callback_context);
if (index.row >= num_rows) {
index.row = num_rows - 1;
}
// when called from iteration triggered by menu_layer_set_selected_next() the
// selection.index.section could be MENU_INDEX_NO... | |
ion_remote_version_start_requests(CommSession *session) {
}
void bt_persistent_storage_set_cached_system_capabilities(
const PebbleProtocolCapabilities *capabilities) {
}
// Fakes
///////////////////////////////////////////////////////////
#include "fake_kernel_malloc.h"
#include "fake_session_send_buffer.h"
#in... | PBL_LOG(LOG_LEVEL_DEBUG, "Wrote %zu bytes", length) | ;
}
static void prv_system_test_receiver_finish(Receiver *receiver) {
++s_finish_count;
}
static void prv_system_test_receiver_cleanup(Receiver *receiver) {
++s_cleanup_count;
}
const ReceiverImplementation g_system_test_receiver_imp = {
.prepare = prv_system_test_receiver_prepare,
.write = prv_system_test_r... |
(config, ctx->hour, ctx->minute) | ;
}
config->hour = ctx->hour;
config->minute = ctx->minute;
return true;
}
void alarm_set_time(AlarmId id, int hour, int minute) {
prv_assert_alarm_params(hour, minute);
prv_alarm_operation(id, prv_set_alarm_time_op, &(SetAlarmTimeContext) { hour, minute });
}
// ------------------------------------------... | |
ifferent lengths
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 1);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 1), MAX_NUM_COLS);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 3), 148);
graphics_draw_horizontal_line_dotted(&ctx, GPoint(0, 5), 0);
graphics_draw_hor... | (gbitmap_pbi_eq(&ctx.dest_bitmap,
TEST_NAMED_PBI_FILE("draw_horiz_dotted_line_even_offset_even_rows_no_clip"))) | |
();
cl_assert_equal_i(s_data.num_will_change_calls, 1);
const GRect to_area_expected = GRect(0, 0, DISP_COLS, MIN(200, DISP_ROWS));
cl_assert_equal_grect(s_data.last_will_change_final_area, to_area_expected);
}
void test_unobstructed_area_service__will_change_twice(void) {
UnobstructedAreaHandlers handlers = {... | (app_state_get_unobstructed_area_state()->handlers.did_change, prv_did_change) | |
/*
* 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... | (&data->window, WINDOW_NAME("Double Tap Test")) | ;
window_set_user_data(&data->window, data);
window_set_window_handlers(&data->window, &(WindowHandlers) {
.load = prv_window_load });
const bool animated = true;
app_window_stack_push(&data->window, animated);
accel_double_tap_service_subscribe(prv_handle_tap);
}
static void prv_handle_deinit(void) ... |
s;
StepTestResults test_results[k_max_tests];
StepFileTestEntry test_entry[k_max_tests];
while (prv_accel_sample_discovery_next(&test_entry[num_tests])) {
StepFileTestEntry *entry = &test_entry[num_tests];
#ifdef STEP_TEST_ONLY
if (strcmp(entry->name, STEP_TEST_ONLY)) {
continue;
}
#endif
... | if (!passed) {
return "FAIL";
} else {
return "pass";
} |
}
// ---------------------------------------------------------------------------------------
// Returns the weighted error of this test
static float prv_compute_test_error(const char *name, ExpectedValue *exp, ActualValue *act,
float weight, bool *all_passed) {
int error = 0;
... |
c - time_elapsed,
.length_min = time_elapsed,
.type = ActivitySessionType_Run,
.ongoing = true,
};
activity_sessions_prv_add_activity_session(&run_activity);
// Run session active, ensure that asking if a run is ongoing returns true
cl_assert_equal_b(true, activity_sessions_is_session_type_ongoing(... | (&start_tm) | |
t_click_config_onto_window(menu_layer, &data->window);
layer_add_child(&data->window.layer, menu_layer_get_layer(menu_layer));
}
static void prv_information_window_unload(Window *window) {
SettingsSystemData *data = (SettingsSystemData*) window_get_user_data(window);
menu_layer_deinit(&data->menu_layer);
prv_... | fonts_get_system_font(FONT_KEY_GOTHIC_18) | ;
graphics_draw_text(ctx, text, font, box, GTextOverflowModeFill, GTextAlignmentLeft, NULL);
}
static void prv_draw_rt_cell_round(GContext *ctx, const Layer *cell_layer, GBitmap *mark,
const char *text, bool is_selected) {
GRect rt_rect = cell_layer->bounds;
const int16_t horiz... |
////
// Description:
// During the load handler of a window, we pop it.
void test_window_stack__pop_during_window_load(void) {
Window *window = window_create();
window_set_window_handlers(window, &(WindowHandlers){
.load = prv_pop_window_load,
.unload = prv_window_unload
});
WindowStack *stack = app_s... | (window_stack_count(stack), 1) | |
MT+4 */
[28]={ 0, 0, 4 * SECONDS_PER_HOUR },
/* Syria (Syria) [Asia/Damascus]
Rule Syria 2012 max - Mar lastFri 0:00 1:00 S
Rule Syria 2009 max - Oct lastFri 0:00 0 -
Mar 26th 2015 22:00 UTC ~ Oct 29th 2015 21:00 UTC, GMT+2 */
[29]={ 142740720... | (clock_to_timestamp(MONDAY, 17, 30), mktime(&jan_6)) | ;
}
void test_clock__clock_to_timestamp(void) {
s_prefs_24h_style = false;
fake_rtc_init(0, 0);
rtc_timezone_clear();
static const time_t jan1st_noon_2005 = 1104580800;
static const int32_t min_gmtoff = -12 * SECONDS_PER_HOUR;
static const int32_t max_gmtoff = 12 * SECONDS_PER_HOUR;
static const int32_... |
he packing end.
*/
static const uint8_t LEVEL_MAP[8] = { LOG_LEVEL_ALWAYS, LOG_LEVEL_ERROR, LOG_LEVEL_WARNING,
LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_VERBOSE,
LOG_LEVEL_DEBUG_VERBOSE, LOG_LEVEL_DEBUG_VERBOSE };
static const struct OV... | if (length == 0) {
return;
} | |
() + ms / MS_PER_SECOND);
}
// Test that we handle different update intervals correctly
void test_hrm_manager__update_interval(void) {
AppInstallId app_id = 1;
uint32_t update_interval_s = 600;
const uint16_t expire_s = 30 * SECONDS_PER_MINUTE;
HRMFeature features = HRMFeature_BPM;
HRMSessionRef session_ref ... | cl_assert(!prv_can_turn_sensor_on()) | ;
fake_system_task_callbacks_invoke_pending();
cl_assert(!hrm_is_enabled(HRM));
s_activity_prefs_heart_rate_is_enabled = true;
hrm_manager_handle_prefs_changed();
cl_assert(prv_can_turn_sensor_on());
fake_system_task_callbacks_invoke_pending();
cl_assert(hrm_is_enabled(HRM));
// Test charging state ch... |
static bool prv_write_data(DataLoggingSessionStorage *storage, const void *data,
uint32_t remaining_bytes) {
const uint8_t *data_ptr = data;
// Write out in chunks
while (remaining_bytes > 0) {
uint8_t data_chunk_length = MIN(DLS_MAX_CHUNK_SIZE_BYTES, remaining_bytes);
// Writ... | pfs_close(session->storage.fd) | ;
// Close the new file now. That will finish up the swap for us
pfs_close(new_storage.fd);
new_storage.fd = DLS_INVALID_FILE;
// Plug in the new storage info into the session
session->storage = new_storage;
PBL_LOG_D(LOG_DOMAIN_DATA_LOGGING, LOG_LEVEL_DEBUG,
"After compaction: size: %d, num_... |
--------
// Set the send_enable setting
void dls_set_send_enable_pp(bool setting) {
s_sends_enabled_pp = setting;
}
// ----------------------------------------------------------------------------------------
// Set the send_enable setting
void dls_set_send_enable_run_level(bool setting) {
s_sends_enabled_run_level... | rtc_get_time() | |
const AppRegistryEntry *reg_entry = &APP_RECORDS[i];
if (reg_entry->type == AppInstallStorageFw) {
const PebbleProcessMd *md = reg_entry->md_fn();
if (md && uuid_equal(&md->uuid, uuid)) {
return reg_entry->id;
}
} else if ((reg_entry->type == AppInstallStorageResources)
&& uui... | (s_head_callback_node_list, &callback_node->node) | ;
}
void app_install_deregister_callback(struct AppInstallCallbackNode *callback_node) {
PBL_ASSERTN(callback_node->node.next != NULL
|| callback_node->node.prev != NULL
|| s_head_callback_node_list == &callback_node->node);
list_remove(&callback_node->node, &(s_head_callback_node_list)... |
///////////////////////////
void watch_app_prefs_db_init(void) {
s_watch_app_prefs_db.mutex = mutex_create_recursive();
}
// All entries in this db currently follow a structure of base data + arbitrary list of records.
// All records in the list are the same size
static bool prv_validate_received_pref(const size_t ... | {
mutex_lock_recursive(s_watch_app_prefs_db.mutex);
status_t rv = pfs_remove(SETTINGS_FILE_NAME);
mutex_unlock_recursive(s_watch_app_prefs_db.mutex);
return rv;
} | |
seconds);
INSIGHTS_LOG_DEBUG("Not adding sleep pin - already checked session %ld", sleep_exit_utc);
return;
}
// Insert or update the pin
INSIGHTS_LOG_DEBUG("Adding sleep pin");
prv_push_sleep_summary_pin(now_utc, sleep_exit_utc, sleep_enter_seconds, sleep_exit_seconds,
sle... | i18n_get("Dismiss", ¬if_attr_list) | );
AttributeList open_app_action_attr_list = {};
AttributeList open_pin_action_attr_list = {};
// Unfortunately, open app and pin both need the parent uuid, so they are mutually exclusive
// Give open pin more precedence since the pin also links to the app
if (config->open_pin.enabled) {
attribute_list_a... |
type
0x02, // Sentence count
// Sentence #1
0x02, 0x00, // Word count
// Word #1
85, // Confidence
0x05, 0x00, // Word length
'H', 'e', 'l', 'l', 'o',
// Word #2
74, // Confidence
0x08, 0x00, // Word length
'c', 'o', 'm', 'p', 'u', 't', 'e... | (attr_list1, VEAttributeIdAppUuid,
sizeof(data1) - sizeof(Uuid)) | ;
cl_assert(!attr3);
attr3 = generic_attribute_find_attribute(attr_list1, VEAttributeIdAppUuid,
sizeof(data1) - sizeof(Uuid) - 1);
cl_assert(!attr3);
}
void test_generic_attribute__add_attribute(void) {
uint8_t data[] = {
0x01, 0x55, 0x77, 0x54, 0x47
};
uint8... |
/*
* 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... | GEdgeInsets(0, ACTION_BAR_WIDTH + x_margin, 0,
x_margin) | );
GRect frame = grect_inset(window_layer->bounds, insets);
frame.origin.y = label_y_offset;
return frame;
}
//! Drawing function for our Window's base Layer. Draws the background, the label, and the value,
//! which is everything on screen with the exception of the child ActionBarLayer
void prv_update_proc(Laye... |
bytes transaction in our progress struct
switch (pb_event->object_type) {
case ObjectWatchApp:
s_fetch_state.app = true;
break;
case ObjectWatchWorker:
s_fetch_state.worker = true;
break;
case ObjectAppResources:
s_fetch_state.resources = true;
brea... | (FETCH_TIMEOUT_MS) | ;
}
//! Called from the system task. Translates an Endpoint error to an event error and sends
//! off the appropriate event.
void prv_handle_app_fetch_install_response(uint8_t result_code) {
switch (result_code) {
case APP_FETCH_RESPONSE_STARTING:
PBL_LOG(LOG_LEVEL_INFO, "Phone confirmed it will start send... |
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 "task_... | mutex_lock(manager->mutex) | ;
// Find this timer
TaskTimer* timer = prv_find_timer(manager, timer_id);
PBL_ASSERTN(!timer->defer_delete);
// If this timer is currently executing it's callback, return false if
// TIMER_START_FLAG_FAIL_IF_EXECUTING is on
if (timer->executing && (flags & TIMER_START_FLAG_FAIL_IF_EXECUTING)) {
mutex... |
/*
* 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... | bt_driver_cb_gatt_handle_indication(&evt) | ;
}
break;
}
default:
PBL_LOG(LOG_LEVEL_ERROR, "Unhandled command id: %d", msg->command_id);
}
}
static BTErrno prv_enqueue_and_get_rv(
HcCommandID cmd_id, const uint8_t *data, size_t data_len, bool resp_required) {
BTErrno rv;
if (resp_required) {
HcProtocolMessage *resp = hc_p... |
s_md.h"
#include "process_management/pebble_process_md.h"
#include "process_state/app_state/app_state.h"
#include "services/common/comm_session/session.h"
#include "services/common/comm_session/session_send_buffer.h"
#include "services/common/system_task.h"
#include "system/logging.h"
#include "system/passert.h"
#defi... | (data->window, true /*animated*/) | ;
}
static void handle_deinit(void) {
// Don't bother freeing anything, the OS should be re-initing the heap.
}
// =================================================================================
static void s_main(void) {
handle_init();
app_event_loop();
handle_deinit();
}
// =============================... |
}
return was_attr_list_deserialized;
}
typedef struct SliceDeserializationIteratorContext {
AppGlance *glance_out;
bool deserialization_failed;
} SliceDeserializationIteratorContext;
static bool prv_deserialize_slice(SerializedAppGlanceSliceHeader *serialized_slice, void *context) {
SliceDeserializationIte... | {
return E_OUT_OF_MEMORY;
} |
}
status_t rv;
// Iterate over the glance slices, creating attribute lists and summing the size we need for the
// overall serialized slice
size_t serialized_glance_size = sizeof(SerializedAppGlanceHeader);
for (unsigned int slice_index = 0; slice_index < glance->num_slices; slice_index++) {
SliceSer... |
/*
* 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 (e->type == PEBBLE_HRM_EVENT) {
snprintf(app_data->status_string, STATUS_STRING_LEN,
"TIA: %"PRIu16"\nLED: %"PRIu16" mA", e->hrm.led.tia, e->hrm.led.current_ua);
layer_mark_dirty(&app_data->window.layer);
} | |
/*
* 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... | {
case HcMessageID_Gatt_ReadCompleted: {
HcGattReadRespData *r_data = (HcGattReadRespData *)&msg->payload[0];
PBL_LOG(LOG_LEVEL_DEBUG, "Gatt: Got a read complete event: handle=%d, len=%d",
r_data->att_handle, r_data->value_length);
PBL_HEXDUMP(LOG_LEVEL_DEBUG, r_data->value, r_data->... |
.attr_val = ni_data->value,
};
if (msg->command_id == HcMessageID_Gatt_Notification) {
bt_driver_cb_gatt_handle_notification(&evt);
} else {
bt_driver_cb_gatt_handle_indication(&evt);
}
break;
}
default:
PBL_LOG(LOG_LEVEL_ERROR, "Unhandled command id:... |
l below require the caller to own the bt_lock while calling the
// function and for as long as the result is being used / accessed.
// -------------------------------------------------------------------------------------------------
GAPLEConnection *gap_le_connection_any(void) {
return s_connections;
}
static bool... | {
strncpy(name_out, connection->device_name, name_out_len);
} |
name_out[name_out_len - 1] = '\0';
}
unlock:
bt_unlock();
}
|
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, UUID_SIZE), 0);
cl_assert_equal_i(notif_db_get_len((uint8_t *)&hdr3, UUID_SIZE), 0);
}
| |
fer_end && *buffer != ' ') {
++buffer;
}
*(buffer++) = 0;
}
args.num_args = NUM_SUPPORTED_PARAM_COUNT;
return args;
}
static void prv_execute_given_command(const Command* cmd, char* param_str, char* param_str_end) {
CommandArgs args = prv_parse_arguments(param_str, param_str_end);
if (args.nu... | system_task_add_callback_from_isr(prv_execute_command_from_dbgserial, NULL,
should_context_switch) | ;
return;
}
if (UNLIKELY(c == 0x7f)) { // Backspace
if (s_dbgserial_prompt_context.write_index != 0) {
s_dbgserial_prompt_context.write_index--;
dbgserial_putchar(0x8); // move cursor back one character
dbgserial_putchar(0x20); // replace that character with a space, advancing the cursor
... |
ity.
//
// So this function is broken into 3 parts:
// 1. Do reads 1 byte at a time until buffer_ptr is word-aligned
// 2. Do 32-bit DMA transfers for as much as possible
// 3. Do reads 1 bytes at a time to deal with non-aligned acceses at the end
const uint32_t word_mask = dcache_alignment_mask_minimum(QS... | prv_set_ddr_enabled(false) | ;
// Prepare transaction
uint32_t modes_bitset = 0;
modes_bitset |= QSPI_ComConfig_FMode_Auto_Polling;
modes_bitset |= QSPI_ComConfig_DMode_4Line;
modes_bitset |= QSPI_ComConfig_IMode_4Line;
modes_bitset |= instruction;
prv_set_comm_config(modes_bitset, 0);
uint32_t loops = 0;
while (QSPI_GetFlagSta... |
/*
* 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... | {
ActivitySession *ret_uuid = *(ActivitySession **)arg;
// TODO: Do something here
return true;
} | |
/*
* 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_put_byte(datum) | ;
}
}
static void prv_prompt_output_cb(int16_t *samples, size_t sample_count, void *context) {
const int OUTPUT_SAMPLE_RATE = (s_is_8khz) ? 8000 : 16000;
int to_process = MIN((int)sample_count, s_timeout);
s_timeout -= to_process;
if (to_process > 0) {
// Groups of samples are encapsulated in HDLC-like... |
nel_3;
static const uint32_t FLASH_DMA_IRQn = DMA2_Stream0_IRQn;
static const uint32_t FLASH_DATA_REGISTER_ADDR = (uint32_t)&(SPI1->DR);
/* TX DMA */
static DMA_Stream_TypeDef* FLASH_TX_DMA_STREAM = DMA2_Stream3;
static const uint32_t FLASH_TX_DMA_CHANNEL = DMA_Channel_3;
static uint32_t analytics_read_count;
static u... | DMA_ITConfig(FLASH_DMA_STREAM, DMA_IT_TC, ENABLE) | ;
// enable the DMA stream to start the transfer
SPI_I2S_DMACmd(FLASH_SPI, SPI_I2S_DMAReq_Tx | SPI_I2S_DMAReq_Rx, ENABLE);
}
static void do_dma_transfer(void) {
xSemaphoreTake(s_flash_state.dma_semaphore, portMAX_DELAY);
stop_mode_disable(InhibitorFlash);
DMA_Cmd(FLASH_DMA_STREAM, ENABLE);
DMA_Cmd(FLASH_T... |
l_assert(bitmap);
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(1)));
gbitmap_sequence_update_bitmap_next_frame(bitmap_sequence, bitmap, NULL);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(2)));
gbitmap_sequence_update_bitmap_next_f... | (gbitmap_pbi_eq(bitmap, GET_PBI_NAME(3))) | ;
// Frame 3 has delay 1000 ms, frame 4 and 5 have zero delay, so at time 2000 ms == frame 5
gbitmap_sequence_update_bitmap_by_elapsed(bitmap_sequence, bitmap, 2 * 1000);
cl_check(gbitmap_pbi_eq(bitmap, GET_PBI_NAME(5)));
// Since loop only equals 1, make sure that huge elapsed time leaves us at final frame
... |
/*
* 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... | (fd, buf, length) | |
ting, 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 <string.h>
#include <inttypes.h>
#includ... | (metric, amount, analytics_uuid_for_client(client)) | ;
}
///////////////////
// Stopwatches
static bool prv_is_stopwatch_for_metric(ListNode *found_node, void *data) {
AnalyticsStopwatchNode* stopwatch_node = (AnalyticsStopwatchNode*)found_node;
return stopwatch_node->metric == (AnalyticsMetric)data;
}
AnalyticsStopwatchNode *prv_find_stopwatch(AnalyticsMetric metri... |
th_is_sharing_heart_rate_for_stored_remote(remote) ?
i18n_get("Sharing Heart Rate ❤", data) : NULL);
PBL_IF_RECT_ELSE(prv_draw_stored_remote_item_rect,
prv_draw_stored_remote_item_round)(ctx, cell_layer, remote_name,
connected_string, le... | draw_stored_remote_item(ctx, cell_layer, device_index, data) | ;
}
}
static void prv_select_click_cb(SettingsCallbacks *context, uint16_t row) {
SettingsBluetoothData *data = (SettingsBluetoothData *) context;
if (row == 0) {
settings_bluetooth_toggle_airplane_mode(data);
return;
}
if (!data->remote_list_head) {
return;
}
prv_reload_remote_list(data);
... |
(), 1);
cl_assert_equal_b(ppogatt_has_client_for_uuid(&s_meta_v0_system.app_uuid), true);
cl_assert_equal_i(fake_comm_session_close_call_count(), 0);
}
void test_ppogatt__ack_received_data(void) {
test_ppogatt__open_session_when_found_pebble_app();
// Receive data:
for (uint8_t i = 0; i < PPOGATT_SN_MOD_DIV... | {
cl_assert_equal_b(fake_comm_session_send_buffer_write_raw_by_transport(transport,
s_short_data_fragment,
sizeof(s_short_data_fragment)), true);
ppogatt_send_next(transport);
prv_assert... | |
RTC_TimeTypeDef rtc_time_before;
RTC_GetTime(RTC_Format_BIN, &rtc_time_before);
RTC_GetDate(RTC_Format_BIN, &rtc_date);
// See reference manual section 26.6.11 for SSR to milliseconds conversion
sub_seconds = RTC_GetSubSecond();
// Make sure neither date nor time rolled over since we read them.
... | prv_get_time_milliseconds_since_epoch() | ;
}
RtcTicks rtc_alarm_get_elapsed_ticks(void) {
uint64_t now = prv_get_time_milliseconds_since_epoch();
PBL_ASSERTN(now >= s_alarm_set_time_milliseconds_since_epoch);
uint64_t milliseconds_elapsed = now - s_alarm_set_time_milliseconds_since_epoch;
return (milliseconds_elapsed * RTC_TICKS_HZ) / 1000;
}
bool r... |
/*
* 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 false;
} |
LegacyFwUpdateCompletionStatus *status = &s_current_completion_status.legacy_status;
switch (event->object_type) {
case ObjectFirmware:
status->firmware_percent_completion = event->progress_percent;
break;
case ObjectSysResources:
status->resource_percent_completion = event->progress_pe... |
bitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw3_no_clip.${BIT_DEPTH_NAME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_XY, ORIGIN_RECT_CLIP_XY, false, 3);
graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_CLIP_XY);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_rect_origin_sw3_clip_xy.${BIT_DEPTH_NAME}.pb... | (&ctx, &OFFSET_DRAW_RECT_CLIP_NXNY) | |
ces/common/i18n/i18n.h"
#include <stdio.h>
typedef struct HealthActivityDetailCard {
int32_t daily_avg;
int32_t weekly_max;
int16_t num_headings;
HealthDetailHeading headings[MAX_NUM_HEADINGS];
int16_t num_subtitles;
HealthDetailSubtitle subtitles[MAX_NUM_SUBTITLES];
int16_t num_zones;
HealthDetail... | PBL_IF_COLOR_ELSE(GColorBlack, GColorWhite) | ,
.num_zones = card_data->num_zones,
.zones = card_data->zones,
.data = card_data,
};
return (Window *)health_detail_card_create(&config);
}
void health_activity_detail_card_destroy(Window *window) {
HealthDetailCard *card = (HealthDetailCard *)window;
HealthActivityDetailCardData *card_data = car... |
/*
* 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... | {
fake_app_timer_deinit();
// some tests deinitialize the engine, avoid double de-init
if (app_state_get_rocky_runtime_context() != NULL) {
jerry_cleanup();
rocky_runtime_context_deinit();
}
gbitmap_destroy(s_pixels);
s_pixels = NULL;
free(s_framebuffer);
} |
static const RockyGlobalAPI *s_graphics_api[] = {
&GRAPHIC_APIS,
NULL,
};
jerry_value_t prv_create_canvas_context_2d_for_layer(Layer *layer);
static const jerry_value_t prv_global_init_and_set_ctx(void) {
rocky_global_init(s_graphics_api);
// make this easily testable by putting it int JS context as global... |
er *node, void *ctx) {
if (node) {
if (node->property_changed_proc) {
node->property_changed_proc(node);
}
}
return true;
}
static bool layer_process_tree_level(Layer *node, void *ctx, LayerIteratorFunc iterator_func) {
while (node) {
if (!iterator_func(node, ctx)) {
return false;
}... | node->update_proc(node, ctx) | ;
}
// if client has forgotten to release frame buffer
if (ctx->lock) {
graphics_release_frame_buffer(ctx, &ctx->dest_bitmap);
APP_LOG(APP_LOG_LEVEL_WARNING,
"Frame buffer was not released. "
"Make sure to call graphics_release_frame_buffer before leaving updat... |
irk) {
// are we looking for a bonding which did not exchange an irk?
if (sm_is_pairing_info_irk_not_used(&intent->bonding->irk)) {
PBL_LOG(LOG_LEVEL_DEBUG, "Bonding does not have irk ... comparing identity address");
return (0 == memcmp(&connection->device.opaque, &intent->bonding->device.o... | prv_has_intents_for_disconnected_devices() | ) {
prv_start_connecting();
}
}
// -------------------------------------------------------------------------------------------------
//! Adds or removes a device to/from the Bluetooth controller's whitelist.
//! Stops and (re)starts the LE Create Connection operation as necessary.
static void prv_mutate_whitelis... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.