prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
ry_event = *event;
s_num_captured_history_events++;
}
}
// ---------------------------------------------------------------------------------------
// Test that we generate health events at the appropriate time
void test_activity__health_events(void) {
// Start activity tracking. This method assumes it can be ... | (&tz_info) | |
t.status,
e->app_outbox_sent.cb_ctx);
++s_num_app_outbox_events_sent;
return true;
}
void app_message_outbox_handle_app_outbox_message_sent(AppOutboxStatus status, void *cb_ctx) {
}
//////////////////////////////////////////////////////////////////////////////////////////////////... | cl_assert_equal_i(s_num_sent_handler_called, 0) | ;
}
app_outbox_send(s_test_data, s_test_data_length,
test_app_outbox_sent_handler, s_expected_cb_ctx);
assert_sent_cb_last_status(AppOutboxStatusOutOfResources);
}
void test_app_outbox__send_but_oom(void) {
prv_register();
fake_kernel_malloc_set_largest_free_block(0);
app_outbox_send(s_t... |
{ 136, 1928, 216},
{ -184, 1384, -40},
{ -344, 800, -152},
{ -632, 232, -144},
{ -656, -48, -168},
{ -480, -208, -24},
{ -392, 488, 96},
{ -376, 3304, 712},
{ 376, 2488, 920},
{ 368, 1536, 424},
{ 416, 824, 176},
{ 424, 216, 64},
{ 512, -208, 72},
{ 584, -488, 296},... | { -328, 824, 72},
{ -352, 208, 24},
{ -352, 136, -304},
{ -192, -24, -176},
{ -232, 240, 48},
// 24 seconds
{ -448, 1920, 432},
{ -112, 2624, 1032},
{ 296, 1896, 608},
{ 376, 1224, 224},
{ 336, 600, 32},
{ 440, -112, 40},
{ 552, -216, -16},
{ 416, -264, 248},
... | |
loc_check(ALARM_ENTRY_SIZE);
AppInstallEntry *entry = kernel_malloc_check(sizeof(AppInstallEntry));
if (!app_install_get_entry_for_install_id(APP_ID_ALARMS, entry)) {
goto cleanup;
}
int num_pin_adds = 0;
time_t alarm_time = prv_get_alarm_time(alarm, cron_job_get_execute_time(cron));
time_t last_alarm... | timeline_event_refresh() | ;
return alarm_found;
}
// ----------------------------------------------------------------------------------------------
static void prv_put_alarm_event(void) {
if (!s_alarms_enabled) {
return;
}
AlarmConfig *config = s_most_recent_alarm_id != ALARM_INVALID_ID ? &s_most_recent_alarm_config :
... |
// Receive volume of 0.604925
// 00 02 00 30 2e 41 30 34 39 32 35 ...0.A04 925
uint8_t volume_update[] = {
0x00, 0x02, 0x00, 0x30, 0x2e, 0x41, 0x30, 0x34,
0x39, 0x32, 0x35,
};
prv_receive_entity_update(volume_update, sizeof(volume_update));
cl_assert_equal_i(music_get_volume_percen... | {
s_launcher_task_callback = NULL;
memset(s_conn_mgr_states, 0, sizeof(s_conn_mgr_states));
fake_rtc_init(1234, 5678);
fake_event_init();
fake_gatt_client_subscriptions_init();
fake_gatt_client_op_init();
stub_pebble_tasks_set_current(PebbleTask_KernelMain);
ams_create();
cl_assert_equal_s(music_get_c... |
void test_ams__cleanup(void) {
ams_destroy();
fake_gatt_client_op_deinit();
fake_gatt_client_subscriptions_deinit();
}
|
ay_us(5);
s_flash_state.deep_sleep = true;
}
}
static void flash_deep_sleep_exit(void) {
assert_usable_state();
if (s_flash_state.deep_sleep) {
flash_start_cmd();
flash_send_and_receive_byte(FLASH_CMD_WAKE);
flash_end_cmd();
// wait a sufficient amount of time to enter standby mode
// I... | {
return;
} |
flash_lock();
s_flash_state.enabled = false;
flash_unlock();
}
void flash_read_bytes(uint8_t* buffer, uint32_t start_addr, uint32_t buffer_size) {
if (!buffer_size) {
return;
}
assert_usable_state();
flash_lock();
if (!s_flash_state.enabled) {
flash_unlock();
return;
}
analytics_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... | GSize(48, 48) | ,
.command_list = (GDrawCommandList) {
.num_commands = num_commands,
},
};
GDrawCommandList *list = &image->command_list;
GDrawCommand *c0 = gdraw_command_list_get_command(list, 0);
*c0 = (GDrawCommand){
.type = GDrawCommandTypePath,
.fill_color = GColorWhite,
.num_poin... |
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 "local_addr_impl.h"
#include "ble_task.h"
#inc... | if (!advert_execute_cb_if_adverts_are_paused(prv_try_set_own_address_cb, &update_info)) {
// Wait for local_addr_handle_disconnection() to happen.
s_local_addr_state = LocalAddressState_AwaitingAdvertisementsPaused;
return;
} |
if (!update_info.did_succeed_setting_own_address) {
// Wait for local_addr_handle_disconnection() to happen.
s_local_addr_state = LocalAddressState_AwaitingDisconnection;
return;
}
}
PBL_LOG(LOG_LEVEL_DEBUG, "Local address policy in sync!");
s_local_addr_state = LocalAddressState_InSy... |
rv_page_to_flash_offset(prev_written_page) +
offsetof(PageHeader, last_written));
}
hdr.last_written = LAST_WRITTEN_TAG;
prv_flash_write((uint8_t *)&hdr.last_written, sizeof(hdr.last_written),
prv_page_to_flash_offset(next_page) + offsetof(PageHeader, last_written));
}
//! The wear leveling strat... | garbage_collect_sector(&next_page, sector_start_pg, sectors_active) | ;
break;
}
}
}
if (next_page != INVALID_PAGE) { // a free page was found
if (use_page) {
prv_update_last_written_page(next_page);
}
*free_page = s_last_page_written = next_page;
return (S_SUCCESS);
}
return (E_OUT_OF_STORAGE);
}
//! Note: expects that the caller does ... |
--------------------------------------------------------------------------------
static void cl_assert_equal_point(const GPoint a, const GPoint b) {
cl_assert_equal_i(a.x, b.x);
cl_assert_equal_i(a.y, b.y);
}
// --------------------------------------------------------------------------------------
static void cl_... | animation_service_test_get_timer_id() | ;
if (!sys_timer_id) {
DPRINTF("timer not created\n");
prv_advance_by_ms_no_timers(dst_time - now);
return;
}
if (!stub_new_timer_is_scheduled(sys_timer_id)) {
DPRINTF("timer not scheduled\n");
prv_advance_by_ms_no_timers(dst_time - now);
return;
}
// Advance ti... |
tion because existing "
"time-based reminder was found in db");
return true;
}
// filter out super-old notifications
if (prv_should_ignore_because_stale(timestamp)) {
return true;
}
return false;
}
void ancs_notifications_handle_message(uint32_t uid,
... | (notification) | ;
notification_storage_unlock();
goto cleanup;
}
prv_handle_ancs_update(notification, &existing_header);
} else {
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... |
repare(&s_rx_buffer, &rx_buffer_ptr);
prv_unlock();
// OK to use the stack for these variables,
// because ad_spi_complex_transact blocks until transfer is completed:
SPITransportMsgStatus remote_status_in = {};
SPITransportMsgStatus local_status_out = {
.msg_id = SPITransportMsgID_Status,
.bytes_sen... | ("Host Transport Receive Buffer Full, exiting from rx'ing to process") | |
/*
* 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... | (d[i + 1]) | ;
}
}
uint32_t crc = legacy_defective_checksum_memory(buf, num_bytes);
prv_put_byte_hdlc((uint8_t) crc);
prv_put_byte_hdlc((uint8_t) (crc >> 8));
prv_put_byte_hdlc((uint8_t) (crc >> 16));
prv_put_byte_hdlc((uint8_t) (crc >> 24));
prv_put_hdlc_frame_delimiter();
}
if (s_timeout =... |
TIM_TimeBaseInit(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, &tim_config);
TIM_Cmd(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, DISABLE);
TIM_ClearITPendingBit(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, TIM_IT_Update);
TIM_ITConfig(BOARD_BT_WATCHDOG_TIMER.timer.peripheral, TIM_IT_Update, ENABLE);
}
static void prv... | {
PBL_LOG(LOG_LEVEL_ERROR, "CRC failed on remote SPI Receive 0x%08" PRIX32 " != 0x%08" PRIX32,
crc, s_spi_transport.rx_footer.crc);
prv_trigger_core_dump_from_isr();
} |
bool should_give_semaphore = false;
if (s_spi_transport.bytes_sendable_count) {
prv_watchdog_start();
s_spi_transport.state = SPITransportState_WaitingForSending;
} else {
// Nothing to send, we're done:
s_spi_transport.state = SPITransportState_Idle;
should_give_semaphore = true;
}
prv... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | cl_assert_ge(2, 1) | ;
cl_assert_ge(1, 1);
cl_assert_ne(1, 2);
}
void test_clar__test_assert_within(void) {
cl_assert_within(0, 0, 0);
cl_assert_within(1, 1, 1);
cl_assert_within(1, 1, 10);
cl_assert_within(5, 1, 10);
cl_assert_within(10, 1, 10);
cl_assert_within(-10, -10, 0);
cl_assert_within(-5, -10, 0);
cl_assert... |
/*
* 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_get_gpoint(), prv_get_gpoint()) | |
.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(ActivitySessionType_... | rtc_set_time(utc_sec) | ;
const time_t time_elapsed = (20 * SECONDS_PER_MINUTE);
// Add a run session
ActivitySession run_activity = {
.start_utc = utc_sec - time_elapsed,
.length_min = time_elapsed,
.type = ActivitySessionType_Run,
.ongoing = true,
};
activity_sessions_prv_add_activity_session(&run_activity);
/... |
/*
* 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... | periph_config_acquire_lock() | |
{
prv_apply_patch_to_struct(data, size, offset, false);
} |
// Does the flash write / erase on the current task
static void prv_update_and_cleanup_struct(void *data, size_t size, size_t offset) {
prv_apply_patch_to_struct(data, size, offset, true);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Custom Local Device ... | |
tributeIdAppName, .cstring = "Awesome" },
{ .id = AttributeIdLastUpdated, .uint32 = s_now },
}
};
s_expected_attributes = &expected_attributes;
ancs_filtering_record_app(&existing_prefs, s_app_id_attr, s_display_name_attr, s_title_attr);
cl_assert(s_performed_store);
// Make sure the our existing ... | ancs_filtering_is_muted(&mute_weekends) | );
cl_assert(!ancs_filtering_is_muted(&mute_weekdays));
s_now += SECONDS_PER_DAY; // Monday Jan 4, 2016
cl_assert(ancs_filtering_is_muted(&mute_always));
cl_assert(!ancs_filtering_is_muted(&mute_weekends));
cl_assert(ancs_filtering_is_muted(&mute_weekdays));
}
void test_ancs_filtering__record_app_no_display... |
equal_i(elapsed_ms, -delay);
cl_assert_passert(animation_get_progress(h, &progress));
animation_set_elapsed(h, 0);
cl_must_pass(animation_get_elapsed(h, &elapsed_ms));
cl_assert_equal_i(elapsed_ms, 0);
cl_must_pass(animation_get_progress(h, &progress));
cl_assert_equal_i(progress, 0);
animation_set_elapse... | (seq, &position) | |
static bool prv_reset_fpga(void) {
const uint32_t length = sle_decode(s_fpga_bitstream, sizeof(s_fpga_bitstream),
s_decoded_fpga_image, sizeof(s_decoded_fpga_image));
return display_program(s_decoded_fpga_image, length);
}
static bool prv_wait_busy(void) {
// The display shou... | prv_wait_busy() | |
/*
* 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... | (vector, buf) | ;
}
// Tests for app_file_name_make()
static void assert_app_file_name_make(AppInstallId app_id, const char *suffix) {
char buf[42];
memset(buf, 'X', sizeof(buf));
buf[41] = '\0';
app_file_name_make(buf, sizeof(buf), app_id, suffix, strlen(suffix));
assert_file_name(buf, app_id, suffix);
}
void test_app_fi... |
te == SessionState_VoiceEndpointSetupReceived ||
s_state == SessionState_AudioEndpointSetupReceived) {
prv_cancel_recording();
} else if (s_state == SessionState_Recording) {
prv_stop_recording();
}
}
prv_reset();
unlock:
mutex_unlock(s_lock);
}
// This will trigger an event to be se... | {
prv_cancel_recording();
} |
VoiceEventType event_type = (s_state <= SessionState_StartSession) ?
VoiceEventTypeSessionSetup : VoiceEventTypeSessionResult;
prv_send_event(event_type, VoiceStatusErrorGeneric, NULL);
return false;
}
if (s_session_id != session_id) {
PBL_LOG(LOG_LEVEL_WARNING, "Received session result fo... |
/*
* 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... | RTC_ReadBackupRegister(RTC_TIMEZONE_ABBR_START) | ;
raw[1] = RTC_ReadBackupRegister(RTC_TIMEZONE_ABBR_END_TZID_DSTID);
raw[2] = RTC_ReadBackupRegister(RTC_TIMEZONE_GMTOFFSET);
raw[3] = RTC_ReadBackupRegister(RTC_TIMEZONE_DST_START);
raw[4] = RTC_ReadBackupRegister(RTC_TIMEZONE_DST_END);
}
void rtc_timezone_clear(void) {
RTC_WriteBackupRegister(RTC_TIMEZONE_... |
/*
* 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_get_user_data((Window*) anim_ctx->window) | ;
if (!data || !finished) {
// We could have gotten cleaned up in the middle of an animation, bail
applib_free(anim_ctx);
return;
}
if (data->view_model.cur_level->parent_level == anim_ctx->next_level) {
--data->view_model.num_dots;
} else {
++data->view_model.num_dots;
}
data->view_mod... |
model_name = TINTIN_MODEL("pebble_blue");
break;
case WATCH_INFO_COLOR_GREEN:
model_name = TINTIN_MODEL("pebble_green");
break;
case WATCH_INFO_COLOR_PINK:
model_name = TINTIN_MODEL("pebble_pink");
break;
case WATCH_INFO_COLOR_TIME_WHITE:
model_name... | {
suffix_str = "";
} | |
ntZero, GCompOpSet, GColorWhite);
cl_assert(gbitmap_pbi_eq(&dest_bitmap, "test_bitblt__8bit_set-expect.8bit.pbi"));
gbitmap_destroy(src_bitmap);
}
// Test GCompOpTint, from same size to size.
// Setup:
// - Source is a 10x10 square, white.
// - Destination is either a black or white square.
// Result:
// - ... | memset(src_data, color.argb, sizeof(src_data)) | |
non-repeating integer that we also use as our key for finding
//! EventedTimers by id.
TimerID sys_timer_id;
EventedTimerCallback callback;
void* callback_data;
PebbleTask target_task;
bool expired; // This gets set when the timer's callback runs
bool repeating;
} EventedTimer;
// Fakes
//////////... | (!s_times_callback_executed) | ;
}
void test_evented_timer__cancel_during_app_event(void) {
EventedTimerID timer = evented_timer_register(100, false, stub_evented_timer_callback, 0);
// We've started the timer, but it hasn't fired yet.
TimerID sys_timer_id = timer;
cl_assert(stub_new_timer_is_scheduled(sys_timer_id));
cl_assert_equal_i(s... |
_top_window;
Window *app_window_stack_get_top_window() {
return &s_app_window_stack_get_top_window;
}
GContext s_context;
// mocks
static MockCallRecordings s_graphics_context_set_fill_color;
void graphics_context_set_fill_color(GContext* ctx, GColor color) {
record_mock_call(s_graphics_context_set_fill_color) {
... | cl_assert_parsed_color("#123456789", NULL) | ;
// different lengths
cl_assert_parsed_color("#f00", &GColorRed);
cl_assert_parsed_color("#FF0000", &GColorRed);
cl_assert_parsed_color("#F00f", &GColorRed);
cl_assert_parsed_color("#FF0000FF", &GColorRed);
// discard rgb components if alpha == 0
cl_assert_parsed_color("#12345600", &GColorClear);
cl_... |
tionHandlers handlers,
void *context) {
AnimationState *state = prv_animation_state_get(PebbleTask_Current);
if (animation_private_using_legacy_2(state)) {
// We need to enable other applib modules like scroll_layer, menu_layer, etc. which are
// compiled to use the 3.0 animation... | {
// We need to enable other applib modules like scroll_layer, menu_layer, etc. which are
// compiled to use the 3.0 animation API to work with 2.0 apps.
animation_legacy2_set_delay((AnimationLegacy2 *)animation_h, delay_ms);
return true;
} |
AnimationPrivate *animation = prv_find_animation_by_handle(state, animation_h, false /*quiet*/);
if (!prv_is_mutable(state, animation)) {
return false;
}
animation->delay_ms = delay_ms;
return true;
}
// -------------------------------------------------------------------------------------------
uint3... |
hDetailHeading) {
.primary_label = "LABEL1",
.primary_value = "value1",
.secondary_label = "LABEL2",
.secondary_value = "value2",
.fill_color = GColorWhite,
#if PBL_BW
.outline_color = GColorBlack,
#endif
},
.num_subtitles = 1,
.subtitles = &(HealthDetailSubtitle) {
... | {
HealthDetailCardConfig config = {
.num_headings = 1,
.headings = &(HealthDetailHeading) {
.primary_label = "LABEL1",
.primary_value = "value1",
.fill_color = GColorWhite,
#if PBL_BW
.outline_color = GColorBlack,
#endif
},
.bg_color = BG_COLOR,
.daily_avg = 900,
.weekl... | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | kino_player_play(test_player) | |
static TimelineItem item1 = {
.header = {
.id = {0x6b, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0xb4},
.parent_id = {0xff, 0xf6, 0x21, 0x5b, 0xc9, 0x7f, 0x40, 0x9e,
0x8c, 0x31, 0x4f, 0x55, 0x65, 0x72, 0x22, 0x01},
.timestamp = 1,
.d... | (!is_dirty) | ;
dirty_list = pin_db_get_dirty_list();
cl_assert(!dirty_list);
}
void test_pin_db__set_status_bits(void) {
pin_db_insert_item(&item1);
TimelineItem item;
cl_must_pass(pin_db_read_item_header(&item, &item1.header.id));
cl_assert_equal_i(item.header.status, 0);
cl_must_pass(pin_db_set_status_bits(&item1... |
/*
* 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 (nf->callbacks.selected != NULL) {
nf->callbacks.selected(nf, nf->callback_context);
} | |
ither express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bmi160.h"
#include "bmi160_private.h"
#include "drivers/accel.h"
#include "bmi160_regs.h"
#include "drivers/exti.h"
#include "drivers/rtc.h"
#include "system/passert.h"
#inc... | {
s_accel_power_mode = BMI160_Accel_Mode_Suspend;
s_gyro_power_mode = BMI160_Gyro_Mode_Suspend;
} |
}
static Bmi160Scale prv_get_accel_scale(void) {
uint8_t scale_reg_val = bmi160_read_reg(BMI160_REG_ACC_RANGE) & 0xf;
if (scale_reg_val == BMI160_ACC_RANGE_2G) {
return BMI160_SCALE_2G;
} else if (scale_reg_val == BMI160_ACC_RANGE_4G) {
return BMI160_SCALE_4G;
} else if (scale_reg_val == BMI160_ACC_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... | (prefs_len) | |
EST:
text_layer_set_text(msg_text_layer, "Addr Bus Test");
break;
case FLASH_TEST_CASE_RUN_STRESS_ADDR_TEST:
text_layer_set_text(msg_text_layer, "Stress Addr Test");
break;
case FLASH_TEST_CASE_RUN_PERF_DATA_TEST:
text_layer_set_text(msg_text_layer, "Perf Data Test");
break;
... | {
PBL_LOG(LOG_LEVEL_DEBUG, ">>>>>FAILED TEST CASE<<<<<");
data->test_case_status = FLASH_TEST_STATUS_FAILED;
} | |
/*
* 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... | kernel_applib_get_compass_config() | ;
} else {
WTF;
}
if (*config == NULL) {
// Note that config will never be NULL after grabbing it from an app,
// worker, or kernel state. However, the value pointed to it may be
// NULL.
*config = task_zalloc_check(sizeof(CompassServiceConfig));
}
return config;
}
static void prv_do_d... |
6},
{ 0, 0x6e, 0, 195},
{ 0, 0x6e, 0, 194},
{ 0, 0x6e, 0, 192},
// 450: Local time: 09:02:00 AM
{ 0, 0x6e, 0, 200},
{ 0, 0x6e, 0, 201},
{ 0, 0x6e, 0, 202},
{ 0, 0x6e, 0, 201},
{ 0, 0x6e, 0, 195},
{ 0, 0x6e, 0, 197},
{ 0, 0x6e, 0, 195},
{ 0, 0x6e, 0, 195},
{ 0, 0x6e, 0... | { 0, 0x6e, 0, 200},
{ 0, 0x6e, 0, 196},
{ 0, 0x6e, 0, 196},
{ 0, 0x6e, 0, 197},
{ 0, 0x6e, 0, 206},
{ 0, 0x6e, 0, 199},
{ 0, 0x6e, 0, 204},
{ 0, 0x6e, 0, 206},
{ 0, 0x6e, 0, 205},
{ 0, 0x6e, 0, 205},
{ 0, 0x6e, 0, 205},
{ 0, 0x6e, 0, 205},
{ 0, 0x6e, 0, 205},
{ 0,... |
{ 0, 0x6e, 0, 202},
{ 0, 0x6e, 0, 202},
{ 0, 0x6e, 0, 202},
{ 0, 0x6e, 0, 198},
{ 0, 0x6e, 0, 204},
{ 0, 0x6e, 0, 197},
{ 0, 0x6e, 0, 196},
{ 0, 0x6e, 0, 195},
{ 0, 0x6e, 0, 202},
{ 0, 0x6e, 0, 194},
{ 0, 0x6e, 0, 193},
{ 0, 0x6e, 0, 202},
{ 0, 0x6e, 0, 202},
{ 0... |
ng the app frame buffer to the
// system frame buffer and the time spent sending the system frame buffer to the display.
__profiler_stop();
__profiler_print_stats();
int64_t time_rendered = prv_time_64() - data->time_started;
APP_LOG(APP_LOG_LEVEL_INFO, "## %d frames rendered", (int)data->rendered_frames);
... | bitmap_layer_create(GRect(0, 0, navbar_width, navbar_width)) | ;
bitmap_layer_set_background_color(data->topleft_layer, GColorWhite);
bitmap_layer_set_bitmap(data->topleft_layer, &s_fps_topleft_bitmap);
layer_add_child(root_layer, (Layer *)data->topleft_layer);
const GRect menu_layer_rect =
GRect(navbar_width, 0, full_rect.size.w - navbar_width, full_rect.size.h);
... |
en) + 1, "%d", &state->test_entry.end_at.min);
} else if (strcmp(token, "TEST_END_AT_MAX") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.end_at.max);
} else if (strcmp(token, "TEST_CUR_STATE_ELAPSED") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.c... | {
// EOF
break;
} |
// printf("\nGot line: %s", line);
// Find first token
char *token = strtok(line, " \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) ... |
COBS_OVERHEAD(PULSE_MAX_SEND_SIZE) | + LINK_HEADER_LEN) {
buf_valid = true;
}
PBL_ASSERT(buf_valid, "Buffer is not from the PULSE transmit buffer pool");
}
void pulse_handle_character(char c, bool *should_context_switch) {
// TODO: discard a frame outright if a framing error occurs
if (s_current_receive_buffer == NULL) {
s_current_receiv... | |
rrors & USART_ISR_ORE) != 0,
.framing_error = (errors & USART_ISR_FE) != 0,
.noise_detected = (errors & USART_ISR_NE) != 0,
};
return flags;
}
bool uart_is_rx_ready(UARTDevice *dev) {
return dev->periph->ISR & USART_ISR_RXNE;
}
bool uart_has_rx_overrun(UARTDevice *dev) {
return dev->periph->ISR & USA... | {
should_context_switch = true;
} |
}
portEND_SWITCHING_ISR(should_context_switch);
}
void uart_clear_all_interrupt_flags(UARTDevice *dev) {
dev->periph->RQR |= USART_RQR_RXFRQ;
dev->periph->ICR |= USART_ICR_ORECF;
}
// DMA
////////////////////////////////////////////////////////////////////////////////
void uart_start_rx_dma(UARTDevice *dev... |
{
return NULL;
} |
return bitmap->addr;
}
void gbitmap_set_data(GBitmap *bitmap, uint8_t *data, GBitmapFormat format,
uint16_t row_size_bytes, bool free_on_destroy) {
if (bitmap) {
bitmap->addr = data;
bitmap->info.format = format;
bitmap->row_size_bytes = row_size_bytes;
bitmap->info.is_bitmap... | |
onding();
cl_assert(ret);
}
void test_bluetooth_persistent_storage__test_is_faithful(void) {
bool ret;
// No pairing yet, we should be unfaithful
ret = bt_persistent_storage_is_unfaithful();
cl_assert(ret);
// Add a pairing, still unfaithful
BTDeviceAddress addr_1 = {{0x11, 0x12, 0x13, 0x14, 0x15, 0x16... | (0, &keys_out[0]) | ;
bt_persistent_storage_get_root_key(1, &keys_out[1]);
cl_assert_equal_m(&keys[0], &keys_out[0], sizeof(SM128BitKey));
cl_assert_equal_m(&keys[1], &keys_out[1], sizeof(SM128BitKey));
}
void test_bluetooth_persistent_storage__delete_all(void) {
bool ret;
// Add some pairings
// BT Classic pairing 1
BTDe... |
RRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "protobuf_log.h"
#include "protobuf_log_private.h"
#include "protobuf_log_util.h"
#include "applib/data_logging.h"
#include "drivers/rtc.... | version_get_major_minor_patch(&v_major, &v_minor, &version_patch_ptr) | ;
// Sender Id
const char *watch_serial = mfg_get_serial_number();
pebble_pipeline_Payload payload = {
.sender = {
.type = {
.funcs.encode = protobuf_log_util_encode_string,
.arg = (void *)PLOG_PAYLOAD_SENDER_TYPE,
},
.id = {
.funcs.encode = protobuf_log_util_encode... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (timer_duration,
prv_pulsing_heart_timer_cb,
base_layer) | ;
}
layer_mark_dirty(base_layer);
}
static void prv_render_progress_bar(GContext *ctx, Layer *base_layer) {
HealthHrSummaryCardData *data = layer_get_data(base_layer);
health_progress_bar_fill(ctx, &data->progress_bar, PROGRESS_BACKGROUND_COLOR,
0, HEALTH_PROGRESS_BAR_MAX_VALUE);
}... |
ol wait_for_busy_clear(uint8_t bus_idx) {
unsigned int attempts = I2C_TIMEOUT_ATTEMPTS_MAX;
while((i2c_buses[bus_idx].i2c->SR2 & I2C_SR2_BUSY) != 0) {
--attempts;
if (!attempts) {
return false;
}
}
return true;
}
//! Abort the transfer
//! Should only be called when the bus is locked
static ... | // which would cause the next transfer to fail
if (!wait_for_busy_clear(bus_idx)) {
// Reset I2C bus if busy flag does not clear
bus_reset(bus_idx);
}
bus_unlock(bus);
return result;
} |
bool i2c_read_register(I2cDevice device_id, uint8_t i2c_device_address, uint8_t register_address, uint8_t *result) {
return i2c_read_register_block(device_id, i2c_device_address, register_address, 1, result);
}
bool i2c_read_register_block(I2cDevice device_id, uint8_t i2c_device_address, uint8_t
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
TapRecognizerData *data = recognizer_get_impl_data((Recognizer *)recognizer,
&s_tap_recognizer_impl);
(void)data;
} |
static bool prv_cancel(Recognizer *recognizer) {
prv_reset(recognizer);
return false;
}
Recognizer *tap_recognizer_create(RecognizerEventCb event_cb, void *user_data) {
TapRecognizerData data = {
.config = {
.taps_required = 1,
.fingers_required = 1,
},
};
return recognizer_create_with... |
////
// Peek Layer
/////////////////////
static void prv_peek_anim_stopped(Animation *animation, bool finished, void *context) {
NotificationWindowData *data = context;
data->first_notif_loaded = true;
peek_layer_destroy(data->peek_layer);
data->peek_layer = NULL;
TimelineItem *item = prv_get_current_notifica... | modal_window_push(&data->window, NOTIFICATION_PRIORITY, true /* animated */) | ;
}
return;
}
// get the current layout so we can get the color and icon
LayoutLayer *layout = swap_layer_get_current_layout(&data->swap_layer);
if (!layout) {
return;
}
// Get color and icon
const LayoutColors *colors = layout_get_notification_colors(layout);
TimelineItem *item = prv_get_... |
/*
* 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... | (r->simultaneous_with_cb, NULL) | ;
cl_assert_equal_p(r->fail_after, NULL);
cl_assert_passert(recognizer_create_with_data(NULL, &s_test_impl_data,
sizeof(s_test_impl_data), dummy,
NULL));
cl_assert_passert(recognizer_create_with_data(&s_test_impl, NUL... |
/*
* 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... | {
const GColor8 dest_color = *dst;
const uint8_t f_src = src_color.a;
const uint8_t f_dst = 3 - f_src;
GColor8 final = {};
final.r = (src_color.r * f_src + dest_color.r * f_dst) / 3;
final.g = (src_color.g * f_src + dest_color.g * f_dst) / 3;
final.b = (src_color.b * f_src + dest_color.b * f... | |
/*
* 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 (s_read_header_mbuf) {
// already a read in progress
return SmartstrapResultBusy;
}
mutex_lock(s_read_lock);
// populate the read info
s_read_info = (ReadInfo) {
.service_id = service_id,
.attribute_id = attribute_id,
};
// add the header
FrameInfo header = (FrameInfo) {
.vers... | |
l.h"
#include <stdbool.h>
#include <stdint.h>
#include "kernel/pbl_malloc.h"
#include "services/common/system_task.h"
#include "system/passert.h"
#include "util/attributes.h"
#include "util/crc32.h"
#include "util/math.h"
#include "util/size.h"
// Defines how many PULSE file descriptors may be open concurrently
// T... | (resp + response_len, cmd, command_len) | ;
response_len += command_len;
pulse_reliable_send(resp, response_len);
}
static void prv_respond_internal_error(Command *cmd, size_t length,
status_t status_code) {
InternalErrorResponse *resp = pulse_reliable_send_begin(
PULSE2_BULKIO_PROTOCOL);
resp->opcode =... |
_release(dev->qspi);
}
int qspi_flash_write_page_begin(QSPIFlash *dev, const void *buffer, uint32_t addr,
uint32_t length) {
const uint32_t offset_in_page = addr % PAGE_SIZE_BYTES;
const uint32_t bytes_in_page = MIN(PAGE_SIZE_BYTES - offset_in_page, length);
qspi_use(dev->qspi);
... | prv_write_cmd_no_addr(dev, dev->state->part->instructions.write_enable) | ;
qspi_indirect_write_no_addr(dev->qspi, write_instruction, ®_value, 1);
qspi_release(dev->qspi);
}
static bool prv_protection_is_enabled(QSPIFlash *dev) {
uint8_t status;
prv_read_register(dev, dev->state->part->instructions.read_protection_status, &status, 1);
return (status & dev->state->part->block_l... |
_i(window2->on_screen, false);
// Switch to app happens via the compositor
compositor_transition(NULL);
// Call the upkeep function so the change in state is handled
modal_manager_event_loop_upkeep();
// The app is unobstructed, it should not be idle
cl_assert_equal_b(s_app_idle, false);
// Assert that... | window_is_focusable(window2) | , false);
WindowStack *app_stack = app_state_get_window_stack();
WindowStack *modal_stack = modal_manager_get_window_stack(ModalPriorityGeneric);
cl_check(app_stack);
cl_check(modal_stack);
cl_check(!app_stack->list_head);
cl_check(!modal_stack->list_head);
// Switch to the app state to push a window
... |
rge */ 2, \
/* This is the same as Large until ExtraLarge is designed */ \
/* x-large */ 2 \
)
typedef struct TimelineLayoutStyle {
int16_t fat_time_margin_h;
int16_t thin_time_margin_h;
int16_t primary_lin... | ((Layer *)layout, prv_update_proc) | ;
GRect icon_frame;
timeline_layout_get_icon_frame(&(GRect) { GPointZero , config->frame->size },
info->scroll_direction, &icon_frame);
const TimelineResourceSize icon_size = (config->mode == LayoutLayerModeCard)
? layout->impl->card_icon_size : TimelineResourceSizeTiny;
... |
r to own the bt_lock while calling the
// function and for as long as the result is being used / accessed.
extern uint16_t gatt_client_characteristic_get_handle_and_connection(
BLECharacteristic characteristic_ref,
... | if (data->client == GAPLEClientKernel
&& data->subtype == PebbleBLEGATTClientEventTypeCharacteristicSubscribe) {
prv_internal_write_cccd_response_cb(event);
goto cleanup;
} |
//! There is a time when we have disconnected, but there are still outstanding responses
//! coming back to the MCU (e.g. HcProtocol). When we disconnect, we call gatt_client_op_cleanup
//! which cleans up all of the memory for the nodes in the lists in `s_client_event_ctxs`.
//! Here, we check if the... |
jerry_char_t *buffer_p,
jerry_size_t buffer_size) {
const jerry_size_t str_size = jerry_get_utf8_string_size(value);
if (str_size == 0 || buffer_size < str_size || buffer_p == NULL) {
return 0;
}
EM_ASM_INT({
var... | JERRY_CREATE_VALUE(null) | ;
}
jerry_value_t jerry_create_object(void) {
return JERRY_CREATE_VALUE(new Object());
}
jerry_value_t jerry_create_string(const jerry_char_t *str_p) {
if (!str_p) {
return jerry_create_undefined();
}
return jerry_create_string_utf8_sz(str_p, strlen((const char *)str_p));
}
jerry_value_t jerry_create_str... |
ht) {
text_layer_set_background_color(text_layer, GColorWhite);
text_layer_set_text_color(text_layer, GColorBlack);
} else {
text_layer_set_background_color(text_layer, GColorClear);
text_layer_set_text_color(text_layer, GColorWhite);
}
text_layer_set_text_alignment(text_layer, GTextAlignmentLeft)... | graphics_draw_pixel(ctx, GPoint(point.x, point.y + 1)) | ;
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y + 1));
}
}
static void draw_color_rect(GContext* ctx, AppData *data, GRect rect) {
uint16_t width = rect.size.w;
uint16_t height = rect.size.h;
for (uint16_t row = 0; row < height; row += 2) {
for (uint16_t col = 0; col < width; col += 2) {
... |
// Generate a repeat start
bus->i2c->CR1 |= I2C_CR1_START;
bus->transfer.state = TRANSFER_STATE_WRITE_ADDRESS_RX;
break;
case TRANSFER_STATE_WRITE_ADDRESS_RX:
// Write the I2C device address again, but this time in read mode.
bus->i2c->DR = bus->transfer.device_address | I2C_RE... | (LOG_LEVEL_ERROR, "NACK received during I2C transfer; Bus: 0x%p", bus->i2c) | ;
}
}
return end_transfer_irq(bus, false);
}
void I2C1_EV_IRQHandler(void) {
portEND_SWITCHING_ISR(irq_event_handler(&i2c_buses[0]));
}
void I2C1_ER_IRQHandler(void) {
portEND_SWITCHING_ISR(irq_error_handler(&i2c_buses[0]));
}
void I2C2_EV_IRQHandler(void) {
portEND_SWITCHING_ISR(irq_event_handler(&i... |
break;
case DMARequestTransferType_None:
default:
WTF;
}
// "As a general recommendation, it is advised to clear all flags in the DMA_LIFCR and
// DMA_HIFCR registers before starting a new transfer." -- STM32 AN4031 (DM00046011.pdf)
// "Before setting EN bit to '1' to start a new transfer, ... | (this->state->transfer_dst) | ) {
dcache_invalidate(this->state->transfer_dst, this->state->transfer_length);
}
// Automatically stop the transfer before calling the handler so that the handler can start
// another transfer immediately. We need to preserve the handler and context first.
DMADirectRequestHan... |
_db_insert((uint8_t *)&big_time_app.uuid, sizeof(Uuid),
(uint8_t *)&big_time_app, sizeof(AppDBEntry));
big_time_app_id = app_db_get_install_id_for_uuid(&big_time_app.uuid);
app_cache_add_entry(big_time_app_id, 10701);
cl_assert_equal_i(BIG_TIME_APP_ID, big_time_app_id);
menu_layer_init(&menu_la... | ARRAY_LENGTH(watchface_default_order) | );
for (uint16_t i = 0; i < num_apps; i++) {
AppMenuNode *node = app_menu_data_source_get_node_at_index(&data_source, i);
cl_assert_equal_i(node->install_id, watchface_default_order[i]);
}
app_menu_data_source_deinit(&data_source);
}
void prv_write_order_to_file(const AppInstallId order[], uint8_t num_e... |
ck sequence in new_timers. The callback will re-register this timer as needed
// for each subsequent click event in the sequence.
const bool timer_started = new_timer_start(s_console_button_timer, 0,
command_button_press_callback, new_timer_context,
... | {
uint32_t iteration = (uintptr_t) data;
uint8_t buffer[128];
time_t base = sys_get_time();
for (int i = 0; i < 16; ++i) {
LogBinaryMessage* msg = (LogBinaryMessage*) buffer;
msg->timestamp = htonl(base + iteration * 16 + i);
msg->log_level = LOG_LEVEL_ERROR;
msg->message_length = sizeof(buffer)... |
void command_log_dump_spam(void) {
prompt_send_response("Spam logs!");
for (int i = 0; i < 16; ++i) {
system_task_add_callback(spam_callback, (void *)(uintptr_t) i);
}
}
#ifdef TEST_FLASH_LOCK_PROTECTION
#include "flash_region/flash_region.h"
#include "drivers/task_watchdog.h"
#include "drivers/watchdog.h"... |
ove here
PROPERTY_MAX,
PROPERTY_COLOR_TABLE, // Currently don't allow to switch the color table order
} ColorProperties;
typedef struct AppData {
uint8_t property;
GColor bg_color;
GColor fg_color;
uint8_t alpha;
TextLayer *alpha_text;
char alpha_text_buffer[30];
TextLayer *fg_text;
char fg_text_b... | GPoint(point.x + 1, point.y + 1) | );
graphics_context_set_stroke_color(ctx, bg_color);
graphics_draw_pixel(ctx, GPoint(point.x + 1, point.y));
graphics_draw_pixel(ctx, GPoint(point.x, point.y + 1));
} else if (alpha == ALPHA_33) {
graphics_context_set_stroke_color(ctx, fg_color);
graphics_draw_pixel(ctx, point);
graphics_conte... |
erSystemFlashRead);
flash_unlock();
}
void flash_write_bytes(const uint8_t* buffer, uint32_t start_addr, uint32_t buffer_size) {
if (!buffer_size) {
return;
}
PBL_ASSERTN((start_addr + buffer_size) <= BOARD_NOR_FLASH_SIZE);
assert_usable_state();
flash_lock();
if (!s_flash_state.enabled) {
fl... | if (enable) {
if (!s_flash_state.deep_sleep) {
flash_deep_sleep_enter();
}
} else {
if (s_flash_state.deep_sleep) {
flash_deep_sleep_exit();
}
} |
disable_flash_spi_clock();
flash_unlock();
}
bool flash_get_sleep_when_idle(void) {
bool result;
flash_lock();
result = s_flash_state.deep_sleep;
flash_unlock();
return result;
}
void debug_flash_dump_registers(void) {
#ifdef PBL_LOG_ENABLED
flash_lock();
if (!s_flash_state.enabled) {
flash_u... |
_model(buffer);
cl_assert_equal_s(buffer, "012345678901234");
}
}
void test_spalding_mfg_info__1_to_2_conversion(void) {
// Force in an old data version.
typedef struct {
uint32_t data_version;
uint32_t color;
uint32_t rtc_freq;
} MfgDataV1;
MfgDataV1 old_data = {
.data_version = ... | 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 the model.
mfg_info_set_model("test_model");
... |
},
{ 2147483646LL, 19, "27C57H31", },
{ 2147483646LL, 19, "27c57h31", },
{ -2147483647LL, 19, "-27C57H32", },
{ -2147483647LL, 19, "-27c57h32", },
{ 2147483646LL, 20, "1DB1F926", },
{ 2147483646LL, 20, "1db1f926", },
{ -2147483647LL, 20, "-1DB1F927", },
{ -2147483647LL, 20, "-1db1f927", },
{ 214748364... | {
char *end;
char *s;
s = "";
strtol(s, &end, 10);
cl_assert_equal_p(s, end);
cl_assert_equal_i('\0', *end);
s = "123";
strtol(s, &end, 10);
cl_assert_equal_p(s+3, end);
cl_assert_equal_i('\0', *end);
s = "123a";
strtol(s, &end, 10);
cl_assert_equal_p(s+3, end);
cl_assert_equal_i('a', *en... | |
/*
* 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... | graphics_context_set_compositing_mode(ctx, GCompOpTint) | ;
} else if (ctx->draw_state.compositing_mode == GCompOpAssign) {
graphics_context_set_compositing_mode(ctx, GCompOpSet);
}
}
graphics_draw_bitmap_in_rect(ctx, icon, icon_frame);
}
static void prv_menu_cell_basic_draw_custom_rect(
GContext *ctx, const Layer *cell_layer, const MenuCellLayerConfig... |
/*
* 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_ASSERTN(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... | settings_file_set(file, key, key_len, val, val_len) | );
verify(file, key, key_len, val, val_len);
}
void test_settings_file__set_get_one(void) {
printf("\nTesting setting and retreiving a single key a single time...\n");
SettingsFile file;
cl_must_pass(settings_file_open(&file, "test_file_set_get_one", 4096));
uint8_t key[4];
int key_len = sizeof(key) - 1;
... |
];
memset(&buf[0], i, sizeof(buf));
int fd = pfs_open(file_small, OP_FLAG_WRITE, FILE_TYPE_STATIC, sizeof(buf));
printf("fd=%d\n", fd);
cl_assert(fd >= 0);
cl_assert_equal_i(pfs_write(fd, &buf[0], sizeof(buf)), sizeof(buf));
if (i == 0) {
start_page = test_get_file_start_page(fd);
}
... | cl_assert(pfs_remove(file_small) == S_SUCCESS) | |
680, 1112, -504},
{ 928, 1112, -328},
{ 1192, 1136, -320},
{ 1520, 912, -224},
{ 1288, 760, -192},
{ 1288, 616, -192},
{ 1504, 496, -184},
{ 1280, 344, -144},
{ 1080, 184, -120},
{ 1120, 272, -168},
{ 1240, 184, -136},
{ 1432, 208, -176},
{ 1232, 136, -120},
{ 1112, 2... | { 1912, 360, 1144},
{ 1576, 256, 1240},
{ 1448, 344, 1048},
{ 1312, 336, 728},
{ 1088, 328, 496},
{ 912, 448, 296},
{ 784, 536, 312},
{ 792, 576, 128},
{ 768, 608, 144},
{ 736, 728, -88},
{ 640, 568, -184},
{ 624, 704, -320},
{ 512, 752, -368},
{ 560, 840, -360},
... |
{ -168, 872, -360},
{ -80, 632, -480},
{ 8, 312, -1032},
{ -104, 880, -536},
{ 32, 520, -344},
{ 80, 1080, -640},
{ 144, 1016, -600},
{ 232, 760, -456},
{ 424, 576, -792},
{ 424, 520, -816},
{ 416, 312, -976},
{ 320, 416, -936},
{ 232, 408, -944},
{ 232, 448, -92... |
/*
* 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... | (connection->ppogatt_wa_state) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (1, 10, 10) | ;
cl_assert_near(1, 5, 10);
cl_assert_near(0, 10, 10);
}
// GRect
/////////////////////////
#define EX_GRECT GRect(5, 6, 7, 8)
static GRect prv_get_grect(void) {
return EX_GRECT;
}
void test_clar__equal_grect(void) {
// test with local variable
GRect a = EX_GRECT;
GRect b = EX_GRECT;
cl_assert_equal_g... |
/*
* 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, "Helo!B") | , 7);
}
void test_strspn__c_basic(void) {
char testbuf[8] = "Hello!B";
cl_assert_equal_i(strcspn(testbuf, "o!B"), 4);
cl_assert_equal_i(strcspn(testbuf, "o"), 4);
cl_assert_equal_i(strcspn(testbuf, "!"), 5);
cl_assert_equal_i(strcspn(testbuf, "H"), 0);
}
|
ytes_overhead = 3 /* ATT header */ + sizeof(PPoGATTPacket);
return (mtu - num_bytes_overhead);
}
// -------------------------------------------------------------------------------------------------
static void prv_enter_awaiting_reset_complete(PPoGATTClient *client, bool self_initiated) {
if (client->state == Sta... | gatt_client_characteristic_get_connection(characteristic) | |
_send_response_fmt(buffer, sizeof(buffer),
"(Sub)Sector at addr: 0x%"PRIX32" not really erased. is_subsector: %d",
addr, is_subsector);
goto done;
}
}
}
}
done:
return erased;
}
// ARG:
// 0 - Only show sectors
// 1 - Show subsectors too if sector is not era... | ("invalid bit number") | ;
return;
}
bit_number += next_digit;
}
int bit_mask = 1 << bit_number;
if (value[0] == '0') {
boot_bit_clear(bit_mask);
} else if (value[0] == '1') {
boot_bit_set(bit_mask);
} else {
prompt_send_response("invalid bit value, pick 1 or 0");
return;
}
prompt_send_response("OK... |
prv_template_evaluate_filter(TemplateStringState *state, const char *filter_name,
const char *params);
static const char *s_error_strings[] = {
"Success.",
"Can't resolve.",
"Missing closing brace.",
"Missing argument.",
"No result generated.",
"Unknown filter.",
"format... | cl_assert_equal_b(ret, true) | ;
cl_assert_equal_s(s_output, "test string 5 seconds");
cl_assert_equal_i(cond.eval_time, 1);
cl_assert_equal_b(cond.force_eval_on_time, true);
}
{
TemplateStringVars vars = {};
TemplateStringError err = {};
TemplateStringEvalConditions cond = {};
vars.current_time = 0;
cond.eval_t... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
cl_assert(gcolor_equal(GColorBlue, GColorBlue));
cl_assert(gcolor_equal(GColorRed, GColorRed));
cl_assert(!gcolor_equal(GColorRed, GColorBlue));
// Two colors with zero alpha values should be equal regardless of what their RGB channels are
GColor8 color1 = GColorBlue;
color1.a = 0;
GColor8 color2 = GCo... |
void test_graphics_colors__equal__deprecated(void) {
cl_assert(gcolor_equal__deprecated(GColorBlue, GColorBlue));
cl_assert(gcolor_equal__deprecated(GColorRed, GColorRed));
cl_assert(!gcolor_equal__deprecated(GColorRed, GColorBlue));
// Check the behavior of the deprecated function (which is incorrect) that ... |
*menu_layer, MenuIndex new_index,
MenuIndex old_index, void *context) {
SettingsData *data = context;
const uint16_t new_row = new_index.row;
const uint16_t old_row = old_index.row;
SettingsCallbacks *callbacks = prv_get_current_callbacks(data);
if (callbacks->sele... | (menu_layer, SETTINGS_MENU_HIGHLIGHT_COLOR, GColorWhite) | ;
menu_layer_set_click_config_onto_window(menu_layer, &data->window);
layer_add_child(&data->window.layer, menu_layer_get_layer(menu_layer));
SettingsCallbacks *callbacks = prv_get_current_callbacks(data);
if (callbacks->get_initial_selection) {
const uint16_t selected_row = callbacks->get_initial_selectio... |
= (Attribute[]) {
{ .id = AttributeIdTitle, .cstring = "Title" },
{ .id = AttributeIdBody, .cstring = "Body" },
{ .id = AttributeIdMuteDayOfWeek, .uint8 = MuteBitfield_Always },
{ .id = AttributeIdAppName, .cstring = "Awesome" },
{ .id = AttributeIdLastUpdated, .uint32 = s_now },
}
}... | (ancs_filtering_is_muted(&mute_weekends)) | ;
cl_assert(!ancs_filtering_is_muted(&mute_weekdays));
s_now += SECONDS_PER_DAY; // Sunday Jan 3, 2016
cl_assert(ancs_filtering_is_muted(&mute_always));
cl_assert(ancs_filtering_is_muted(&mute_weekends));
cl_assert(!ancs_filtering_is_muted(&mute_weekdays));
s_now += SECONDS_PER_DAY; // Monday Jan 4, 2016
... |
/*
* 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_num_sessions, 0) | ;
// Add a non-ongoing walk session
prv_add_session(&(ActivitySession){
.type = ActivitySessionType_Walk,
.ongoing = false,
});
// Make sure the session was added
cl_assert_equal_i(s_num_sessions, 1);
// Find the session we just added
ActivitySession walk_session = {};
found_session = workout... |
{ -1528, 344, 600},
{ -1112, 1136, 704},
{ -856, 1120, -56},
{ -808, 720, 168},
// 15 seconds
{ -960, 568, 240},
{ -1200, 640, 328},
{ -1584, 616, 312},
{ -1880, 528, 328},
{ -1920, 352, 488},
{ -1784, 88, 480},
{ -1640, 16, 328},
{ -1424, 48, 280},
{ -1224, 120, 256... | { -1944, 640, -24},
{ -1872, 632, 160},
{ -1536, 736, -96},
{ -1416, 160, -296},
{ -1600, 480, -176},
{ -1824, 632, 112},
{ -1416, 1208, 56},
{ -1176, 336, -120},
{ -736, 560, -384},
{ -768, 832, -280},
{ -1080, 848, -56},
{ -1472, 440, 48},
{ -1616, 272, 64},
{ -... |
{ -1456, 360, 8},
{ -1640, 280, 40},
{ -1640, 264, 72},
{ -1504, 184, 120},
// 23 seconds
{ -1368, 128, 120},
{ -1272, 112, 120},
{ -1136, 80, 120},
{ -1040, 96, 96},
{ -1056, -248, 232},
{ -824, -496, 144},
{ -936, -120, -8},
{ -1392, 128, -144},
{ -1424, 464, -... |
/*
* 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... | dbgserial_putstr("Keys:\nWASD: Move frame.origin\n[]: Change frame.size.w & bounds.size.w\n{}: Change frame.size.h & bounds.size.h") | ;
serial_console_set_state(SERIAL_CONSOLE_STATE_LAYER_NUDGING);
}
#endif /* UI_DEBUG */
|
fer[buffer_size]; \
DictionaryIterator it; \
const DictionaryResult result = \
dict_serialize_tuplets_to_buffer_with_iter(&it, tuplets, ARRAY_LENGTH(tuplets), \
buffer, &buffer_size); \
cl_assert_equal_i(DICT_OK, result); \
if (s_received_callba... | (false /* start_connected */) | ;
prv_simulate_transport_connection_event(true /* is_connected */);
RCV_DUMMY_CHUNK();
// https://pebbletechnology.atlassian.net/browse/PBL-42466
// TODO: assert that app message was NACK'd
// Expect responding with a ResetRequest:
EXPECT_OUTBOX_RESET_REQUEST();
EXPECT_OUTBOX_MESSAGE_PENDING(TupletBytes... |
use uint16_t instead of uint32_t (aka ResourceId) to save space. This wont be a problem
//! until we have more than 2^16 resource ids.
extern const uint16_t g_timeline_resources[][TimelineResourceSizeCount];
T_STATIC bool prv_is_app_published_resource_valid(const AppResourceInfo *res_info) {
// TODO: PBL-39864 Impro... | (timeline_res && res_info_out && (size < TimelineResourceSizeCount)) | ;
// Test the high bit to determine if system resource
// TODO PBL-24499: Remove check for system uuid - this is only in place to ease the migration
// from 3.4, where not all system pins use the correct id convention
if (timeline_resources_is_system(timeline_res->res_id) || uuid_is_system(timeline_res->app_id... |
SECONDS_PER_HOUR);
// if the event is within 24 hours, then show the actual time instead of "X hours ago"
const int MAX_RELATIVE_HRS = 13;
clock_set_24h_style(false);
// June 9th 2015, 17:00:00 (T+01:00:00)
rtc_set_time(event_time + SECONDS_PER_HOUR);
clock_get_until_time_capitalized(time_buf, sizeof(tim... | rtc_set_time(event_time + (1 * SECONDS_PER_MINUTE)) | ;
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, 16:02:00 (T+00:02:00)
rtc_set_time(event_time + (2 * SECONDS_PER_MINUTE));
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_REL... |
r_scheduled(top_window)) {
return true;
}
WindowStack *stack = app_state_get_window_stack();
if (!window_stack_is_animating(stack)) {
return false;
}
WindowTransitioningContext *transition_ctx = &stack->transition_context;
return prv_window_is_render_scheduled(transition_ctx->window_from) ||
... | {
ApplibInternalEventsInfo *events_info =
app_state_get_applib_internal_events_info();
// Initialize the state for the status bar handler.
events_info->minute_of_last_legacy2_statusbar_change = -1;
events_info->legacy2_status_bar_change_event = (EventServiceInfo) {
.type = PEBBLE_TICK_EVEN... |
// NOTE: We could be super fancy and register and unregister when the fullscreen
// status changes, but it's probably not worth it as we'll be waking up once a
// minute anyway to update the face itself and it will happen as part of the same interval
}
static void prv_legacy2_status_bar_timer_unsubscribe(void) ... |
we get at two full past days in there
#define PIN_DB_FILE_NAME "pindb"
#define PIN_DB_MAX_SIZE KiBYTES(40) // TODO [FBO] variable size / reasonable value
static TimelineItemStorage s_pin_db_storage;
/////////////////////////
// Pin DB specific API
/////////////////////////
status_t pin_db_delete_with_parent(const T... | {
blob_db_sync_record(BlobDBIdPins, (uint8_t *)&item->header.id, sizeof(TimelineItemId),
rtc_get_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... | (CRG_TOP, CLK_AMBA_REG, AES_CLK_ENABLE) | );
hw_aes_hash_setup aes_setup = {
.mode = HW_AES_ECB, // we're just encrypting one block, so just use "code book"
.aesDirection = HW_AES_ENCRYPT,
.aesKeySize = HW_AES_128,
.aesKeyExpand = true,
.aesKeys = (uintptr_t)(void *)key,
.aesWriteBackAll = false,
.moreDataToCome = false,
.sou... |
,
{ 1112, 376, 16},
{ 888, 240, 56},
// 94 seconds
{ 1224, 152, 192},
{ 1256, 104, 312},
{ 1120, 104, 136},
{ 944, 104, 120},
{ 848, 56, 136},
{ 784, 32, 120},
{ 744, 0, 120},
{ 680, -24, 112},
{ 664, -64, 64},
{ 888, 32, -88},
{ 1136, 24, -32},
{ 1720, -192, ... | { 1016, 112, 136},
{ 1320, 48, 224},
{ 1304, 48, 256},
{ 1128, 72, 248},
{ 968, 64, 152},
{ 856, 32, 120},
{ 768, 48, 40},
{ 688, 24, 0},
// 100 seconds
{ 624, -48, 8},
{ 640, -136, 16},
{ 880, 0, -128},
{ 1344, -128, 88},
{ 1856, -32, 352},
{ 1640, 384, 152},... |
{ 1184, 336, -32},
{ 1272, 344, -128},
{ 1400, 272, 88},
{ 1136, 352, 184},
{ 976, 384, 144},
{ 912, 240, 120},
{ 848, 168, 152},
{ 792, 320, 24},
{ 864, 336, -16},
{ 960, 456, -32},
{ 1088, 432, -24},
{ 1280, 376, -24},
{ 1664, 176, 128},
// 103 seconds
{ 18... |
clude "apps/system_app_ids.h"
#include "board/board.h"
#include "os/mutex.h"
#include "process_management/app_install_manager.h"
#include "process_management/process_manager.h"
#include "services/normal/activity/activity.h"
#include "services/normal/activity/activity_insights.h"
#include "services/normal/activity/insig... | if (!app_install_entry_is_watchface(entry) ||
app_install_entry_is_hidden(entry)) {
return true; // continue search
} |
watchface_set_default_install_id(entry->install_id);
return false;
}
AppInstallId watchface_get_default_install_id(void) {
AppInstallId app_id = app_install_get_id_for_uuid(&s_default_watchface);
AppInstallEntry entry;
if ((app_id == INSTALL_ID_INVALID) ||
!app_install_get_entry_for_install_id(app_id... |
>next = s_head;
s_head = result;
} else {
// Insert as tail:
prev->next = result;
result->next = NULL;
}
}
static ScanResult *list_get_by_index(uint8_t index) {
ScanResult *result = s_head;
while (index && result) {
result = result->next;
--index;
}
return result;
}
static void lis... | menu_cell_basic_header_draw(ctx, cell_layer,
(section_index == SectionData) ? "Results" : "Options") | |
stored will be 0, because the result is in the future, so a value of 0
will definitely be the soonest time that matches.
Now, if the result is behind the local epoch, we step through higher order fields for a field
that was not specified. When we find one, we increase the value by 1. Since this is a higher
order fi... | {
time_t t_last = t;
time_t offset_epoch = local_epoch;
while (true) {
const time_t t_delta = (t - local_epoch) * ((job->offset_seconds > 0) ? 1 : -1);
if ((job->may_be_instant ? (t_delta <= 0) : (t_delta < 0))) {
break;
}
// Offset seconds is positive => Applying a positive ... |
return t;
}
time_t cron_job_get_execute_time(const CronJob *job) {
return cron_job_get_execute_time_from_epoch(job, rtc_get_time());
}
|
mple
if (strcmp(token, "{") == 0) {
PBL_ASSERTN(state->test_entry.name[0] != 0);
int x, y, z;
sscanf(token + strlen(token) + 1, "%d, %d, %d", &x, &y, &z);
fflush(stdout);
PBL_ASSERTN(state->test_entry.num_samples < ACCEL_SAMPLES_DISCOVERY_MAX_SAMPLES);
state->samples[state->test... | {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.end_at.max);
} | else if (strcmp(token, "TEST_CUR_STATE_ELAPSED") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.cur_state_elapsed.value);
} else if (strcmp(token, "TEST_CUR_STATE_ELAPSED_MIN") == 0) {
sscanf(token + strlen(token) + 1, "%d", &state->test_entry.cur_state_elapsed.min);
} e... |
/);
}
}
launcher_app_glance_destroy(entry->glance);
app_free(entry);
}
static bool prv_glance_cache_deinit_foreach_cb(ListNode *node, void *context) {
LauncherAppGlanceService *service = context;
LauncherAppGlanceCacheEntry *entry = (LauncherAppGlanceCacheEntry *)node;
prv_glance_cache_destroy_entry(... | ARRAY_LENGTH(s_system_glance_factories) | ; i++) {
const SystemAppGlanceFactory *factory = &s_system_glance_factories[i];
if (uuid_equal(&factory->uuid, &node->uuid)) {
glance = factory->constructor(node);
break;
}
}
// If we haven't loaded a glance yet, try loading a generic glance for the node
if (!glance) {
glance = launch... |
_schedule(a);
uint64_t start_ms = prv_now_ms();
prv_advance_to_ms_with_timers(start_ms + test_duration);
// Should still be running
cl_assert_equal_i(prv_count_handler_entries(&s_setup_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, a), 1);
cl_assert_equal_i(p... | prv_count_handler_entries(&s_started_handler_calls, a) | , 1);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, a), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, b), 2);
cl_assert_equal_i(prv_count_handler_entries(&s_stopped_handler_calls, b), 1);
cl_assert_equal_i(prv_count_handler_entries(&s_started_handler_calls, ... |
a unused
static void prv_check_all_sessions_timer_cb(void *data) {
// If sends are not enabled, do nothing
if (!prv_sends_enabled()) {
PBL_LOG(LOG_LEVEL_INFO, "Not sending sessions beause sending is disabled");
return;
}
// We regularly check all our sessions to see if we have any data to send. Normall... | if (leftover_bytes) {
PBL_LOG(LOG_LEVEL_ERROR, "leftover bytes in the session. Flushing...");
// remove the number of leftover bytes so we fall back on our feet
read_bytes -= leftover_bytes;
dls_storage_consume(logging_session, leftover_bytes);
analytics_inc(ANALYTICS_DEVICE_METRIC_DATA_LOGGING_FL... |
// ----------------------------------------------------------------------------------------
void dls_pause(void) {
regular_timer_remove_callback(&prv_check_all_sessions_timer_info);
}
// ----------------------------------------------------------------------------------------
void dls_resume(void) {
regular_tim... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.