prefix
stringlengths
0
918k
middle
stringlengths
0
812k
suffix
stringlengths
0
962k
dls_out, BLEDescriptor *descriptor_hdls_out) { } void launcher_task_add_callback(void (*callback)(void *data), void *data) { callback(data); } // FIXME: PBL-23945 void fake_kernel_malloc_mark(void) { } void fake_kernel_malloc_mark_assert_equal(void) { } // Helpers //////////////////////////////////////////////...
fake_gatt_put_discovery_indication_gatt_profile_service(TEST_GATT_CONNECTION_ID, true /* has_service_changed_characteristic */)
reate sample data for testing sleep and data logging static void prv_create_test_data(uint32_t num_minutes, AlgMinuteDLSSample *minute_data) { uint16_t next_vmc = 0; uint8_t next_orient = 1; uint8_t next_light = 2; uint16_t next_active_calories = 3; uint16_t next_resting_calories = 4; uint16_t next_distance...
activity_algorithm_init(&s_sample_rate)
; } // --------------------------------------------------------------------------------------- void test_activity_algorithm_kraepelin__cleanup(void) { fake_system_task_callbacks_invoke_pending(); activity_algorithm_deinit(); } // ----------------------------------------------------------------------------------...
w_all_day_events) { if (direction == TimelineIterDirectionPast) { return prv_find_first_past(head, timestamp, today_midnight, show_all_day_events); } else { return prv_find_first_future(head, timestamp, today_midnight, show_all_day_events); } } static void prv_remove_node(TimelineNode **head, TimelineNod...
{ *list_head = (TimelineNode *)list_sorted_add((ListNode *)*list_head, (ListNode *)nodes[i], prv_time_comparator, true); }
} static bool prv_each(SettingsFile *file, SettingsRecordInfo *info, void *context) { // check entry is valid if (info->key_len != UUID_SIZE || info->val_len == 0) { return true; // continue iteration } TimelineNode **list_head = context; CommonTimelineItemHeader header; // we don't care about the a...
typedef enum UpdateFirmwareResult { UPDATE_FW_SUCCESS = 0, UPDATE_FW_ERROR_MICRO_FLASH_UNTOUCHED = 1, UPDATE_FW_ERROR_MICRO_FLASH_MANGLED = 2 } UpdateFirmwareResult; static UpdateFirmwareResult update_fw(uint32_t flash_address) { display_firmware_update_progress(0, 1); boot_bit_set(BOOT_BIT_NEW_FW_UPDATE_IN...
("Failed to load recovery firmware, strike two. Try again.")
; boot_bit_set(BOOT_BIT_RECOVERY_LOAD_FAIL_STRIKE_TWO); boot_bit_set(BOOT_BIT_SOFTWARE_FAILURE_OCCURRED); system_reset(); } else { dbgserial_putstr("Failed to load recovery firmware, strike three. SAD WATCH"); boot_bit_clear(BOOT_BIT_FW_START_FAIL_STRIKE_ONE); boot_bit_clear(BOOT...
32, 0x8e, 0x0f, 0xbb, 0xc6, 0x42, 0x1a, 0xa6, 0x69, 0x9b, 0xda, 0xda, // Discovery Generation 0x00, // RSVD 0x00, // Size Bytes 0x51, 0x00, // Att Handle EMULATED_PPOGATT_SERVICE_HANDLE_LSB, EMULATED_PPOGATT_SERVICE_HANDLE_MSB, // Num characteristics 0x02, // Num Descriptors 0x01, // RSVD 0x...
(state->pending_response_data)
; } const uint32_t alloc_size = sizeof(HcGattWriteRespData); state->pending_data_size = alloc_size; HcGattWriteRespData *data = kernel_zalloc_check(alloc_size); *data = (HcGattWriteRespData) { .status = BLEGATTErrorSuccess, .hdr.addr = hdr->addr, .att_handle = att_hdl, .context_ref = ((HcGattR...
/* * 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 (non_equal_count >= 2) { success = true; break; } } previous_value = *rand_out; }
RNG->CR &= ~RNG_CR_RNGEN; periph_config_disable(RNG, RCC_AHB2Periph_RNG); periph_config_release_lock(); return success; }
){ "Unhandled Error", " "ERROR_STRING, NULL }; prv_do_eval("throw new Error('"ERROR_STRING"');"); cl_assert(*s_log_internal__expected == NULL); } void test_rocky_api_util__create_date_now(void) { const time_t cur_time = 1458250851; // Thu Mar 17 21:40:51 2016 UTC ...
(getDate, now, NULL, 0)
; jerry_value_t result_month = jerry_call_function(getMonth, now, NULL, 0); jerry_value_t result_year = jerry_call_function(getYear, now, NULL, 0); cl_assert_equal_d(jerry_get_number_value(result_seconds), 28.0); cl_assert_equal_d(jerry_get_number_value(result_minutes), 38.0); cl_assert_equal_d(jerry_get_num...
0x90, 0xa4, 0x91, 0x3f, 0x1f, 0xa6, 0x76, 0x01}, .app_version = { .major = 1, .minor = 1, }, .sdk_version = { .major = 1, .minor = 1, }, .info_flags = 0, .icon_resource_id = 0, }; static const AppDBEntry app3 = { .name = "Application 3", .uuid = {0x7c, 0x65, 0x2e, 0xb9, 0x26, ...
(true, uuid_equal(&app3.uuid, &temp.uuid))
3); graphics_draw_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP); cl_check(gbitmap_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...
(&ctx, fb, OFFSET_RECT_CLIP_NXNY, OFFSET_RECT_CLIP_NXNY, true, 1)
ces/normal/blob_db/app_db.h" #include "util/build_id.h" #include "util/time/time.h" #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include "fixtures/load_test_resources.h" // Stub Includes //////////////////////////////////// #include "stubs_analytics.h" #include "stubs_app_manager.h" #include "stu...
if (!exists) { return false; }
return app_install_entry_has_worker(&entry); } bool app_install_is_hidden(AppInstallId id) { AppInstallEntry entry; bool exists = app_install_get_entry_for_install_id(id, &entry); if (!exists) { return false; } return app_install_entry_is_hidden(&entry); } bool app_install_entries_equal(AppInstallEnt...
ept 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 License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KI...
{ shift_factor[j] += s_samples[i][j]; }
shift_factor[j] /= N_SAMPS; } int16_t raw_data[N_SAMPS][N_AXIS]; for (int i = 0; i < N_SAMPS; i++) { for (int j = 0; j < 3; j++) { raw_data[i][j] = (s_samples[i][j] - shift_factor[j]); // TODO: stop here if we have a chance of overflowing } } int32_t r[N_SAMPS]; for (int i = 0; i ...
GRect(20, 110, 70, 20)
); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "fill_rect_transparent.8bit.pbi")); } void test_graphics_fill_rect_${BIT_DEPTH_NAME}__origin_radius(void) { GContext ctx; test_graphics_context_init(&ctx, fb); // AA = true, SW has no effect, all corners setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT...
{ cl_assert(is_app_file_name("@12345678.foo") == false); }
void test_app_file__is_app_file_name_tricky_false_8(void) { cl_assert(is_app_file_name("@123456780bar") == false); } // Tests for app_file_get_app_id() void test_app_file__get_app_id_simple(void) { cl_assert_equal_i(app_file_get_app_id("@00000001/abc"), 1); } void test_app_file__get_app_id_invalid_1(void) { ...
; PageHeader pg_hdr; memset(&pg_hdr, 0xff, sizeof(pg_hdr)); bool use_gc_allocator = (strcmp(f->name, GC_FILE_NAME) == 0); if ((rv = find_free_page(&start_page, use_gc_allocator, true)) != S_SUCCESS) { return (rv); } pg_hdr.version = PFS_CUR_VERSION; SET_PAGE_FLAGS(pg_hdr.page_flags, PAGE_FLA...
{ return (E_RANGE); }
} f->curr_page = next_page; } *pg_offset = data_offset % free_bytes_in_page(f->curr_page); return (S_SUCCESS); } static int mark_fd_free(int fd) { if (PFS_FD(fd).file.name != NULL) { kernel_free(PFS_FD(fd).file.name); PFS_FD(fd).file.name = NULL; } if (PFS_FD(fd).file.pg_cache != NULL) { ...
/* * 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...
accel_service_private_get_session(task)
; PBL_ASSERTN(state->double_tap_handler != NULL); // only kernel clients can subscribe to double tap right now, so just increment double tap count // device analytic here analytics_inc(ANALYTICS_DEVICE_METRIC_ACCEL_DOUBLE_TAP_COUNT, AnalyticsClient_System); state->double_tap_handler(e->accel_tap.axis, e->acce...
(&s_stopped_handler_calls, seq)
, 1); cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, c), 1); cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, c), 1); cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, c), 1); cl_assert_equal_i(prv_count_handler_entries(&s_teardown_handler_calls, c)...
" \t\n"); if (!token) { continue; } // If this is a pre-processor directive, skip it if (token[0] == '#') { continue; } // If this is a comment skip it if (strcmp(token, "//") == 0) { continue; } // If this is an AlgDlsMinuteData line, get the name if (strcm...
(token + strlen(token) + 1, "%d", &state->test_entry.force_shut_down_at)
; } else if (strcmp(token, "TEST_WEIGHT") == 0) { sscanf(token + strlen(token) + 1, "%f", &state->test_entry.weight); } else if (strcmp(token, "TEST_NAME") == 0) { sscanf(token + strlen(token) + 1, "%s", state->test_entry.name); } } // If this is a "static AlgDlsMinuteData sa...
include "stubs_task_watchdog.h" static PebbleProcessMd __pbl_app_info; const PebbleProcessMd* sys_process_manager_get_current_process_md(void) { return &__pbl_app_info; } // Tests //////////////////////////////////// #define TEST_UUID_A { 0x2F, 0xF7, 0xFA, 0x04, 0x60, 0x11, 0x4A, 0x98, 0x8A, 0x3B, 0xA8, 0x26, 0xA4...
persist_get_size(key)
, sizeof(bool)); cl_assert_equal_i(persist_read_bool(key), true); } void test_persist__data(void) { const uint32_t key = 0; const int size = sizeof(test_uuid_a); Uuid uuid_buffer; cl_assert_equal_i(persist_read_data(key, &uuid_buffer, sizeof(uuid_buffer)), E_DOES_NOT_EXIST); cl_assert_equal_i(persist_writ...
RIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, true, 11); graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 3); // TODO: Fix offset calculation and reenable this: - PBL-16509 #if SCREEN_COLOR_DEPTH_BITS == 8 cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r3_aa_sw11_no_clip.${BIT_DEPTH_NAME}.p...
(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 1)
; cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect_origin_r1_sw11_no_clip.${BIT_DEPTH_NAME}.pbi")); setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_NO_CLIP, ORIGIN_RECT_NO_CLIP, false, 11); graphics_draw_round_rect(&ctx, &ORIGIN_DRAW_RECT_NO_CLIP, 2); cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_round_rect...
n (next_state == TimelineAppStateCard || next_state == TimelineAppStatePopCard); case TimelineAppStateCard: return (next_state == TimelineAppStatePopCard || next_state == TimelineAppStateStationary); case TimelineAppStatePopCard: return (next_state == TimelineAppStateStat...
grect_align(&icon_frame, &data->peek_layer.layer.frame, GAlignCenter, false)
; const TimelineAppStyle *style = prv_get_style(); icon_frame.origin.y += style->peek_icon_offset_y; } if (shift_offscreen) { if (data->timeline_model.direction == TimelineIterDirectionPast) { icon_frame.origin.y -= DISP_ROWS; } else { icon_frame.origin.y += DISP_ROWS; } } *icon_...
E_Connection_Complete_Event_Data = &event_data, }; if (is_master) { prv_fake_gap_le_create_connection_event_put(&event); } else { prv_fake_gap_le_adv_connection_event_put(&event); } } void fake_gap_put_disconnection_event(uint8_t status, uint8_t reason, bool is_ma...
{ s_encrypted_device = BTDeviceAddressToBDADDR(device->address); }
int GAP_LE_Regenerate_Long_Term_Key(unsigned int BluetoothStackID, Encryption_Key_t *DHK, Encryption_Key_t *ER, Word_t EDIV, Random_Number_t *Rand, Long_Term_Key_t *LTK_Result) { return 0; } int GAP_LE_Register_Remote_Authentication(unsigned i...
) ? LayoutIdNotification : LayoutIdReminder; NotificationLayoutInfo layout_info = (NotificationLayoutInfo) { .item = item, .show_notification_timestamp = !prv_should_pop_due_to_inactivity() }; const LayoutLayerConfig config = { .frame = &data->window.layer.bounds, .attributes = &item->attr_list, ...
{ // This functionality only exists for popups (modal windows) which currently all // run on Kernel Main launcher_task_add_callback(prv_clear_stale_reminders, data); }
static void prv_setup_reminder_watchdog(NotificationWindowData *data) { if (!data->is_modal || regular_timer_is_scheduled(&data->reminder_watchdog_timer_id) || !do_not_disturb_is_active()) { return; } data->reminder_watchdog_timer_id = (const RegularTimerInfo) { .cb = prv_clear_stale_reminders_ti...
xb8, 0xd1, 0x87, 0xd0, 0xbd, 0xd0, 0xbe, 0x00, 0xd0, 0xa1, 0xd0, 0xba, 0xd0, 0xbe, 0xd1, 0x80, 0xd0, 0xbe, 0x20, 0xd0, 0xb1, 0xd1, 0x83, 0xd0, 0xb4, 0xd1, }; void test_timeline_item__get_serialized_attributes_length(void) { const uint8_t *cursor = s_serialized_attribute_list; int32_t result = attribute_get_buf...
(memcmp(buffer, s_payload_complete, sizeof(s_payload_complete)) == 0)
/* * 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_WARNING, "Reboot reason is already set")
; } return; } RTC_WriteBackupRegister(REBOOT_REASON_REGISTER_1, raw[0]); RTC_WriteBackupRegister(REBOOT_REASON_REGISTER_2, raw[1]); RTC_WriteBackupRegister(REBOOT_REASON_STUCK_TASK_PC, raw[2]); RTC_WriteBackupRegister(REBOOT_REASON_STUCK_TASK_LR, raw[3]); RTC_WriteBackupRegister(REBOOT_REASON_STUCK...
RE_FUNCTION; s_ctx.draw_state.tint_color = EXPECTED_TINT_COLOR_BEFORE_AND_AFTER_PRE_FUNCTION; PreAndPostFunctionsTestProcessor processor = (PreAndPostFunctionsTestProcessor) { .processor.pre = prv_pre_and_post_functions__pre, .processor.post = prv_pre_and_post_functions__post, }; graphics_draw_bitmap_i...
{ PostFunctionCalledEvenIfPreFunctionCausesNothingToBeDrawnTestProcessor *processor_with_data = (PostFunctionCalledEvenIfPreFunctionCausesNothingToBeDrawnTestProcessor *)processor; // Change the bitmap to use to NULL to cause nothing to be drawn *bitmap_to_use = NULL; // We'll expect the bitmap we set the...
void test_gbitmap_processor__post_function_called_even_if_pre_function_specifies_null_bitmap(void) { prv_post_function_called_even_if_pre_function_causes_nothing_to_be_drawn_test( post_function_called_even_if_pre_function_specifies_null_bitmap__pre); }; static void post_function_called_even_if_pre_function_spe...
cl_assert(pfs_write(fd, bigbuf, large_file_size) == large_file_size); cl_assert(pfs_close(fd) == S_SUCCESS); } free(bigbuf); // now read back the large files curr = 0; for (int i = 0; i < 2; i++) { snprintf(file_large, sizeof(file_large), "large%d", i); int fd = pfs_open(file_large, OP_FLAG_READ...
for (int i = (files_written - 1); i >= 0; i--) { char name[128]; snprintf(name, sizeof(name), "file%d", i); cl_assert_equal_i(pfs_remove(name), S_SUCCESS); }
} } void test_pfs__active_in_region(void) { cl_assert(pfs_active_in_region(0, pfs_get_size())); } void test_pfs__get_size(void) { cl_assert(pfs_get_size() == (ftl_get_size() - SECTOR_SIZE_BYTES)); } void test_pfs__migration(void) { // reset the flash fake_spi_flash_cleanup(); fake_spi_flash_init(0, 0x10...
bs_hexdump.h" #include "stubs_passert.h" // Fakes /////////////////////////////////////////////////////////// static TimerID s_debounce_timer; static bool s_default_connection_state; static unsigned int s_event_count = 0; static PebbleEvent s_cached_event; static Transport *s_transport; static CommSession *s_session...
{ //! Currently connected init(true /* connected */); check_connected(); //! Get disconnected event prv_send_connection_event(false); check_waiting_to_send_disconnect(); // No event put cl_assert_equal_i(s_event_count, 0); //! Get connected event before timer fires prv_send_connection_event(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...
(window, true)
; layer_set_update_proc((Layer *) window, prv_test_update_proc); app_window_stack_push(window, false); } static uint16_t prv_get_num_rows(struct MenuLayer *menu_layer, uint16_t section, void *callback_context) { return (uint16_t) ARRAY_LENGTH(s_tests); } static void prv_draw_row...
e); } static bool prv_is_in_list(AppInstallId id, const AppInstallId list[], uint8_t len) { for (unsigned int i = 0; i < len; i++) { if (list[i] == id) { return true; } } return false; } ////////////////////// // Settings Helpers ////////////////////// //! Settings iterator function that finds th...
(&file, prv_each_free_up_space, &evict_data)
ble_out); cl_assert(gcolor_equal(lookup_table_out[0], GColorBlack)); cl_assert(gcolor_equal(lookup_table_out[1], GColorDarkGray)); cl_assert(gcolor_equal(lookup_table_out[2], GColorLightGray)); cl_assert(gcolor_equal(lookup_table_out[3], GColorWhite)); // Setting the tint color to blue should result in a gra...
{ for (GColor8Component j = 1; j <= max_component_value; j++) { cl_assert_equal_i(gcolor_component_multiply(i, j), gcolor_component_multiply(j, i)); } }
//////// // Fakes / Stubs #include "stubs_bt_lock.h" #include "stubs_logging.h" #include "stubs_passert.h" static bool s_last_driver_allow_cycling; BTDeviceAddress s_last_driver_addr; bool s_last_driver_addr_is_null; void bt_driver_set_local_address(bool allow_cycling, const BTDeviceA...
prv_assert_driver_addr_is_addr2()
ging.h" #include "stubs_mutex.h" #include "stubs_passert.h" #include "stubs_pbl_malloc.h" #include "stubs_pebble_tasks.h" #include "stubs_print.h" #include "stubs_prompt.h" #include "stubs_serial.h" #include "stubs_sleep.h" #include "stubs_task_watchdog.h" #define PFS_SECTOR_SIZE 4096 // a - 4K file full of 1's stati...
pfs_close(fd)
, S_SUCCESS); } // the file system is full, lets delete a file snprintf(file_name, sizeof(file_name), "file%d", num / 2); fd = pfs_open(file_name, OP_FLAG_READ, 0, 0); cl_assert(fd >= 0); uint16_t target_start_page = test_get_file_start_page(fd); pfs_close_and_remove(fd); // lets force garbage collect...
indow_stack_remove(data->continent_window, continent_animated); const bool region_animated = true; app_window_stack_remove(&option_menu->window, region_animated); } static void prv_region_menu_push(SettingsTimeData *data) { const char *title = prv_get_timezone_title(); const OptionMenuCallbacks callbacks = { ...
{ SettingsTimeData *data = (SettingsTimeData*) context; i18n_free_all(data); app_free(data->continent_names); app_free(data->region_names); app_free(data->region_names_buffer); app_free(data); }
static Window *prv_init(void) { SettingsTimeData *data = app_malloc_check(sizeof(*data)); *data = (SettingsTimeData){}; data->callbacks = (SettingsCallbacks) { .deinit = prv_deinit_cb, .draw_row = prv_draw_row_cb, .select_click = prv_select_click_cb, .num_rows = prv_num_rows_cb, .selection_...
ELATIVE_HRS); cl_assert_equal_s("Fri, 12:00 PM", time_buf); // June 11th 2015, 23:59:59 (T-12:00:01) rtc_set_time(event_time - (12 * SECONDS_PER_HOUR) - 1); clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS); cl_assert_equal_s("Fri, 12:00 PM", time_buf); // June 12t...
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS)
; cl_assert_equal_s("1 MIN AGO", time_buf); // June 9th 2015, 12:05:00 (T+00:05:00) rtc_set_time(event_time + (5 * SECONDS_PER_MINUTE)); clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_HRS); cl_assert_equal_s("5 MIN AGO", time_buf); // June 9th 2015, 12:10:00 (T+00:10...
/* * 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...
progress_callback(sector - first_sector + 1, count, progress_context)
/* * 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...
app_window_stack_push(window, false)
; } static uint16_t prv_get_num_rows(struct MenuLayer *menu_layer, uint16_t section, void *callback_context) { return (uint16_t) ARRAY_LENGTH(s_tests); } static void prv_draw_row(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *callback_c...
60, 120, -360}, { 1072, 112, -376}, { 1472, 64, -432}, { 1584, 24, -424}, { 1080, -56, -504}, { 648, -16, -432}, { 832, -24, -328}, { 1256, -112, -272}, { 1224, -208, -280}, { 984, -200, -360}, { 912, -72, -448}, { 848, -88, -408}, { 976, -168, -344}, { 1040, -344, -3...
{ 952, -160, -192}, { 880, -48, -208}, { 1192, -64, -200}, { 1464, -128, -72}, { 1288, -136, 32}, { 1256, -184, 8}, { 1232, -192, 16}, { 1152, -184, 32}, { 1088, -192, 24}, { 992, -144, 48}, // 13 seconds { 856, -144, 0}, { 832, -152, -32}, { 856, -152, -48}, ...
{ 1008, -72, -136}, { 1040, -64, -120}, { 1120, -72, -72}, { 1480, -64, -96}, { 1320, -32, -104}, { 1136, 56, -104}, { 936, 48, -72}, { 1112, 160, -120}, { 1288, 72, -16}, { 1344, 144, 48}, { 1240, 40, 120}, { 1264, 144, 48}, { 1152, 56, -24}, { 1320, 416, -296},...
prev_button_state = button_get_state_bits() & ~SELECT_BUTTON_MASK; while (1) { // See if we should restart uint8_t button_state = button_get_state_bits() & ~SELECT_BUTTON_MASK; if (button_state != prev_button_state) { system_reset(); } delay_ms(10); } } static void prv_print_reset_reason...
(0xd15ea5e5)
timestamps(); } /************************************* *************************************/ static void prv_menu_layer_reload_data(void *data) { cl_assert_equal_p(data, &menu_layer); menu_layer_reload_data(&menu_layer); } void test_app_menu_data_source__pass_init(void) { app_menu_data_source_init(&data_sou...
("lnc_ord", OP_FLAG_WRITE, FILE_TYPE_STATIC, file_len)
; pfs_write(fd, &entries_to_write, sizeof(entries_to_write)); pfs_write(fd, order, sizeof(AppInstallId) * num_entries); AppInstallId zero_id = 0; pfs_write(fd, &zero_id, sizeof(zero_id)); pfs_close(fd); } void prv_test_new_order_with_filter_callback(const AppInstallId order[], uint8_t num_entries, ...
/* * 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...
serial_distance(a, b, 32)
; } int32_t serial_distance(uint32_t a, uint32_t b, int bits) { // See https://en.wikipedia.org/wiki/Serial_Number_Arithmetic const int64_t a_minus_b = a - b; const int64_t b_minus_a = b - a; const bool a_is_earlier_than_b = (a < b && b_minus_a < (1 << (bits - 1))) || (a > b && a_minus_b > (1 << (bits - 1))); ...
ernet connection", data); #endif break; case AppFetchResultIncompatibleJSFailure: // TODO: PBL-39752 make this a more expressive error message with a call to action icon = TIMELINE_RESOURCE_GENERIC_WARNING; message = i18n_get("Incompatible JS", data); break; case AppFetchResultGene...
(BUTTON_ID_BACK, (ClickHandler) prv_click_handler)
; window_single_click_subscribe(BUTTON_ID_UP, (ClickHandler) prv_click_handler); window_single_click_subscribe(BUTTON_ID_SELECT, (ClickHandler) prv_click_handler); window_single_click_subscribe(BUTTON_ID_BACK, (ClickHandler) prv_click_handler); } static void handle_init(void) { AppFetchUIData* data = app_zallo...
#if PBL_COLOR ASSERT_CALLED(graphics_internal_circle_quadrant_fill_aa(&context, GPoint(50, 50), 10, GCornersAll)); #else ASSERT_CALLED(graphics_circle_fill_non_aa(&context, GPoint(50, 50), 10)); #endif setup_test(&context, true, 5, GColorBlack, GColorBlack, false); graphics_fill_round_rect(&context, &GRect(20...
graphics_fill_circle(&context, GPoint(50, 50), 10)
r triples of quadrants cl_assert_equal_edc(prv_calc_draw_config_ellipsis(TO_TRIG(0), TO_TRIG(270)), ((EllipsisDrawConfig){ .start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(0),GCornerTopRight}, .full_quadrants = (GCornersBottom | GCornerTopRight), .end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(270),GCo...
prv_calc_draw_config_ellipsis(TO_TRIG(45 - 360), TO_TRIG(270 + 45 - 360))
, ((EllipsisDrawConfig){ .start_quadrant = (EllipsisPartDrawConfig){TO_TRIG(45),GCornerTopRight}, .full_quadrants = GCornersBottom, .end_quadrant = (EllipsisPartDrawConfig){TO_TRIG(270 + 45),GCornerTopLeft} })); // Ending quadrant filling up and starting quadrant finishing cl_assert_equal_edc(prv_cal...
+ sizeof(PebbleBLEGATTClientServiceEventInfo); PebbleBLEGATTClientServiceEventInfo *info = kernel_zalloc_check(space_needed); *info = (PebbleBLEGATTClientServiceEventInfo) { .type = PebbleServicesAdded, .device = connection->device, .status = status }; info->services_added_data.num_service...
{ return; // nothing to do }
if ((new_job->hdl.start == MIN_ATT_HANDLE) && (new_job->hdl.end == MAX_ATT_HANDLE)) { // we are rediscovering all services so flush everything prv_free_service_nodes(connection); prv_send_services_invalidate_all_event( connection, BTErrnoServiceDiscoveryDatabaseChanged); } else { // we are red...
// The last median should be stored and accessable via the LastStableBPM metric activity_get_metric(ActivityMetricHeartRateFilteredBPM, 1, &last_median); activity_get_metric(ActivityMetricHeartRateFilteredUpdatedTimeUTC, 1, &last_update_utc); cl_assert_equal_i(last_median, 51); cl_assert(last_update_utc >= ...
(metric_values[1], 2222)
; cl_assert_equal_i(metric_values[2], 0000); cl_assert_equal_i(metric_values[3], 0000); cl_assert_equal_i(metric_values[4], 0000); cl_assert_equal_i(metric_values[5], 0000); cl_assert_equal_i(metric_values[6], 3333); // Set the current value to something larger activity_metrics_prv_set_metric(ActivityMet...
lteredUpdatedTimeUTC, 1, (int32_t *)&health_data->hr_last_updated); } void health_data_update(HealthData *health_data) { const time_t now = rtc_get_time(); struct tm local_tm; localtime_r(&now, &local_tm); //! Step / activity related data // Get the step totals for today and the past ...
(HealthMetricHeartRateRawBPM)
; health_data->hr_last_updated = current_hr_timestamp; } } void health_data_update_hr_zone_minutes(HealthData *health_data) { activity_get_metric(ActivityMetricHeartRateZone1Minutes, 1, &health_data->hr_zone1_minutes); activity_get_metric(ActivityMetricHeartRateZone2Minutes, 1, &health_data->hr_zone2_minutes...
/* * 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...
{ char testbuf[9] = "hi"; cl_assert_equal_i(strlen(testbuf), 2); }
void test_strlen__weird(void) { char testbuf[9] = "hi\0five"; cl_assert_equal_i(strlen(testbuf), 2); }
(s_perftest_text_arguments.font_key, "RESOURCE_ID_GOTHIC_24_BOLD")
== 0) { font_index = TestStringFont_Gothic24B; } else { font_index = TestStringFont_Other; } #if TEXT_PERFTEST_MODAL // Length replaces the yoffset argument size_t length = atoi(s_perftest_text_arguments.y_offset); if (length == 0) { length = STRING_LENGTH_MAX; } #else size_t length = s_perf...
pairing_data crc // This tests that when setting a value, all fields in the struct must be valid. void test_shared_prf_storage_v3__handle_currupt_field_during_setting(void) { bool GETTING_STARTED_COMPLETE = true; shared_prf_storage_set_getting_started_complete(GETTING_STARTED_COMPLETE); cl_assert_equal_i(shared_p...
shared_prf_storage_get_valid_page_number()
, 1); shared_prf_storage_set_getting_started_complete(true); cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 1); shared_prf_storage_set_getting_started_complete(false); cl_assert_equal_i(shared_prf_storage_get_valid_page_number(), 2); }
; shared_prf_storage_store_ble_pairing_data(&PAIRING_INFO, DEVICE_NAME, true /* requires_address_pinning */, 0xff /* flags */); shared_prf_storage_set_getting_started_complete(GETTING_STARTED_COMPLETE); shared_prf_storage_set_local_device_name(DEVICE_NAME); char dev...
shared_prf_storage_get_valid_page_number()
), sizeof(data)); cl_assert_equal_i(data.getting_started.crc, new_crc); // Should be corrupt, so it should return false cl_assert_equal_b(shared_prf_storage_get_getting_started_complete(), false); // Should have moved to the next page cl_assert_equal_b(shared_prf_storage_get_valid_page_num...
/* * 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...
grect_clip(&ctx->draw_state.clip_box, &window->layer.frame)
; StatusBarLayerConfig config = { .foreground_color = GColorWhite, .background_color = GColorBlack, .mode = StatusBarLayerModeClock, }; GRect frame = window->layer.frame; // window.frame.origin.y is 0 already (for 2.x compatibility reasons) // see prv_adjust_drawing_state_fo...
guage governing permissions and * limitations under the License. */ #include "gdrawmask_demo.h" #include "applib/app.h" #include "applib/app_light.h" #include "process_state/app_state/app_state.h" #include "applib/fonts/fonts.h" #include "applib/ui/app_window_stack.h" #include "applib/ui/ui.h" #include "kernel/pbl_...
graphics_context_set_fill_color(ctx, GColorRed)
; graphics_fill_rect(ctx, &layer_bounds); graphics_context_mask_destroy(ctx, mask); } static void prv_refresh_timer_callback(void *context) { GDrawMaskDemoData *data = context; layer_mark_dirty(window_get_root_layer(&data->window)); app_timer_register(ANIMATION_TARGET_FRAME_INTERVAL_MS, prv_refresh_timer_ca...
turn true; } static bool prv_set_s_timeline_peek_enabled(bool *enabled) { s_timeline_peek_enabled = *enabled; timeline_peek_set_enabled(*enabled); return true; } static bool prv_set_s_timeline_peek_before_time_m(uint16_t *before_time_m) { s_timeline_peek_before_time_m = *before_time_m; timeline_peek_set_sho...
if (settings_file_get_len(&file, entry->key, key_len) == entry->value_len) { settings_file_get(&file, entry->key, key_len, entry->value, entry->value_len); }
ly initialized data list->serialized_byte_length = 3; list->data[0] = 'a'; list->data[1] = '\0'; list->data[2] = 'b'; // end of data list->data[3] = 'c'; list->data[4] = '\0'; cl_assert_equal_i(2, string_list_count(list)); cl_assert_equal_s("a", string_list_get_at(list, 0)); cl_assert_equal_s("bc", st...
cl_assert_equal_p(timeline_item_find_reply_action(NULL), NULL)
; // Make sure we can handle timeline items with no actions TimelineItem item = {}; cl_assert_equal_p(timeline_item_find_reply_action(&item), NULL); // Copy the action list since it's easiest to just modify it TimelineItemAction *action_list = malloc(sizeof(s_basic_action_list)); memcpy(action_list, s_bas...
fb; size_t framebuffer_get_size_bytes(FrameBuffer *f) { return FRAMEBUFFER_SIZE_BYTES; } /////////////////////////////////////////////////////////// // Tests void test_word_iterator__initialize(void) { framebuffer_init(&s_fb, &(GSize) {DISP_COLS, DISP_ROWS}); graphics_context_init(&s_ctx, &s_fb, GContextInitia...
cl_assert(*word_iter_state.current.start == 'o')
; cl_assert(*word_iter_state.current.end == '\0'); cl_assert(!iter_next(&word_iter)); } void test_word_iterator__test_string_terminating_newlines(void) { // Allocate mutable types Iterator word_iter = (Iterator) { 0 }; WordIterState word_iter_state = (WordIterState) { 0 }; // Allocate immutable types b...
= 1 << 1, ToStringFormatSecondNumeric = 1 << 2, ToStringFormatSecond2Digit = 1 << 3, ToStringFormatMinuteNumeric = 1 << 4, ToStringFormatMinute2Digit = 1 << 5, ToStringFormatHourNumeric = 1 << 6, ToStringFormatHour2Digit = 1 << 7, ToStringFormatLocaleDate = 1 << 8, ToStringFormatDayNumeric = 1 << 9, T...
if (rocky_str_equal(option_values[i].field, option_values[i].value)) { result = option_values[i].format; found_options++; }
if (found_options > 1) { // today, we don't support combinations of several options, it's either none or one return ToStringFormatUnsupported; } } return result; } static const char *prv_strftime_format(ToStringFormat format, bool is_24h_style) { switch (format) { case ToStringFormatUns...
olor color) { peek_layer->bg_color = color; } static bool prv_is_dot_size(GSize size) { return (size.w <= UNFOLD_DOT_SIZE_PX && size.h <= UNFOLD_DOT_SIZE_PX); } void peek_layer_set_icon_with_size(PeekLayer *peek_layer, const TimelineResourceInfo *timeline_res, TimelineResourceSi...
{ GRect icon_from = GRectZero; KinoReel *prev_reel = kino_layer_get_reel(&peek_layer->kino_layer); if (prev_reel) { icon_from = kino_reel_get_elapsed(prev_reel) ? kino_reel_transform_get_to_frame(prev_reel) : kino_reel_transform_get_from_frame(prev_reel); } ...
GPoint center_from = grect_center_point(&icon_from); GPoint center_to = grect_center_point(&icon_to); GPoint target = gpoint_add(gpoint_sub(center_to, center_from), GPoint(size.w / 2, size.h / 2)); const bool take_ownership = true; KinoReel *kino_reel = kino_reel_scale_segmented_create(from_reel, take_owner...
s_invoke_pending(); const uint8_t chunk[] = { 0xaa, 0xbb, 0xcc, 0xdd }; prv_receive_put(s_last_response_cookie, chunk, sizeof(chunk)); prv_process_and_reset_test_counters(); } static void prv_receive_init_put_and_commit_fw_object(void) { prv_receive_init_and_put_fw_object(); prv_receive_commit(s_last_respon...
{ put_bytes_cancel(); }
0}, { 1152, 32, 0}, { 1288, 24, -32}, { 1392, 152, -88}, // 37 seconds { 1528, 368, -48}, { 1448, 424, 64}, { 1256, 272, 80}, { 1064, 376, -40}, { 1768, 64, 144}, { 2016, -352, 432}, { 2216, -568, 304}, { 1872, -368, 312}, { 1384, -216, 192}, { 1176, -184, 96}, ...
{ 1104, -480, 128}, { 848, -512, 0}, { 720, -520, 0}, { 552, -592, -16}, { 520, -560, -64}, { 1016, -552, 48}, { 1456, -440, 48}, { 1904, -256, 112}, { 1992, -8, 240}, { 1544, 352, -96}, { 1304, 456, 120}, { 1248, 272, 40}, { 1472, 104, -16}, { 1496, 176, 16}, ...
{ 2024, 376, 496}, { 2368, 64, 328}, { 2240, 520, 376}, { 1680, 400, 416}, { 1280, 16, 344}, { 1144, -464, 168}, { 920, -456, 120}, { 880, -408, -8}, { 768, -408, 8}, { 688, -472, 0}, { 848, -472, -48}, { 800, -328, 0}, { 1200, -216, -48}, { 1584, -240, 48}, ...
/* * 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_display_prompt()
; } return should_context_switch; #endif }
", hours, minutes); return time_str; } // ============================================================================================= // Start of unit tests void test_kraepelin_algorithm__initialize(void) { } // --------------------------------------------------------------------------------------- void test_kr...
if (results->steps < entry->exp_steps_min || results->steps > entry->exp_steps_max) { status = "FAIL"; fail_count++; } else { status = "pass"; pass_count++; }
printf("\n%-40s %-10d %-10d %-10d %-10d %-10d %-10d %-10.2f %-10s", entry->name, entry->exp_steps, results->steps, error, entry->exp_steps_min, entry->exp_steps_max, results->ref_steps, weighted_error, status); } ...
); cl_assert_equal_i(mfg_info_get_disp_offsets().x, -2); cl_assert_equal_i(mfg_info_get_disp_offsets().y, 1); cl_assert_equal_i(mfg_info_get_watch_color(), 3); cl_assert_equal_i(mfg_info_get_rtc_freq(), 4); mfg_info_get_model(buffer); cl_assert_equal_s(buffer, ""); // Make sure we have space for...
((const uint8_t*) "xxxx", BOOT_FPGA_FLASH_ADDR + HEADER_SIZE, 4)
; // Make sure it's corrupted flash_read_bytes(fpga_buffer, BOOT_FPGA_FLASH_ADDR, sizeof(fpga_buffer)); cl_assert(memcmp(fpga_buffer + HEADER_SIZE, s_boot_fpga, sizeof(s_boot_fpga)) != 0); // Now update it and make sure we healed the corruption mfg_info_update_constant_data(); flash_read_bytes(fpga_buffe...
ope == HealthServiceTimeScopeOnce) && ((now_utc - time_start) <= HS_MAX_MINUTE_DATA_SEC); } } break; } WTF; } // ---------------------------------------------------------------------------------------------- // Return the daily historical values for the given metric, retrieving...
time_t seconds_today = now_utc - sys_time_start_of_today(); HealthValue per_day_default = (daily_totals.totals[0] * SECONDS_PER_DAY) / MAX(1, seconds_today); if (stats->weekday.sum == 0) { stats->weekday = (HealthServiceStats) { .sum = per_day_default, .avg = per_day_default, .min = per_...
use_stale(timestamp)) { return true; } return false; } void ancs_notifications_handle_message(uint32_t uid, ANCSProperty properties, ANCSAttribute **notif_attributes, ANCSAttribute **app_attrib...
{ prv_handle_new_ancs_notif(notification); }
notification_storage_unlock(); // if missed call, also add a pin if (is_notification_from_phone_app && has_missed_call_property) { TimelineItem *missed_call_pin = ancs_item_create_and_populate(notif_attributes, app_attributes, app_metadata, app_notif_prefs, tim...
Only call from interrupt functions static portBASE_TYPE end_transfer_irq(I2cBus *bus, bool result) { bus->i2c->CR2 &= ~(I2C_CR2_ITEVTEN | I2C_CR2_ITERREN | I2C_CR2_ITBUFEN); bus->i2c->CR1 |= I2C_CR1_STOP; bus->transfer.result = result; bus->transfer.state = TRANSFER_STATE_INVALID; bus->busy = false; retur...
end_transfer_irq(bus, false)
; break; } return should_context_switch; } //! Handle error interrupt on the specified \a bus static portBASE_TYPE irq_error_handler(I2cBus *bus) { if (bus->transfer.state == TRANSFER_STATE_INVALID) { // Disable interrupts if spurious interrupt received bus->i2c->CR2 &= ~I2C_CR2_ITERREN; retu...
/* * 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...
{ // The unit tests parse the //> TEST_.* lines below for test values //> TEST_NAME walk_200_pbl_25530_7 //> TEST_EXPECTED 200 //> TEST_EXPECTED_MIN 165 //> TEST_EXPECTED_MAX 230 //> TEST_WEIGHT 1.0 static AccelRawData samples[] = { // 0 seconds // elapsed: 0 minutes { 24, 16, -1032}, { 32...
{ 472, 576, -408}, { 584, 672, -416}, { 936, 920, -424}, { 832, 696, -216}, { 840, 520, -168}, { 824, 928, -440}, { 752, 784, -208}, { 744, 688, -192}, { 712, 744, -136}, { 672, 816, -176}, { 696, 744, -160}, { 664, 608, -160}, { 640, 536, -72}, { 648, 624, -64},...
(dev->do_swap_rx_tx ? USART_CR2_SWAP : 0); dev->periph->CR3 = (dev->half_duplex ? USART_CR3_HDSEL : 0); dev->periph->CR1 = cr1_extra_flags | USART_CR1_UE; dev->state->initialized = true; // initialize the DMA request if (dev->rx_dma) { dma_request_init(dev->rx_dma); } } void uart_init(UARTDevice *de...
{ // disable the interrupt NVIC_DisableIRQ(dev->irq_channel); }
ring_widths[] = {36, 0, 24, 28, 32}; static void prv_draw_heart_node_callback(GContext *ctx, const GRect *box, const GTextNodeDrawConfig *config, bool render, GSize *size_out, void *user_data); static void prv_draw_hr_measuring_node_cal...
( metric_type, active_window->workout_data)
points(void) { const uint16_t radius = 5; GPoint result; const GPoint origin_center = GPointZero; // 90 degrees should be (5, 0) result = gpoint_from_polar_internal(&origin_center, radius, (TRIG_MAX_ANGLE / 4)); cl_assert_equal_gpoint(result, GPoint(5, 0)); // 270 (90 * 3) degrees should be (-5, 0) res...
cl_assert_equal_grect(GRect(5, 5, 0, 0), grect_centered_internal(&p2, GSize(0, 0)))
*session) { } // Helpers //////////////////////////////////////////////////////////////////////////////////////////////////// typedef struct { SessionSendQueueJob job; size_t consumed_length; size_t length; uint8_t data[]; } TestSendJob; static size_t prv_get_length(const TestSendJob *sb) { return (sb->l...
(data_out, 0, sizeof(data_out))
= 0; graphics_context_set_stroke_color(&context, color); cl_assert_equal_i(context.draw_state.stroke_color.argb, GColorClear.argb); // Stroke Color - 2-bit graphics_context_set_stroke_color_2bit(&context, GColor2Black); cl_assert(gcolor_equal(context.draw_state.stroke_color, GColorBlack)); // Fill Color ...
GPoint(50, 50)
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 "timeline_item_layer.h" #include "applib/graphics/graphics.h" #include "applib/ui/action_menu_window.h" #include "applib/ui/wi...
property_animation_init(item_layer->animation, &implementation, item_layer, NULL, &new_offset)
; } else { item_layer->animation = property_animation_create(&implementation, item_layer, NULL, &new_offset); PBL_ASSERTN(item_layer->animation); animation_set_auto_destroy(property_animation_get_animation(item_layer->animation), false); } Animation *animation = property_animation_get_animatio...
tate); switch (simple_state) { case StateWaitForReady: if (event->type == VoiceEventTypeSessionSetup) { prv_handle_ready_event(data, event); } break; case StateWaitForResponse: if (event->type == VoiceEventTypeSessionResult) { prv_handle_dictation_result(data, event); ...
animation_set_duration((Animation *) anim, duration)
; animation_set_curve((Animation *) anim, AnimationCurveEaseInOut); return anim; } static const PropertyAnimationImplementation s_animated_dot_impl = { .base = { .update = (AnimationUpdateImplementation) property_animation_update_int16, }, .accessors = { .setter = { .int16 = prv_set_d...
ytics.h" #include "stubs_hexdump.h" #include "stubs_logging.h" #include "stubs_mutex.h" #include "stubs_passert.h" #include "stubs_prompt.h" #include "stubs_regular_timer.h" #include "stubs_sleep.h" #include "stubs_task_watchdog.h" extern TimerID get_reminder_timer_id(void); static TimelineItem item1 = { .header = ...
fake_system_task_callbacks_invoke(1); cl_assert_equal_i(num_events_put, 3); cl_assert_equal_m(&item3.header.id, stub_new_timer_callback_data(get_reminder_timer_id()), sizeof(TimelineItemId)); cl_assert(stub_new_timer_timeout(get_reminder_timer_id()) == 200 * 1000); now += 200; stub_pebble_tasks_set_current...
void test_reminders__first_init_test(void) { cl_assert_equal_i(reminders_init(), 0); test_reminders__timer_test(); } static TimelineItem s_stale_reminder = { .header = { .id = {0x3C, 0xAF, 0x17, 0xD5, 0xBE, 0x15, 0x4B, 0xFD, 0xAE, 0x2A, 0xAE, 0x44, 0xC0, 0x96, 0xCB, 0x7D}, .timestamp = 60 * 60, ...
return false; } // First, we need to compute the absolute start time of this animation, backing it up by the // delay and any repeats we have already done uint32_t start_ms = parent->abs_start_time_ms; start_ms -= parent->times_played * (parent->duration_ms + parent->delay_ms); // Loop through animation ...
(PebbleTask_Current)
cycles => 90 - 6 sync cycles = 84 cycles to play with // minimum low = ceil(1300ns / (1 / 36MHz)) = 47 cycles // minimum high = ceil(600ns / (1 / 36MHz)) = 22 cycles // extra cycles = 15 => (7 low, 8 high) => SCLL of 54 and SCLH of 30 // // SCLDEL = ceil((t_r 0 + t_SU 100ns) / (1 / 36MHz)) = 4 cycles prv_c...
cl_assert_equal_i(i2c_timingr_calculate(MHZ_TO_HZ(36), I2CBusMode_Standard, KHZ_TO_HZ(400), 0, 0), I2C_TIMINGR_INVALID_VALUE)
/* * 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 (fw_base[FW_IDENTIFIER_OFFSET / sizeof(uint32_t)] != 0x4E65576F) { // NeWo return false; }
// TODO: Additional checks? return true; } static void prv_get_fw_reset_vector(void **reset_handler, void **initial_stack_pointer) { void** fw_vector_table; if (firmware_is_new_world(NULL)) { fw_vector_table = (void**) FIRMWARE_NEWWORLD_BASE; } else { fw_vector_table...
urn; } // Cancel any outstanding timer. prv_stop_timer(outbox); outbox->transmission_size_limit = 0; applib_free(outbox->app_outbox_message); outbox->app_outbox_message = NULL; // Finish by moving to the next phase. outbox->phase = OUT_CLOSED; } static void prv_throttle(AppMessageCtxOutbox *outbox) ...
{ PBL_LOG(LOG_LEVEL_ERROR, "Can't call app_message_outbox_send() now, wait for sent_callback!"); return APP_MSG_BUSY; }
if (outbox->phase != OUT_WRITING) { return APP_MSG_INVALID_STATE; } const size_t transmission_size = dict_write_end(&outbox->iterator) + APP_MSG_HDR_OVRHD_SIZE; if (transmission_size > outbox->transmission_size_limit) { return APP_MSG_BUFFER_OVERFLOW; } uint8_t transaction_id = prv_get_next_trans...
/* * 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...
{ analytics_storage_take_lock(); // We don't currently allow incrementing signed integers, because the // only intended use of this API call is to increment counters, and counters // should always be unsigned. This restriction could be changed in the future, // however. PBL_ASSERTN(analytics_metric_is_unsi...
void analytics_add(AnalyticsMetric metric, int64_t amount, AnalyticsClient client) { analytics_add_for_uuid(metric, amount, analytics_uuid_for_client(client)); } /////////////////// // Stopwatches static bool prv_is_stopwatch_for_metric(ListNode *found_node, void *data) { AnalyticsStopwatchNode* stopwatch_node =...
if (uuid_is_system(&logging_session->app_uuid)) { PBL_LOG(LOG_LEVEL_WARNING, "Finishing the system data logging session at %p", logging_session); }
bool is_active = dls_lock_session(logging_session); if (!is_active) { PBL_LOG(LOG_LEVEL_WARNING, "Tried to close a non-active data logging session"); return; } // Wait for write buffer to empty int timeout = 1000; // 1 second while (logging_session->data->buffer_storage != NULL && timeout) { ...
/* * 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_prefs_24h_style = false; fake_rtc_init(0, 0); rtc_timezone_clear(); clock_init(); static const time_t jan1st_noon_2005 = 1104580800; clock_set_time(jan1st_noon_2005); cl_assert_equal_i(rtc_get_time(), jan1st_noon_2005); }
void test_clock__basic_timezone_gmtoffset(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 int...
) 0x1234); // Unschedule callback should not have been called: cl_assert_equal_i(s_unscheduled_cb_count, 0); } void test_gap_le_advert__deinit_unschedules(void) { BLEAdData *ad = create_ad(NULL, NULL); GAPLEAdvertisingJobTerm advert_term = { .min_interval_slots = 160, .max_interval_slots = 320, ....
gap_le_is_advertising_enabled()
, true); // make sure we can remove a few jobs with the same advertisement type tag = GAPLEAdvertisingJobTagReconnection; gap_le_advert_unschedule_job_types(&tag, 1); // should have 3 jobs unscheduled at this point and 1 still running cl_assert_equal_i(s_unscheduled_cb_count, 3); cl_assert_equal_b(gap_le_...
/* * 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 (!sb) { return false; }
comm_session_send_buffer_write(sb, data, length); comm_session_send_buffer_end_write(sb); return true; } CommSession * comm_session_open(Transport *transport, const TransportImplementation *implementation, TransportDestination destination) { ++s_session_open_call_count; Comm...
160, 264}, { 1008, 280, 144}, { 1040, 360, 168}, { 984, 360, 160}, { 904, 440, 8}, { 824, 360, 32}, { 904, 440, -136}, { 1192, 464, -224}, { 1320, 432, -160}, { 1784, 424, -152}, { 1816, 392, 24}, { 1112, 240, 32}, { 1304, 232, 152}, { 1424, 120, 168}, { 1264, 104...
{ 1912, 256, -16}, { 1424, 272, 64}, { 1208, 216, 88}, { 1416, 112, 152}, { 1312, -24, 216}, { 1104, 24, 224}, { 968, 16, 168}, { 816, -48, 144}, { 776, -40, 104}, { 872, 0, 128}, { 776, -56, 40}, { 888, -88, -8}, { 824, -120, -88}, { 1360, -264, 0}, { 1456, -...
(num_items > 3) { return; // we only support 3 simultaneous subscribers } int fastest_rate = 0; AccelRawData fake_buf[1]; for (int i = 0; i < num_items; i++) { if (fastest_rate < sample_arr[i]) { fastest_rate = sample_arr[i]; } sessions[i] = sys_accel_manager_data_subscribe( samp...
cl_assert_equal_i(s_num_samples, 22)
; stub_pebble_tasks_set_current(PebbleTask_KernelMain); sys_accel_manager_set_sample_buffer(main_session, fake_buf, 3); cl_assert_equal_i(s_num_samples, 7); /* 300ms / (1000ms / 25 samps) */ }
he emulated CCCD. } PBL_LOG(LOG_LEVEL_ALWAYS, "Phone & Watch have hit CCCD, initiate PPoGatt WA!"); hc_protocol_enqueue_with_payload(HcEndpointID_Gatt, HcMessageID_Gatt_WriteCompleted, (uint8_t *)state->pending_response_data, state->pending_da...
{ 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_...
static bool prv_handle_emulated_write(uint16_t conn_idx, const HcProtocolMessage *msg) { PBL_ASSERTN(msg->command_id == HcMessageID_Gatt_WriteNoResponse); // Remap a data write to a data notification HcGattWriteData *data = (HcGattWriteData *)&msg->payload[0]; ble_error_t e = ble_gatts_send_event( conn...
s_hidden(sports_id)); cl_assert_equal_b(false, app_install_is_hidden(bg_counter_id)); cl_assert_equal_b(false, app_install_is_hidden(menu_layer_id)); cl_assert_equal_b(false, app_install_is_hidden(CRAZY_ID)); } void test_app_install_manager__is_from_system(void) { cl_assert_equal_b(true, app_install_id_from_s...
cl_assert(false == app_install_entry_is_hidden(&entry))
; } // clear and ensure hidden app_install_unmark_prioritized(sports_id); cl_assert(true == app_install_entry_is_hidden(&entry)); // simulates multiple messages from app for (int i = 0; i < 10; i++) { // visible after communication app_install_mark_prioritized(sports_id, true /* can_expire */); ...
/ capitalization! i18n_noop("Every Day"); break; case ALARM_KIND_WEEKDAYS: alarm_day_text = all_caps ? /// A frequency option for alarms, i.e. the alarm would only go off every weekday. Respect /// capitalization! i18n_noop("WEEKDAYS") : ...
{ // Write the shortened day strings, remove last ',' alarm_day_text[strnlen(alarm_day_text, 28) - 1] = 0; }
} // ---------------------------------------------------------------------------------------------- void command_alarm(void) { prv_put_alarm_event(); }
/* * 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...
__disable_irq()
; s_interrupts_disabled_by_heap = true; } } static void prv_heap_unlock(void *ctx) { if (s_interrupts_disabled_by_heap) { __enable_irq(); s_interrupts_disabled_by_heap = false; } } void kernel_heap_init(void) { const bool fuzz_on_free = true; extern uint8_t __heap_start; uint8_t *heap_start =...
/* * 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...
DEFINE_SYSCALL(AppWorkerResult, sys_app_worker_launch, void)
{ AppInstallId install_id = app_manager_get_task_context()->install_id; // Make sure there is a worker for this app if (!app_manager_get_task_context()->app_md->has_worker) { return APP_WORKER_RESULT_NO_WORKER; } // Is there a worker already running? const PebbleProcessMd *md = worker_manager_get_cur...
if (sleep_exit_utc == -1 || exit_utc > sleep_exit_utc) { sleep_exit_utc = exit_utc; }
} total_seconds += activity_sessions[i].length_min * SECONDS_PER_MINUTE; } s_data.metric_history[ActivityMetricSleepEnterAtSeconds][0] = time_util_get_minute_of_day(sleep_enter_utc) * SECONDS_PER_MINUTE; s_data.metric_history[ActivityMetricSleepExitAtSeconds][0] = time_...
/* * 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...
(b->data[2], b4)
; free(b); } void test_buffer__can_read_and_write_uint32(void) { uint32_t expected = 0x12345678; Buffer *b = buffer_create(4); buffer_add(b, (const uint8_t* const)&expected, sizeof(expected)); cl_assert_equal_i(expected, *(uint32_t*)b->data); free(b); }
services) { if (PRIVILEGE_WAS_ELEVATED) { syscall_assert_userspace_buffer(services, sizeof(BLEService) * num_services); } return gatt_client_copy_service_refs(&device, services, num_services); } DEFINE_SYSCALL(uint16_t, sys_ble_client_get_maximum_value_length, BTDeviceInternal device) { return gap_le_conn...
(BTErrno, sys_ble_client_write_descriptor, BLEDescriptor descriptor, const uint8_t *value, size_t value_length)
{ return gatt_client_op_write_descriptor(descriptor, value, value_length, GAPLEClientApp); } DEFINE_SYSCALL(BTErrno, sys_ble_client_read_descriptor, BLEDescriptor descriptor) { return gatt_client_op_read_descriptor(descriptor, GAPLEClientApp); } // -----------------------...
-56, 432}, { 680, -224, 152}, { 1080, 824, -520}, { 2048, 3624, -2328}, { 720, 4000, -2352}, { -376, 2040, -1240}, { -616, 1024, -568}, { -744, 104, -112}, { -1376, -448, 192}, { -1480, -240, -96}, { -1184, 0, -168}, { -856, 872, -344}, { -1384, 3736, -1520}, { -8, 40...
{ 984, 280, 192}, { 1432, 152, -144}, { 1424, -176, 160}, { 1016, -144, 288}, { 984, -200, 24}, { 1600, 3720, -1224}, { 1184, 4000, -1632}, { -632, 3048, -1432}, { -752, 1608, -648}, { -768, 656, -288}, // 23 seconds { -608, -80, -48}, { -1048, -376, -8}, { -1144,...
/* * 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; }
// Offload to KernelBG, because we cannot use comm_session_send_data() with bt_lock held. system_task_add_callback(prv_send_ping_kernel_bg_cb, NULL); s_is_ping_kernel_bg_callback_scheduled = true; } static void prv_push_window(void *data) { SimpleDialog *s_dialog = simple_dialog_create("Ping"); Dialog *dia...
iance 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 License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either e...
{ spi_ll_slave_write(ICE40LP->spi_port, byte); }
// Set SCS high so that we don't process any of these clocks as commands. spi_ll_slave_scs_deassert(ICE40LP->spi_port); static const uint8_t spi_zeros[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; // 49+ SCLK cycles to tell FPGA we're done configuration. spi_ll_slave_burst_write(ICE40LP->spi_port, spi_zeros, ARRAY_LE...
4, -4); cl_assert_equal_s(dstbuf, "There are 4 lights, 4294967292"); // Alternate form snprintf(dstbuf, 256, "There are %#u lights, %#u", 4, -4); cl_assert_equal_s(dstbuf, "There are 4 lights, 4294967292"); // Zero padded minimum character output snprintf(dstbuf, 256, "There are %02u lights, %02u", 4, -4...
snprintf(dstbuf, 256, "%.0ozero%.0o", 0, 1)
; cl_assert_equal_s(dstbuf, "zero1"); // Minimum digits output (unspecified digits, acts as zero) snprintf(dstbuf, 256, "%.ozero%.o", 0, 1); cl_assert_equal_s(dstbuf, "zero1"); // Minimum digits output (negative digits, acts as zero) snprintf(dstbuf, 256, "%.-3ozero%.-3o", 0, 1); cl_assert_equal_s(dstbu...
8_t)x }; for (int dest_color_index = 0; dest_color_index < num_dest_colors; dest_color_index++) { for (int mask_value_index = 0; mask_value_index < num_mask_values; mask_value_index++) { int16_t y1 = (int16_t)((dest_color_index * vline_applying_test_row_height) + (mask_value_index * num_pixe...
(ctx, y, x1_fixed, x2_fixed, gradient_width, gradient_width, clip_box_min_x, clip_box_max_x, color)
; } void test_graphics_context_mask__record_assign_horizontal_line_delta_raw(void) { prv_mask_record_hline_test_pattern(prv_hline_pattern_record_assign_horizontal_line_delta_raw); CHECK_EXPECTED_TEST_IMAGE(s_ctx); }; ///////////////////////////////////// // RECORDING VERTICAL LINE TESTS // /////////////////////...
void) { Iterator iterator = {0}; TimelineIterState state = {0}; TimelineNode *head = NULL; // check first timeline_init(&head); cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture, 1421183640), 0); cl_assert(uuid_equal(&state.pin.header.id, &s_items[5].header.id)...
fake_pbl_malloc_num_net_allocs()
, 0); timeline_init(&head); cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionFuture, 1421178000), 0); cl_assert_equal_i(prv_num_items(iterator), 6); // Thursday Jan 16 00:00:00 PST 2015 // No items within window rtc_set_time(1421395200); head = NULL; timeline_init...
nfo *info, void *context) { // check entry is valid if (info->key_len != UUID_SIZE || info->val_len == 0) { return true; // continue iteration } TimelineNode **list_head = context; CommonTimelineItemHeader header; // we don't care about the attributes here, so we don't allocate space for them info->...
timeline_exists(&timeline_iter_state->node->id)