prefix stringlengths 0 918k | middle stringlengths 0 812k | suffix stringlengths 0 962k |
|---|---|---|
tatic void prv_monitor_system_task_cb(void *context) {
static uint32_t s_monitor_interval = 0;
PBL_ASSERT_TASK(PebbleTask_KernelBackground);
smartstrap_state_lock();
if (s_subscriber_count == 0) {
prv_release_accessory();
smartstrap_state_unlock();
return;
}
if (smartstrap_fsm_state_get() == Sm... | smartstrap_connection_kick_monitor() | ;
}
smartstrap_state_unlock();
}
DEFINE_SYSCALL(void, sys_smartstrap_unsubscribe, void) {
smartstrap_state_lock();
s_subscriber_count--;
if (s_subscriber_count == 0) {
// Disconnect directly from here rather than waiting for the monitor in order to ensure it
// happens synchronously.
prv_release_... |
first message, allocate buffer:
uint8_t *const buffer = task_malloc(chunk->total_size_bytes);
if (!buffer) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Not enough mem to recv postMessage() of %"PRIu32" bytes",
(uint32_t) chunk->total_size_bytes);
// https://pebbletechnology.atlassian.net/browse/PB... | (node->data, data, length) | ;
if (s_state.out.control_msg_queue) {
list_append((ListNode *)s_state.out.control_msg_queue, (ListNode *)node);
} else {
s_state.out.control_msg_queue = node;
}
prv_outbox_try_send_next();
}
////////////////////////////////////////////////////////////////////////////////
// Generic outbox handlers
//... |
/*
* 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... | {
GBCoredumpData *data = storage->impl_data;
uint32_t image_base = data->core_dump_base + sizeof(CoreDumpFlashRegionHeader);
flash_read_bytes(buffer, image_base + storage->current_offset, len);
storage->current_offset += len;
return true;
} | |
ats (values <= 0 are considered invalid)
static bool prv_stats_filter(int index, int32_t value, void *context) {
return (value > 0);
}
// ------------------------------------------------------------------------------------------------
// Calculates the mean and median of a metric over the entire history we have for ... | attribute_list_add_cstring(&dismiss_action_attr_list, AttributeIdTitle,
i18n_get("Dismiss", ¬if_attr_list)) | |
rst
l.selection_animation_disabled = true;
menu_layer_set_selected_index(&l, MenuIndex(0, 1), MenuRowAlignTop, true);
cl_assert_equal_i(1, menu_layer_get_selected_index(&l).row);
cl_assert(!l.animation.animation);
// Test enabled
l.selection_animation_disabled = false;
menu_layer_set_selected_index(&l, M... | menu_layer_get_selected_index(&l) | |
}
#endif
return APP_STACK_NORMAL_SIZE;
}
T_STATIC MemorySegment prv_get_app_ram_segment(void) {
return (MemorySegment) { __APP_RAM__, __APP_RAM_end__ };
}
T_STATIC size_t prv_get_stack_guard_size(void) {
return (uintptr_t)__stack_guard_size__;
}
// ------------------------------------------------------------... | if (!resource_init_app(res_bank_num, res_version_ptr)) {
// The resources are busted! Abort starting this app.
APP_LOG(APP_LOG_LEVEL_ERROR,
"Checksum for resources differs or insufficient meta data for JavaScript app.");
return false;
} |
}
// Synchronously handle process start since its new state is needed for app state initialization
timeline_peek_handle_process_start();
const ProcessAppSDKType sdk_type = process_metadata_get_app_sdk_type(app_md);
// The rest of app_ram is available for app_state to use as it sees fit.
if (!app_state_c... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (framebuffer.buffer) | |
ind a connection is because we have deinitialized everything
// we only have connections stored after the module has been initialized
PBL_ASSERTN((connection != NULL) == s_le_connection_module_initialized);
if (connection) {
prv_destroy_connection(connection);
}
}
bt_unlock();
}
// --------... | {
cb(connection, data);
connection = (GAPLEConnection *) connection->node.next;
} |
}
// -------------------------------------------------------------------------------------------------
void gap_le_connection_set_gateway(GAPLEConnection *connection, bool is_gateway) {
connection->is_gateway = is_gateway;
// TODO: update bonding `is_gateway` flag
// bt_persistent_storage_...
}
// ----------... |
/*
* 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... | callback(data) | ;
}
// Helpers
///////////////////////////////////////////////////////////
static const BTDeviceInternal s_device = {
.address = {
.octets = {
1, 2, 3, 4, 5, 6,
},
},
};
static uint32_t s_connection_id = 1;
static GAPLEConnection *s_connection;
static void prv_cccd_write(bool is_subscribing) {
... |
///////////////////////////////////////////////////////////////////////////////////////
//! Tests
void test_do_not_disturb__initialize(void) {
fake_spi_flash_init(0, 0x1000000);
pfs_init(false);
pfs_format(false);
rtc_set_time(s_thursday_00_00);
alerts_preferences_init();
do_not_disturb_init();
do_not_... | (do_not_disturb_is_manually_enabled() == false) | ;
cl_assert(do_not_disturb_is_schedule_enabled(WeekdaySchedule) == true);
cl_assert(do_not_disturb_is_smart_dnd_enabled() == false);
active = do_not_disturb_is_active();
cl_assert(active == true);
// Enabling Smart DND
do_not_disturb_set_manually_enabled(false);
do_not_disturb_set_schedule_enabled(Weekda... |
uint16_t radius,
GCornerMask corner_mask) {
PBL_ASSERTN(ctx);
if (!rect || ctx->lock) {
return;
}
#if PBL_COLOR
if (ctx->draw_state.antialiased) {
// Antialiased (not suppported on 1-bit color)
prv_fill_rect_aa(ctx, rect, radius, corner_mask, ctx->draw_state.fill_colo... | (ctx, top_right, bottom_right) | ;
graphics_line_draw_precise_stroked(ctx, bottom_right, bottom_left);
graphics_line_draw_precise_stroked(ctx, bottom_left, top_left);
}
// This takes care of all routines since it re-uses existing AA and SW functionality in draw line
// and draw circle
T_STATIC void prv_draw_round_rect(GContext* ctx, const GRect *... |
{ 1608, 568, -136},
{ 1616, 752, -64},
{ 1392, 896, 8},
{ 1096, 1040, 32},
{ 696, 1008, 16},
{ 728, 984, 120},
{ 848, 776, 144},
{ 1024, 744, 48},
{ 1240, 720, 40},
// 60 seconds
// elapsed: 1 minutes
{ 1568, 672, 24},
{ 1464, 472, -40},
{ 1512, 472, -112},
{ 16... | { 1448, 296, -120},
{ 1384, 264, -80},
{ 1368, 208, -80},
{ 1328, 168, -16},
{ 1128, 200, -48},
{ 744, -144, 56},
{ 792, -304, 96},
{ 752, -312, -152},
{ 1128, 144, -360},
{ 1528, 56, -264},
{ 1360, 368, -312},
{ 1224, 96, -280},
{ 1296, 344, -312},
{ 1528, 400, -... | |
96, -1256},
{ -592, 864, -848},
{ -952, 152, -264},
{ -1384, -120, 88},
{ -1304, -64, -24},
{ -920, 344, -104},
{ -800, 1248, -312},
{ -528, 4000, -1568},
{ 400, 3984, -1832},
{ 856, 1824, -712},
{ 624, 904, -200},
{ 1264, 432, -32},
{ 1440, -472, 360},
{ 1376, -672, ... | { -152, 2432, -2224},
{ -760, 1232, -1792},
{ -912, 648, -1080},
{ -1144, -224, -168},
{ -1376, -336, 24},
{ -1048, -176, 24},
{ -1056, 360, 144},
{ -2424, 1464, -136},
{ -1112, 4000, -2592},
{ 992, 4000, -1768},
{ 1816, 1320, -720},
{ 1832, 104, 96},
// 51 seconds
... |
{ -968, 560, -136},
{ -608, 2192, -976},
{ -672, 3776, -1400},
{ -128, 3656, -1600},
{ 560, 2376, -872},
{ 640, 976, -168},
{ 960, 400, -80},
{ 1296, -88, 80},
{ 1608, -264, 192},
{ 1384, -280, 184},
{ 976, 48, 120},
{ 1312, 240, -304},
{ 3208, 3248, -2616},
{ 21... |
rv_disable_qspi_clock(void) {
periph_config_disable(RCC_AHB3PeriphClockCmd, RCC_AHB3Periph_QSPI);
}
static void prv_set_num_data_bytes(uint32_t length) {
// From the docs: QSPI_DataLength: Number of data to be retrieved, value+1.
// so 0 is 1 byte, so we substract 1 from the length. -1 is read the entire flash l... | prv_flash_check_whoami() | ;
prv_disable_qspi_clock();
return result;
}
void flash_read_bytes(uint8_t *buffer_ptr, uint32_t start_addr, uint32_t buffer_size) {
prv_enable_qspi_clock();
prv_set_num_data_bytes(buffer_size);
QSPI_ComConfig_InitTypeDef qspi_com_config;
QSPI_ComConfig_StructInit(&qspi_com_config);
qspi_com_config.Q... |
config->extent);
}
static GTextNodeText *prv_create_text_attribute_node_from_config(
const LayoutLayer *layout, const LayoutNodeTextAttributeConfig *config) {
GTextNodeText *text_node = prv_create_text_node_attribute(layout, config->attr_id);
if (text_node) {
prv_set_text_node_text_parameters_from_config(t... | if (config->horizontal_alignment) {
horizontal_node->horizontal_alignment = ToGTextAlignment(config->horizontal_alignment);
} |
prv_setup_container_node_from_config(&horizontal_node->container, layout, &config->container);
}
return horizontal_node;
}
static GTextNodeVertical *prv_create_vertical_container_node_from_config(
const LayoutLayer *layout, const LayoutNodeVerticalConfig *config) {
const int capacity = config->container... |
ActiveKCalories:
case ActivityMetricDistanceMeters:
case ActivityMetricSleepStateSeconds:
case ActivityMetricLastVMC:
case ActivityMetricHeartRateRawBPM:
case ActivityMetricHeartRateRawQuality:
case ActivityMetricHeartRateRawUpdatedTimeUTC:
case ActivityMetricHeartRateFilteredBPM:
case A... | prv_file_open_and_lock(&file) | ;
if (rv != S_SUCCESS) {
return rv;
}
rv = settings_file_set(&file, key, key_len, val, val_len);
prv_file_close_and_unlock(&file);
}
prv_notify_health_listeners((const char *)key, key_len, val, val_len);
return rv;
}
int health_db_get_len(const uint8_t *key, int key_len) {
if (!prv_key... |
AME}.pbi"));
setup_test_aa_sw(&ctx, fb, ORIGIN_RECT_CLIP_NXNY, ORIGIN_RECT_CLIP_NXNY, true, 10);
graphics_line_draw_precise_stroked_aa(&ctx, START_ON_ORIGIN_RECT_NXNY, END_ON_ORIGIN_RECT_NXNY, 10);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_across_nxny_origin_layer_aa.${BIT_DEPTH_NAME}.pbi"))... | cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "draw_stroke_precise_inside_offset_layer_non_aa.${BIT_DEPTH_NAME}.pbi")) | |
ributeList *list) {
return (sizeof(Attribute) * list->num_attributes) + attribute_list_get_string_buffer_size(list);
}
size_t attribute_list_get_string_buffer_size(const AttributeList *list) {
size_t size = 0;
for (int i = 0; i < list->num_attributes; i++) {
size += prv_get_attribute_length(&list->attributes... | if (attr_list->attributes[i].id == id) {
return &attr_list->attributes[i];
} |
}
return NULL;
}
const char *attribute_get_string(const AttributeList *attr_list, AttributeId id,
char *default_value) {
PBL_ASSERTN(attr_list != NULL);
if (id == AttributeIdUnused) {
return default_value;
}
PBL_ASSERTN(prv_attribute_type(id) == AttributeTypeString);
... |
tContext
} ExecutingCommand;
static bool s_command_continues_after_return = false;
static ExecutingCommand s_executing_command = ExecutingCommandNone;
//! Currently used prompt context. This is set so that we know which response
//! and completion callbacks to use.
static PromptContext *s_current_context = NULL;
st... | if (!command_found) {
cmd[cmd_len] = '\0';
char buffer[64];
prompt_send_response_fmt(buffer, sizeof(buffer), "Invalid command <%s>! Try 'help'", cmd);
prompt_command_finish();
} |
}
void prompt_context_execute(PromptContext *context) {
s_executing_command = ExecutingCommandContext;
prv_find_and_execute_command(context->buffer, context->write_index, context);
context->write_index = 0;
}
static void prv_execute_command_from_dbgserial(void *data) {
dbgserial_putstr("");
char* buffer ... |
/*
* 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... | mfg_info_set_rtc_freq(rtc_freq) | ;
}
void command_model_read(void) {
char model_buffer[MFG_INFO_MODEL_STRING_LENGTH];
mfg_info_get_model(model_buffer);
// Just send it straight out, as it's already null-terminated
prompt_send_response(model_buffer);
}
void command_model_write(const char* model) {
// mfg_info_set_model will truncate if the... |
8n_noop("Bootloader"),
[SystemInformationItemHardware] = i18n_noop("Hardware"),
[SystemInformationItemSerial] = i18n_noop("Serial"),
[SystemInformationItemUptime] = i18n_noop("Uptime"),
[SystemInformationItemLegal] = i18n_noop("Legal")
};
static void prv_populate_uptime_string(SystemInformationData* data) {
... | ("Did your Pebble reset?") | , RESOURCE_ID_RESULT_FAILED_LARGE);
confirmation_dialog_set_click_config_provider(confirmation_dialog,
prv_information_click_config);
app_confirmation_dialog_push(confirmation_dialog);
}
}
#include "drivers/led_controller.h"
#include "system/rtc_registers.h"
static void prv_color_led_easter_egg(voi... |
0x06,
PmicRegisters_INT_MASK_A = 0x07,
PmicRegisters_INT_MASK_B = 0x08,
PmicRegisters_CHG_CNTL_A = 0x0A,
PmicRegisters_BUCK1_CONFIG = 0x0D,
PmicRegisters_BUCK2_CONFIG = 0x0F,
PmicRegisters_LDO1_CONFIG = 0x12,
PmicRegisters_LDO2_CONFIG = 0x14,
PmicRegisters_LDO3_CONFIG = 0x16,
PmicRegisters_MON_CFG = ... | {
// We disabled the rail!
*ref_count = 0;
return true;
} |
return false;
} else {
(*ref_count)--;
return true;
}
}
}
bool pmic_power_off(void) {
bool ret = prv_write_register(PmicRegisters_PWR_CFG, 0xB2);
if (ret) {
// Goodbye cruel world. The PMIC should be removing our power at any time now.
while (1) {}
__builtin_unreachable()... |
&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿıŁłŒœŠšŸŽžƒˆˇ˘˙˚˛˜˝π–—‘’‚“”„†‡•…‰‹›⁄€™Ω∂∆∏∑−√∞∫≈≠≤≥◊fifl";
static void select_click_handler(ClickRecognizerRef recognizer, void* callbac... | fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD) | ;
s_system_font = s_fonts[0];
struct AppState* data = app_malloc_check(sizeof(struct AppState));
app_state_set_user_data(data);
push_window(data);
}
static void handle_deinit(void) {
struct AppState* data = app_state_get_user_data();
app_free(data);
}
static void s_main(void) {
handle_init();
app_ev... |
tate->storage, true /* successful */);
kernel_free(state);
s_get_bytes_in_progress = false;
prv_put_status_event(DebugInfoStateFinished);
comm_session_set_responsiveness(state->session, BtConsumerPpGetBytes, ResponseTimeMax, 0);
return;
} else {
comm_session_set_responsiveness(state->session... | prv_protocol_send_err_response(session, hdr->transaction_id, GET_BYTES_MALFORMED_COMMAND) | |
on__reuse_components(void) {
#ifdef TEST_INCLUDE_COMPLEX
// Create animations
// Create a sequence out of a and b
Animation *a = prv_create_test_animation();
Animation *b = prv_create_test_animation();
Animation *seq = animation_sequence_create(a, b, NULL);
cl_assert(seq != NULL);
// Try to create a sp... | cl_assert_passert(animation_get_progress(h, &progress)) | |
etrics_prv_get_distance_mm();
const uint32_t minute_distance_mm = distance_mm - s_alg_state->prev_distance_mm;
const int k_mm_per_cm = 10;
m_rec->distance_cm = ROUND(minute_distance_mm, k_mm_per_cm);
// Fill in heart rate, heart rate sample weight, then reset it
int32_t median, heart_rate_total_weight_x100;
... | if (!activity_tracking_on()) {
return;
} | |
de "applib/graphics/graphics_line.h"
#include "applib/graphics/gtypes.h"
#include "applib/graphics/framebuffer.h"
#include "applib/ui/animation.h"
#include "applib/ui/animation_timing.h"
#include "applib/ui/animation_interpolate.h"
#include "applib/graphics/gdraw_command_transforms.h"
#include "util.h"
#include "test... | cl_assert_equal_i(y, -255 + -255) | ;
}
void test_gdraw_command_transforms__int_scale_to_scale_overflow(void) {
InterpolateInt64Function interp = prv_default_interpolate;
int y = prv_int_scale_and_translate_to(181, 1, 1, 181, 0, 0, ANIMATION_NORMALIZED_MAX,
interp);
cl_assert_equal_i(y, 181 * 181);
}
void ... |
ted 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 "workout_dialog.h"
#include "applib/applib_malloc.auto.h"
#include "applib/graphics/gtypes.h"
#incl... | (ctx,
dialog->buffer,
dialog_text_font,
probe_rect,
GTextOverflowModeWordWrap,
... | |
/*
* 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(text_resources_init_font(0, gothic_18_handle, 0, &s_font_info)) | ;
cl_assert_equal_i(FONT_VERSION(s_font_info.base.md.version), 3);
cl_assert_equal_i(s_font_info.base.md.wildcard_codepoint, WILDCARD_CODEPOINT);
cl_assert_equal_i(s_font_info.base.md.codepoint_bytes, 2);
}
void test_text_resources__horiz_advance(void) {
uint32_t gothic_18_handle = RESOURCE_ID_GOTHIC_18;
cl_... |
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 11th 2015, 12:00:00 (T-24:00:00)
rtc_set_time(event_time - SECONDS_PER_DAY);
clock_get_until_time_capitalized(time_buf, sizeof(time_buf), event_time, MAX_RELATIVE_... | cl_assert_equal_s("IN 10 H", time_buf) | |
text(ctx, identifier, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
identifier_area, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
}
#else
static void prv_draw_border(Layer *layer, GContext *ctx, uint8_t radial_padding_size) {
graphics_draw_rect(ctx, &layer->bounds);
}
#endif... | {
light_enable(true);
prv_handle_init();
app_event_loop();
light_enable(false);
} |
const PebbleProcessMd* mfg_display_app_get_info(void) {
static const PebbleProcessMdSystem s_app_info = {
.common.main_func = &s_main,
// UUID: df582042-5beb-410f-9fed-76eccd31821e
.common.uuid = { 0xdf, 0x58, 0x20, 0x42, 0x5b, 0xeb, 0x41, 0x0f,
0x9f, 0xed, 0x76, 0xec, 0xcd, 0x31, 0... |
uled_completed, true);
}
free(ad_a);
free(ad_b);
free(ad_c);
free(ad_d);
}
// Tests that the adv data is set when a job goes from a silent term to a non-silent one, and
// another job's data was previously advertised.
void test_gap_le_advert__data_set_after_silent_term(void) {
GAPLEAdvertisingJobTerm adve... | gap_le_assert_advertising_interval(advert_terms_a[0].min_interval_slots,
advert_terms_a[0].max_interval_slots) | ;
// After A's first term, expect that B's second term will follow. B's first term was silent, so
// this "ran" at the same time as A's first term.
regular_timer_fire_seconds(1);
cl_assert_equal_b(gap_le_is_advertising_enabled(), true);
assert_ad_data("B");
gap_le_assert_advertising_interval(advert_terms_... |
/*
* 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... | (QSPI_FLASH) | ;
}
FlashAddress flash_impl_get_sector_base_address(FlashAddress addr) {
return (addr & SECTOR_ADDR_MASK);
}
FlashAddress flash_impl_get_subsector_base_address(FlashAddress addr) {
return (addr & SUBSECTOR_ADDR_MASK);
}
void flash_impl_enable_write_protection(void) {
}
status_t flash_impl_write_protect(FlashAdd... |
/*
* 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 sfs_seek(iter, 0, FSeekCur);
} | |
pfs_init(false) | ;
int expected_remaing_files = pages_per_sector - 1;
// scatter files across two sectors
for (int i = 0; i < (pages_per_sector + start_page_offset); i++) {
char filename[20];
sprintf(filename, "test%d", i + start_page_offset);
int fd = pfs_open(filename, OP_FLAG_WRITE, FILE_TYPE_STATIC, 10);
cl_... | |
font,
GRect(x_start, y, width, font_height),
text_format.overflow_mode,
text_format.text_alignment, NULL);
}
// Renders all of StatusBarLayer when layer_mark_dirty triggers LayerUpdateProc
void status_bar_layer_render(GContext *ctx, const GRect *boun... | graphics_text_layout_get_max_used_size(ctx,
time_text_buffer,
text_format.font,
status_bar_layer->layer.bounds,
text_format.over... | .w;
}
|
bt_driver_cb_gatt_handle_mtu_update(&mtu_resp) | ;
}
static void prv_handle_dev_name_response(const HcProtocol_GapDeviceNameResponseHeader *resp) {
GAPLEConnection *connection = gap_le_connection_by_device(&resp->addr);
if (!connection) {
PBL_LOG(LOG_LEVEL_INFO, "HcGap: no connection for "BT_DEVICE_ADDRESS_FMT,
BT_DEVICE_ADDRESS_XPLODE(resp->addr... | |
/*
* 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... | {
*image = (RotBitmapLayer){};
image->bitmap = bitmap;
const int32_t bmp_width = bitmap->bounds.size.w;
const int32_t bmp_height = bitmap->bounds.size.h;
const int32_t layer_size = integer_sqrt(bmp_width * bmp_width + bmp_height * bmp_height);
layer_init(&image->layer, &GRect(0, 0, layer_size, layer_size)... | |
//////////////
bool sys_app_pp_has_capability(CommSessionCapability capability) {
return true;
}
static int s_sys_psleep_last_millis;
void sys_psleep(int millis) {
s_sys_psleep_last_millis = millis;
}
AppMessageCtx *app_state_get_app_message_ctx(void) {
return &s_app_message_ctx;
}
bool app_message_receiver_... | (prv_out_sent_callback) | , NULL);
cl_assert_equal_p(app_message_register_outbox_failed(prv_out_failed_callback), NULL);
cl_assert_equal_p(app_message_register_inbox_dropped(prv_in_dropped_callback), NULL);
cl_assert_equal_p(app_message_register_inbox_received(prv_in_received_callback), NULL);
s_out_sent_call_count = 0;
s_out_failed_... |
es/common/comm_session/session_internal.h"
#include "services/common/comm_session/session_send_queue.h"
#include "util/math.h"
extern void comm_session_send_queue_cleanup(CommSession *session);
// Fakes & Stubs
////////////////////////////////////////////////////////////////////////////////////////////////////
#incl... | cl_assert(job) | ;
cl_assert_equal_i((i + 1) * sizeof(TEST_DATA),
comm_session_send_queue_get_length(s_valid_session));
}
}
static void prv_add_jobs(int num_jobs) {
for (int i = 0; i < num_jobs; ++i) {
SessionSendQueueJob *job = prv_create_test_job(TEST_DATA, sizeof(TEST_DATA));
comm_session_send_... |
t_layer.h"
#include "stubs_logging.h"
#include "stubs_modal_manager.h"
#include "stubs_mutex.h"
#include "stubs_notification_storage.h"
#include "stubs_notifications.h"
#include "stubs_passert.h"
#include "stubs_phone_call_util.h"
#include "stubs_prompt.h"
#include "stubs_rand_ptr.h"
#include "stubs_regular_timer.h"
#i... | {
s_in_calendar_event = false;
rtc_set_time(0);
fake_event_init();
pin_db_init();
} | |
one(&tz);
uint8_t num_net_allocs = fake_pbl_malloc_num_net_allocs();
for (unsigned int i = 0; i < ARRAY_LENGTH(s_items); ++i) {
cl_assert_equal_i(pin_db_insert_item(&s_items[i]), 0);
}
cl_assert_equal_i(fake_pbl_malloc_num_net_allocs(), num_net_allocs);
}
void test_timeline__cleanup(void) {
fake_settings... | (&state.pin.header.id, &s_items[0].header.id) | );
}
void test_timeline__none_backwards(void) {
Iterator iterator = {0};
TimelineIterState state = {0};
TimelineNode *head = NULL;
timeline_init(&head);
cl_assert_equal_i(timeline_iter_init(&iterator, &state, &head, TimelineIterDirectionPast,
1421178000), 2);
}
void test_timeline__middle_forwards(void) ... |
_UINT16:
{
*((uint16_t*)location) = (uint16_t)CLIP(val, 0, UINT16_MAX);
return;
}
case ANALYTICS_METRIC_ELEMENT_TYPE_UINT32:
{
*((uint32_t*)location) = (uint32_t)CLIP(val, 0, UINT32_MAX);
return;
}
case ANALYTICS_METRIC_ELEMENT_TYPE_INT8:
{
*((int8_t*)location) = (int8_... | analytics_heartbeat_set(hb, ANALYTICS_APP_METRIC_BLOB_VERSION,
ANALYTICS_APP_HEARTBEAT_BLOB_VERSION) | ;
return hb;
}
void analytics_heartbeat_clear(AnalyticsHeartbeat *heartbeat) {
AnalyticsHeartbeatKind kind = heartbeat->kind;
uint32_t size = sizeof(AnalyticsHeartbeat) + analytics_heartbeat_kind_data_size(kind);
memset(heartbeat, 0, size);
heartbeat->kind = kind;
}
//////////////////
// Debug
#ifdef ANALYT... |
/*
* 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 (!WITHIN(point.x, data_row_info.min_x, data_row_info.max_x)) {
return;
} | |
clude "services/common/debounced_connection_service.h"
#include "services/common/ecompass.h"
#include "services/common/event_service.h"
#include "services/common/evented_timer.h"
#include "services/common/firmware_update.h"
#include "services/common/i18n/i18n.h"
#include "services/common/light.h"
#include "services/com... | {
// mask the app task if we're already animating
e->task_mask |= 1 << PebbleTask_App;
return;
} |
const bool is_modal_focused = (modal_manager_get_enabled() &&
!(modal_manager_get_properties() & ModalProperty_Unfocused));
if (is_modal_focused) {
// mask the app task if a modal is on top
e->task_mask |= 1 << PebbleTask_App;
modal_manager_handle_button_event(e);
... |
set_table(Codepoint codepoint, FontCache *font_cache,
const FontResource *font_res) {
const int table_id = prv_offset_table_get_id(&font_res->md, codepoint);
if (table_id == font_cache->offset_table_id) {
return font_cache->offset_table_size;
}
size_t num_bytes, offset, num... | {
max_idx = mid_idx - 1;
} | else {
offset = prv_offset_table_get_offset(font_cache, &font_res->md, mid_idx);
break;
}
}
return offset;
}
static uint32_t prv_get_glyph_data_offset(Codepoint codepoint, FontCache *font_cache,
const FontResource *font_res) {
const uint32_t offset = pr... |
spi == SPI5) {
bus->state->spi_clock_periph = RCC_APB2Periph_SPI5;
bus->state->spi_clock_periph_speed = clocks.PCLK2_Frequency;
bus->state->spi_apb = SpiAPB_2;
#endif
#ifdef SPI6
} else if (bus->spi == SPI6) {
bus->state->spi_clock_periph = RCC_APB2Periph_SPI6;
bus->state->spi_clock_periph_speed =... | (bus->state->spi_clock_periph, ENABLE) | ;
// Release SPIx from reset state
RCC_APB1PeriphResetCmd(bus->state->spi_clock_periph, DISABLE);
} else if (bus->state->spi_apb == SpiAPB_2) {
// Enable SPIx reset state
RCC_APB2PeriphResetCmd(bus->state->spi_clock_periph, ENABLE);
// Release SPIx from reset state
RCC_APB2PeriphResetCmd(bus->... |
);
}
static void prv_drain_fifo(void) {
// we can't drain the fifo if we are in low power mode so we have
// to temporarily enter normal mode
bool was_low_power = (s_accel_power_mode == BMI160_Accel_Mode_Low);
if (was_low_power) {
bmi160_set_accel_power_mode(BMI160_Accel_Mode_Normal);
}
// get the FIF... | (BMI160_REG_INT_OUT_CTRL, int_cfg, int_mask) | ;
BMI160_DBG("INT_OUT_CTRL = 0x%"PRIx8, bmi160_read_reg(BMI160_REG_INT_OUT_CTRL));
}
}
void bmi160_init(void) {
gpio_input_init(&BOARD_CONFIG_ACCEL.accel_int_gpios[0]);
gpio_input_init(&BOARD_CONFIG_ACCEL.accel_int_gpios[1]);
exti_configure_pin(BOARD_CONFIG_ACCEL.accel_ints[0], ExtiTrigger_Rising,
b... |
Window window;
TestPattern test_pattern;
#if MFG_INFO_RECORDS_TEST_RESULTS
Window results_window;
MfgResultsUI results_ui;
#endif
} AppData;
static void prv_draw_solid(Layer *layer, GContext *ctx, GColor color) {
graphics_context_set_fill_color(ctx, color);
graphics_fill_rect(ctx, &layer->bounds);
}
stat... | (layer, ctx, GColorWhite) | ;
break;
case TestPattern_Crosshair:
prv_draw_crosshair_screen(layer, ctx, 0);
break;
#if PBL_COLOR
case TestPattern_Red:
prv_draw_solid(layer, ctx, GColorRed);
break;
case TestPattern_Green:
prv_draw_solid(layer, ctx, GColorGreen);
break;
case TestPattern_Blue:
prv_draw_solid(la... |
rt(s_erase_poll_timer, remaining_ms, prv_flash_erase_timer_cb, NULL, 0);
}
}
static void prv_flash_erase_async(
uint32_t sector_addr, bool is_subsector, FlashOperationCompleteCb on_complete_cb,
void *context) {
uint32_t remaining_ms = prv_flash_erase_start(sector_addr, on_complete_cb,
... | if (do_protect) {
status = flash_impl_write_protect(
FLASH_REGION_SAFE_FIRMWARE_BEGIN,
(FLASH_REGION_SAFE_FIRMWARE_END - SECTOR_SIZE_BYTES));
} else {
status = flash_impl_unprotect();
} |
PBL_ASSERT(PASSED(status), "flash_prf_set_protection failed: %" PRId32, status);
mutex_unlock(s_flash_lock);
}
#if 0
void flash_erase_bulk(void) {
mutex_lock(s_flash_lock);
flash_impl_erase_bulk_begin();
while (flash_impl_erase_is_in_progress()) {
psleep(10);
}
mutex_unlock(s_flash_lock);
}
#endif
... |
{
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
return heap_zalloc(task_heap_get_for_current_task(), size, saved_lr);
} |
void *task_zalloc_check(size_t bytes) {
register uintptr_t lr __asm("lr");
uintptr_t saved_lr = lr;
Heap *heap = task_heap_get_for_current_task();
void *mem = heap_zalloc(heap, bytes, saved_lr);
if (!mem && bytes != 0) {
PBL_CROAK_OOM(bytes, saved_lr, heap);
}
return mem;
}
void *task_calloc(size... | |
ions and
* limitations under the License.
*/
#include "property_animation_legacy2.h"
#include "applib/ui/property_animation.h"
#include "applib/ui/animation_timing.h"
#include "applib/ui/layer.h"
#include "kernel/pbl_malloc.h"
#include "system/passert.h"
#include "system/logging.h"
/////////////////////
// Proper... | {
property_animation->values.to.int16 = to_value ? *((int16_t*)to_value)
: implementation->accessors.getter.int16(subject);
property_animation->values.from.int16 = from_value ? *((int16_t*)from_value)
: implementation->accessors.get... | else if (property_animation->animation.implementation->update
== (AnimationLegacy2UpdateImplementation) property_animation_legacy2_update_gpoint
|| property_animation->animation.implementation->update
== (AnimationLegacy2UpdateImplementation) property_animation_update_gpoint) {
... |
a stream being sent via accessory_send_stream()
static volatile AccessoryDataStreamCallback s_stream_cb;
//! Context passed to accessory_send_stream()
static void *s_stream_context;
//! Semaphore used for accessory_send_stream()
static SemaphoreHandle_t s_send_semaphore;
//! Mutex used for accessory_block() / accessor... | (InhibitorAccessory) | |
ceDiscovery;
if (s_reserved_read_mbuf) {
// already a read in progress
return;
}
s_reserved_read_mbuf = mbuf_get(s_read_buffer, sizeof(s_read_buffer), MBufPoolSmartstrap);
SmartstrapResult result = prv_do_send(GenericServiceTypeRead, service_id, attribute_id, NULL,
... | if (app_id == INSTALL_ID_INVALID) {
PBL_LOG(LOG_LEVEL_DEBUG, "Attempting to launch an invalid app");
return false;
} |
app_manager_put_launch_app_event(&(AppLaunchEventConfig) {
.id = app_id,
.common.reason = APP_LAUNCH_SMARTSTRAP,
});
} else if (attr == ControlServiceAttributeButtonEvent) {
// TODO: PBL-38311
return false;
} else {
WTF;
}
return true;
}
static bool prv_read_complete(bool succe... |
PBL_LOG(LOG_LEVEL_DEBUG, "Raw DOWN");
}
text_layer_set_text(&data->text, data->text_buffer);
toggle_color(window);
(void)recognizer;
}
static void raw_up_click_handler(ClickRecognizerRef recognizer, Window *window) {
raw_click_handler(recognizer, window, true);
}
static void raw_down_click_handler(Clic... | window_set_user_data(window, data) | ;
window_set_window_handlers(window, &(WindowHandlers) {
.load = prv_window_load,
});
window_set_click_config_provider(window, (ClickConfigProvider) config_provider);
const bool animated = true;
app_window_stack_push(window, animated);
}
////////////////////
// App boilerplate
static void handle_init(vo... |
amples(void *data) {
uint8_t src_reg;
lis3dh_read(LIS3DH_FIFO_SRC_REG, 1, &src_reg);
uint8_t num_samples = src_reg & FSS_MASK;
AccelRawData accel_raw_data[num_samples];
if (src_reg & FIFO_OVRN) {
PBL_LOG(LOG_LEVEL_ERROR, "Fifo overrun");
analytics_inc(ANALYTICS_DEVICE_METRIC_ACCEL_FIFO_OVERRUN_COUNT,... | if (lis3dh_get_fifo_mode() == MODE_STREAM) {
return (-2);
} |
accel_get_data((AccelRawData*)data, 1);
return (0);
}
// Compute and return the device's delta position to help determine movement as idle.
static uint32_t prv_compute_delta_pos(AccelRawData *cur_pos, AccelRawData *last_pos) {
return abs(last_pos->x - cur_pos->x) + abs(last_pos->y - cur_pos->y) + abs(last_po... |
s, value);
} else {
prv_update_stats(&weekday_stats, value);
}
prv_update_stats(&daily_stats, value);
}
// ----------------------------------------
// Compute each combination of agg/stat and compare to expected
for (HealthAggregation agg = HealthAggregationSum; agg <= HealthAggregationMax; ... | (min_value, 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... | gdraw_command_list_scale_stroke_width(
list, data->stroke_width.from, data->stroke_width.to,
data->stroke_width.from_op, data->stroke_width.to_op, stroke_width_progress) | ;
if (delay_ctx.owns_lookup) {
applib_free(index_lookup);
}
}
static GPoint prv_calc_bounce_offset(GRect from, GRect to, int16_t bounce) {
GPoint bounce_offset = GPointZero;
const int16_t delta_x = to.origin.x - from.origin.x;
const int16_t delta_y = to.origin.y - from.origin.y;
if (!delta_x && !del... |
f_free(s_read_header_mbuf);
s_read_header_mbuf = NULL;
SmartstrapResult result = SmartstrapResultOk;
if (!success) {
result = SmartstrapResultTimeOut;
} else if ((length < sizeof(FrameInfo)) ||
(header->length != length - sizeof(FrameInfo)) ||
(header->length > data_length) ||
(header->ver... | {
prv_send_service_discovery(NULL);
s_last_service_discovery_time = current_time;
return true;
} |
return false;
}
static void prv_read_aborted(void) {
mbuf_free(s_read_header_mbuf);
s_read_header_mbuf = NULL;
mbuf_free(s_reserved_read_mbuf);
s_reserved_read_mbuf = NULL;
}
const SmartstrapProfileInfo *smartstrap_generic_service_get_info(void) {
static const SmartstrapProfileInfo s_generic_service_info... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (data, ((uint8_t*) s_timezone_database) + start_offset, num_bytes) | |
----------------------------------------------------------------------------------------------
void accel_session_shake_subscribe(AccelServiceState * session, AccelTapHandler handler) {
AccelServiceState *state = (AccelServiceState *)session;
state->shake_handler = handler;
event_service_client_subscribe(&state-... | (samples_per_update * sizeof(AccelRawData)) | ;
if (!state->raw_data) {
APP_LOG(LOG_LEVEL_ERROR, "Not enough memory to subscribe");
state->raw_data = old_buf;
return -1;
}
state->samples_per_update = samples_per_update;
int result = sys_accel_manager_set_sample_buffer(state->manager_state, state->raw_data,
... |
_graphics_get_gcontext();
const GRect rect = prv_grect_from_precise(&prect);
func(ctx, &rect);
return jerry_create_undefined();
}
JERRY_FUNCTION(prv_fill_rect) {
return prv_rect_call(argc, argv, graphics_fill_rect);
}
static void prv_draw_rect_impl(GContext *ctx, const GRectPrecise *rect) {
GRectPrecise adj... | jerry_create_undefined() | ;
}
JERRY_FUNCTION(prv_save) {
Context2DStoredState *const new_head = task_zalloc(sizeof(*new_head));
new_head->draw_state = rocky_api_graphics_get_gcontext()->draw_state;
list_insert_before(&s_canvas_context_2d_stored_states->node, &new_head->node);
s_canvas_context_2d_stored_states = new_head;
return jerry... |
/*
* 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_is_pebble_app_connected() | ) {
new_connectivity_icon_id = RESOURCE_ID_CONNECTIVITY_BLUETOOTH_DISCONNECTED;
} else if (alert_mask != AlertMaskAllOn) {
if (alert_mask == AlertMaskPhoneCalls) {
new_connectivity_icon_id = RESOURCE_ID_CONNECTIVITY_BLUETOOTH_CALLS_ONLY;
}
} else if (prv_is_pebble_app_connected()) {
new_connec... |
_PER_WEEK);
cleanup:
prv_file_close_and_unlock(&file);
return rv;
}
// ----------------------------------------------------------------------------------------------
void alarm_set_enabled(AlarmId id, bool enable) {
SettingsFile file;
if (!prv_file_open_and_lock(&file)) {
return;
}
AlarmConfig config... | prv_file_open_and_lock(&file) | |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | prv_initialize_icons() | ;
}
void test_menu_layer_system_cells__cleanup(void) {
free(fb);
fb = NULL;
gbitmap_deinit(&s_tictoc_icon_bitmap);
gbitmap_deinit(&s_smart_alarm_icon_bitmap);
gbitmap_destroy(s_dest_bitmap);
s_dest_bitmap = NULL;
}
// Helpers
//////////////////////
// This struct represents the data for a column of the... |
de "golf_resources.h"
//! TODO: Fixme once i18n support is available for 3rd party apps
#define i18n_get(a, b) a
#define i18n_free_all(data)
enum {
GOLF_FRONT_KEY = 0x0, // TUPLE_CSTRING
GOLF_MID_KEY = 0x1, // TUPLE_CSTRING
GOLF_BACK_KEY = 0x2, // TUPLE_CSTRING
GOLF_HOLE_KEY = 0x3, // TUPLE_CSTRING
GOLF_PAR... | graphics_draw_pixel(ctx, p0) | ;
}
even = !even;
p0.x += delta.x;
p0.y += delta.y;
--length;
}
}
static void background_update_proc(Layer *layer, GContext *ctx) {
GRect bounds = layer_get_bounds(layer);
// Draw lines to contain 'hole' and 'par' sections.
// Magic numbers measured from design spec
const int16_t vertica... |
fd;
status_t rv = settings_file_open(&fd, BT_PERSISTENT_STORAGE_FILE_NAME,
BT_PERSISTENT_STORAGE_FILE_SIZE);
if (rv != S_SUCCESS) {
goto cleanup;
}
data_len = settings_file_get_len(&fd, key, key_len);
// If a big enough buffer wasn't passed in, then the d... | settings_file_exists(&fd, &id, sizeof(id)) | ) {
free_key = id;
break;
}
}
settings_file_close(&fd);
}
cleanup:
prv_unlock();
return free_key;
}
static bool prv_any_pinned_ble_pairings_itr(SettingsFile *file,
SettingsRecordInfo *info,
void *context... |
G;
uint32_t CACHE_MRM_MISSES_REG;
uint32_t CACHE_MRM_CTRL_REG;
uint32_t CACHE_MRM_TINT_REG;
uint32_t CACHE_MRM_THRES_REG;
uint32_t SWD_RESET_REG;
} AllRegisters;
static AllRegisters ALL_REGISTERS;
#endif // DEFAULT_REGISTER_DEBUG
void default_registers_restore(void) {
DCDC->DCDC_CTRL_0_REG = 0x2f24... | REG_SETF(DCDC, DCDC_VDD_0_REG, DCDC_VDD_VOLTAGE, 0x10) | ;
REG_SETF(DCDC, DCDC_VDD_0_REG, DCDC_VDD_CUR_LIM_MAX_HV, 0x18);
REG_SETF(DCDC, DCDC_VDD_0_REG, DCDC_VDD_CUR_LIM_MIN, 0x4);
REG_SETF(DCDC, DCDC_VDD_1_REG, DCDC_VDD_ENABLE_HV, 0x1);
REG_SETF(DCDC, DCDC_VDD_1_REG, DCDC_VDD_ENABLE_LV, 0x1);
REG_SETF(DCDC, DCDC_VDD_1_REG, DCDC_VDD_CUR_LIM_MAX_LV, 0xB);
REG_SET... |
lled from lis3dh_read/accel_write)
uint8_t mode;
if (!prv_read_register(LIS3DH_FIFO_CTRL_REG, &mode)) {
return;
}
if (mode != MODE_BYPASS) {
uint8_t fifo_ctrl_reg = mode & ~MODE_MASK;
fifo_ctrl_reg |= (MODE_BYPASS & MODE_MASK);
if (!prv_write_register(LIS3DH_FIFO_CTRL_REG, fifo_ctrl_reg)) {
... | (I2C_LIS3DH) | ;
s_running = true;
return true;
}
void accel_stop(void) {
PBL_ASSERTN(s_initialized);
if (s_running) {
disable_accel_interrupts();
clear_accel_interrupts();
i2c_release(I2C_LIS3DH);
enable_accel_interrupts();
s_running = false;
}
}
void lis3dh_init_mutex(void) {
s_accel_mutex = m... |
/*
* 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 (task == PebbleTask_App) {
event_queue = app_manager_get_task_context()->to_process_event_queue;
} else if (task == PebbleTask_Worker) {
event_queue = worker_manager_get_task_context()->to_process_event_queue;
} else if (task == PebbleTask_KernelMain) {
// The event service always runs from KernelMai... |
// Subscribe to the service!
PebbleEvent event = {
.type = PEBBLE_SUBSCRIPTION_EVENT,
.subscription = {
.subscribe = true,
.task = task,
.event_queue = event_queue,
.event_type = handler->type,
},
};
if (task == PebbleTask_KernelMain) {
// The client is also KernelMain,... |
ayload unsupported = {
.min_supported_version = POSTMESSAGE_PROTOCOL_MAX_VERSION + 1,
.max_supported_version = POSTMESSAGE_PROTOCOL_MAX_VERSION + 1,
.max_tx_chunk_size = POSTMESSAGE_PROTOCOL_MAX_TX_CHUNK_SIZE,
.max_rx_chunk_size = POSTMESSAGE_PROTOCOL_MAX_RX_CHUNK_SIZE,
};
RCV_APP_MESSAGE(TupletByte... | {
prv_init_and_goto_awaiting_reset_complete_remote_initiated();
RCV_RESET_COMPLETE();
cl_assert_equal_i(rocky_api_app_message_get_state(), PostMessageStateSessionOpen);
} |
void test_rocky_api_app_message__session_open__rcv_reset_request(void) {
prv_init_and_goto_session_open();
EXECUTE_SCRIPT("var isCalled = false;"
"_rocky.on('postmessagedisconnected', function() { isCalled = true; });");
ASSERT_JS_GLOBAL_EQUALS_B("isCalled", false);
RCV_RESET_REQUEST();
... |
he timeout from KernelBG
ReadCompleteContext context = {
.success = false,
.is_notify = true
};
system_task_add_callback(prv_read_complete_system_task_cb, context.context_ptr);
}
}
void prv_schedule_notify_timeout(void *context) {
// make sure there's still a notification pending
if (smar... | (LOG_LEVEL_WARNING, "Failed to change smartstrap FSM state (%d)",
smartstrap_fsm_state_get()) | ;
return SmartstrapResultBusy;
}
// We are now be in a state which allows us to freely modify static variables as we can be sure
// that no ISR or other tasks will be allowed to access or modify them while we are in this
// state.
accessory_disable_input();
// NOTE: Accessory input will be re-enabled b... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
fake_event_reset_count();
fake_event_clear_last();
} |
PebbleEvent fake_event_get_last(void) {
return s_last_pebble_event;
}
void fake_event_clear_last(void) {
void **buf = fake_event_get_buffer(&s_last_pebble_event);
if (buf && *buf) {
kernel_free(*buf);
*buf = NULL;
}
s_last_pebble_event = (PebbleEvent) {};
}
void fake_event_reset_count(void) {
s... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (global_lock) | ) {
mutex_unlock(global_lock);
}
}
void stupid_timeout() {
if (!mutex_lock_with_timeout(global_lock)) {
mutex_unlock(global_lock);
}
}
void reversal() {
mutex_lock(global_lock);
mutex_lock(global_lock2);
mutex_unlock(global_lock);
mutex_unlock(global_lock2);
}
// Trying to repro the false pos... |
// ---------------------------------------------------------------------------------------
// Callback called by the algorithm. This collects stats from an epoch
static void prv_stats_cb(uint32_t num_stats, const char **names, int32_t *values) {
if (s_stats_num_columns == 0) {
// Save the column names if this ... | MIN(num_samples_left, KALG_SAMPLE_HZ * SECONDS_PER_MINUTE) | ;
uint32_t steps;
uint32_t consumed_samples;
steps = kalg_analyze_samples(s_kalg_state, data, chunk_size, &consumed_samples);
minute_steps += steps;
total_steps += steps;
if (chunk_size == KALG_SAMPLE_HZ * SECONDS_PER_MINUTE) {
// Capture the minute data for each minute
TestMinuteDa... |
/*
* 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... | while (SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_TXE) == RESET) {} | |
e_in_region(0, pfs_get_size()));
// delete every page and make sure pfs is active
for (int i = 0; i < num_pages(); i++) {
snprintf(file_name, sizeof(file_name), "file%d", i);
cl_assert(pfs_remove(file_name) == S_SUCCESS);
}
cl_assert(pfs_active_in_region(0, pfs_get_size()));
// continuation page on ... | for (int i = 0; i < original_page_count; i++) {
snprintf(file_small, sizeof(file_small), "file%d", i);
snprintf(buf, sizeof(buf), "This is small buf %d!", i);
int len = strlen(buf);
char rbuf[len];
int fd = pfs_open(file_small, OP_FLAG_READ, FILE_TYPE_STATIC, 0);
cl_assert(fd >= 0);
cl_asser... |
}
static uint32_t s_watch_file_callback_called_count = 0;
static void prv_file_changed_callback(void *data) {
s_watch_file_callback_called_count++;
}
void test_pfs__watch_file_callbacks(void) {
const char* file_name = "newfile";
PFSCallbackHandle cb_handle = pfs_watch_file(file_name, prv_file_changed_callback... |
nterrupt for writing
bus->i2c->CR2 |= I2C_CR2_ITBUFEN;
bus->transfer.state = TRANSFER_STATE_WRITE_DATA;
}
break;
case TRANSFER_STATE_REPEAT_START:
// Generate a repeat start
bus->i2c->CR1 |= I2C_CR1_START;
bus->transfer.state = TRANSFER_STATE_WRITE_ADDRESS_RX;
br... | if (bus->transfer.state == TRANSFER_STATE_WAIT_FOR_DATA) {
bus->transfer.state = TRANSFER_STATE_WRITE_ADDRESS_RX;
return pause_transfer_irq(bus);
}
else if (bus->transfer.state == TRANSFER_STATE_WRITE_REG_ADDRESS){
bus->transfer.state = TRANSFER_STATE_WRITE_ADDRESS_TX;
return pause_trans... |
}
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(&i2c_buse... |
tics/analytics.h"
#include "services/common/analytics/analytics_metric.h"
#include "services/common/analytics/analytics_storage.h"
#include "system/logging.h"
#include "system/passert.h"
static PebbleRecursiveMutex *s_analytics_storage_mutex = NULL;
static AnalyticsHeartbeat *s_device_heartbeat = NULL;
static Analyti... | {
PBL_ASSERTN(client == AnalyticsClient_Ignore || client != AnalyticsClient_System);
const Uuid uuid_system = UUID_SYSTEM;
if (!uuid) {
uuid = analytics_uuid_for_client(client);
if (!uuid) {
// There is a brief period of time where no app is running, which we
// attribute to the ... |
default:
WTF;
}
}
|
ed_area_service_will_change(from_area.size.h, to_area.size.h);
fake_event_service_handle_last();
cl_assert_equal_i(s_data.num_will_change_calls, 1);
const GRect to_area_expected = GRect(0, 0, DISP_COLS, MIN(200, DISP_ROWS));
cl_assert_equal_grect(s_data.last_will_change_final_area, to_area_expected);
}
void te... | (fake_event_service_get_info(PEBBLE_UNOBSTRUCTED_AREA_EVENT)->handler) | ;
cl_assert_equal_p(app_state_get_unobstructed_area_state()->handlers.did_change, prv_did_change);
const GRect from_area = GRect(0, 0, DISP_COLS, 400);
const GRect to_area = GRect(0, 0, DISP_COLS, 200);
unobstructed_area_service_will_change(from_area.size.h, to_area.size.h);
fake_event_service_handle_last();... |
&data->pin_window.item_detail_layer;
timeline_layout_transition_card_to_pin(item_layer->timeline_layout, pin_timeline_layout);
}
#endif
// animate the timeline layer from the left
Layer *layer = &data->timeline_layer.layer;
GPoint from_origin = { -layer->bounds.size.w, 0 };
Animation *layer_in = (Animati... | timeline_layer_set_sidebar_width(&s_app_data->timeline_layer,
timeline_layer_get_ideal_sidebar_width()) | ;
}
#endif
}
static void NOINLINE prv_deinit(void) {
prv_cleanup_timer(&s_app_data->intro_timer_id);
prv_cleanup_timer(&s_app_data->inactive_timer_id);
event_service_client_unsubscribe(&s_app_data->focus_event_info);
event_service_client_unsubscribe(&s_app_data->blobdb_event_info);
timeline_layer_deinit(... |
dField;
typedef bool (*SearchCallback)(PersistMapIdField *field, void *data);
static const uint16_t PERSIST_MAP_VERSION = 1;
// Start off with a file which can hold 256 UUIDs
#define PMAP_FILE_SIZE \
((sizeof(PersistMapHeader) + sizeof(PersistMapIdField)) * 256)
static const char *s_map_filename = "pmap";
#if IS... | pfs_write(new_fd, buf, bytes_to_read) | |
'u', 'b', 't', 'i', 't', 'l', 'e',
};
const size_t app_glance_with_slice_missing_expiration_time_size =
sizeof(app_glance_with_slice_missing_expiration_time);
cl_assert_equal_i(app_glance_db_insert((uint8_t *)&APP_GLANCE_TEST_UUID, UUID_SIZE,
(uint8_t *)&app_glance_... | {
time_t time_out;
// Reading the creation time of a glance that doesn't exist should return "does not exist"
cl_assert_equal_i(app_glance_db_read_creation_time(&APP_GLANCE_TEST_UUID, &time_out),
E_DOES_NOT_EXIST);
// Insert a glance and check that the creation time we read back matches
... |
void test_app_glance_db__read_glance_creation_time_with_invalid_arguments_fails(void) {
// NULL UUID fails
time_t time_out;
cl_assert_equal_i(app_glance_db_read_creation_time(NULL, &time_out), E_INVALID_ARGUMENT);
// NULL time_out fails
cl_assert_equal_i(app_glance_db_read_creation_time(&APP_GLANCE_TEST_UU... |
/*
* 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_get_current_context() | ;
TextLayoutExtended layout = { 0 };
graphics_text_attributes_enable_screen_text_flow((GTextLayoutCacheRef) &layout,
TEXT_FLOW_INSET_PX);
return graphics_text_layout_get_max_used_size(ctx,
text,
... |
>animation, &count);
Animation *anim = property_animation_get_animation(transcription_dialog->animation);
animation_set_duration(anim, (count - begin) * CHARACTER_DELAY);
animation_set_curve(anim, AnimationCurveEaseInOut);
// Text is shown if creating the property animation fails
*transcription_dialog->zer... | PBL_ASSERTN(transcription_dialog) | ;
transcription_dialog->callback = callback;
transcription_dialog->callback_context = callback_context;
}
void transcription_dialog_keep_alive_on_select(TranscriptionDialog *transcription_dialog,
bool keep_alive_on_select) {
PBL_ASSERTN(transcription_dialog);
tran... |
UNKNOWN_APP_TYPE,
APP_TYPE_MASK = 0x1,
} CustomizableAppType;
typedef enum {
NAME_FIELD = 0x00,
ICON_FIELD = 0x80,
FIELD_MASK = 0x80,
} FieldId;
typedef struct PACKED {
//! OR'ed value of (CustomizableAppType | FieldId). No C bitfields here, because order is compiler-specific.
uint8_t app_type_and_field... | if (app_type != UNKNOWN_APP_TYPE && s_info[app_type].name != NULL) {
name = s_info[app_type].name;
} else {
return NULL;
} |
return name;
}
const GBitmap *app_custom_get_icon(AppInstallId app_id) {
CustomizableAppType app_type = get_app_type_for_app_id(app_id);
if (app_type != UNKNOWN_APP_TYPE && s_info[app_type].image_data != NULL) {
return &s_info[app_type].icon;
}
return 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... | cl_assert(child_a.next_sibling == &child_c) | ;
cl_assert(grand_child_a.parent == &child_a);
cl_assert(child_c.parent == &parent);
// Remove first-child (child_a):
//
// +-parent
// |
// '->child_c
//
// +-child_a
// |
// '->grand_child_a
//
layer_remove_from_parent(&child_a);
cl_assert(parent.first_child == &child_... |
eing unused.
PBL_LOG(LOG_LEVEL_INFO, "No intent for connection");
bluetooth_analytics_handle_no_intent_for_connection();
}
#if RECOVERY_FW
// In PRF, stick to shortest connection interval indefinitely:
conn_mgr_set_ble_conn_response_time(connection, BtConsumerPRF,
... | {
fp(intent, data);
} |
intent = next;
}
}
// -------------------------------------------------------------------------------------------------
//! Helper for prv_handle_encryption_change
static void prv_send_clients_encrypted_event(GAPLEConnectionIntent *intent, void *unused_data) {
prv_update_clients(intent, HciStatusCode_Success... |
/*
* 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... | (int8_t, sys_ble_get_advertising_tx_power, void) | {
return gap_le_advert_get_tx_power();
}
// -----------------------------------------------------------------------------
// ble_central.h
DEFINE_SYSCALL(BTErrno, sys_ble_central_connect, BTDeviceInternal device,
bool auto_reconnect, bool is_pairing_required) {
return gap_le_connect_connect(&devic... |
/*
* 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... | (RCC->AHB1ENR, (0x1 << idx)) | ;
}
}
|
alse /* expect_can_handle */);
}
void test_ams__cannot_handle_unknown_characteristic(void) {
prv_discover_ams(1);
cl_assert_equal_b(ams_can_handle_characteristic(s_unknown_characteristic), false);
}
void test_ams__discover_of_ams_should_subscribe_to_entity_update_characteristic(void) {
// Pass in 2 instances, i... | (ams_is_registered_for_all_entity_updates(), false) | ;
// Expect to have written the command to register for the Queue entity:
fake_gatt_client_op_assert_write(entity_update, s_register_queue_entity,
sizeof(s_register_queue_entity), GAPLEClientKernel,
true /* is_response_required */);
ams_handle... |
gpath_destroy(s_duplicates_path);
gpath_destroy(s_infinite_path);
gpath_destroy(s_crossing_path);
gpath_destroy(s_aa_clipping_path);
}
// tests
void test_graphics_gpath_${BIT_DEPTH_NAME}__filled(void) {
GContext ctx;
Layer layer;
prv_reset();
s_current_path = s_house_path;
test_graphics_context_ini... | (&ctx, fb) | ;
graphics_context_set_antialiased(&ctx, true);
prv_filled_update_proc(NULL, &ctx);
cl_check(gbitmap_pbi_eq(&ctx.dest_bitmap, "gpath_filled_aa.${BIT_DEPTH_NAME}.pbi"));
// Special case for two points that are duplicates...
prv_reset();
test_graphics_context_init(&ctx, fb);
s_current_path = s_single_dupli... |
izeof(AS7000InfoRecord))) {
return false;
}
if (log_version) {
// print out the version information
PBL_LOG(LOG_LEVEL_INFO, "AS7000 enabled! Protocol v%" PRIu8 ".%" PRIu8
", SW v%" PRIu8 ".%" PRIu8 ".%" PRIu8 ", HW Rev %" PRIu8,
info->protocol_version_major, info->protocol_version_min... | gpio_output_set(&dev->en_gpio, true) | ;
dev->state->enabled_state = HRMEnabledState_PoweringOn;
dev->state->handshake_count = 0;
new_timer_start(dev->state->timer, NORMAL_BOOT_DELAY_MS, prv_enable_timer_cb, (void *)dev,
0 /* flags */);
interval_timer_init(&s_handshake_interval_timer, 900, 1100, 8);
PBL_LOG(LOG_LEVE... |
/cache.h"
#include "popups/timeline/peek.h"
#include "process_management/app_manager.h"
#include "process_management/process_manager.h"
#include "process_state/app_state/app_state.h"
#include "system/logging.h"
#include "system/passert.h"
#include "system/profiler.h"
#include "util/size.h"
// The number of pixels for ... | ARRAY_LENGTH(s_rounded_corner_width) | ) {
return s_rounded_corner_width[row_index];
} else if (num_rows - row_index - 1 < (int)ARRAY_LENGTH(s_rounded_corner_width)) {
return s_rounded_corner_width[num_rows - row_index - 1];
}
return 0;
}
void compositor_set_modal_transition_offset(GPoint modal_offset) {
s_animation_state.modal_offset = mod... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | (BUTTON_ID_UP, prv_up_click_handler) | ;
window_single_click_subscribe(BUTTON_ID_DOWN, prv_down_click_handler);
}
void mfg_results_ui_init(MfgResultsUI *results_ui, MfgTest test, Window *window) {
GRect bounds = window->layer.bounds;
bounds.size.w -= 5;
bounds.size.h = 40;
bounds.origin.y += 5;
TextLayer *pass = &results_ui->pass_text_layer;
... |
;
free(command);
}
void test_gdraw_command__draw_precise_path(void) {
GDrawCommand *command = malloc(sizeof(GDrawCommand) + (sizeof(GPoint) * 3 ));
*command = (GDrawCommand){
.type = GDrawCommandTypePrecisePath,
.hidden = false,
.stroke_color = GColorRed,
.stroke_width = 1,
.fill_color = ... | cl_assert(prv_compare_points(¢er, s_stroke_points, s_path_num_points)) | |
static void prv_update_aml_cache(ActionMenuLayer *aml, int selected_index) {
prv_unschedule_item_animation(aml);
if (aml->layout_cache.item_heights != NULL) {
applib_free(aml->layout_cache.item_heights);
aml->layout_cache.item_heights = NULL;
}
if (aml->num_items > 0) {
// Update the cache of heig... | if (!aml) {
return;
} |
action_menu_layer_deinit(aml);
applib_free(aml);
}
void action_menu_layer_set_align(ActionMenuLayer *aml, ActionMenuAlign align) {
if (!aml) {
return;
}
aml->layout_cache.align = align;
}
void action_menu_layer_set_items(ActionMenuLayer *aml, const ActionMenuItem* items, int num_items,
... |
00},
{10, 3640},
{20, 3690},
{30, 3730},
{40, 3750},
{50, 3790},
{60, 3840},
{70, 3910},
{80, 4000},
{90, 4120},
{100, 4250},
};
static const VoltagePoint charge_curve[] = {
{0, BATTERY_CRITICAL_VOLTAGE_CHARGING},
{10, 3970},
{20, 4020},
{30, 4060},
{40, 4090},
{50, 4130... | prv_lookup_percent_by_voltage(battery_mv, is_charging, 1) | ;
}
static uint32_t prv_sample_scaled_charge_percent(
uint32_t battery_mv, bool is_charging, uint32_t scaling_factor) {
int compensate = 0; // We compensate 5% during rounding, so don't do here
for (int i = 0; i < BATTERY_CURVE_COMPENSATE_COUNT; ++i) {
compensate += s_battery_compensation_values[i];
}
... |
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... | {
s_select_cb_called = true;
} | |
RACKING
HealthServiceState health_service_state;
#endif
LocaleInfo locale_info;
#if CAPABILITY_HAS_ACCESSORY_CONNECTOR
SmartstrapConnectionState smartstrap_state;
#endif
ContentIndicatorsBuffer content_indicators_buffer;
bool app_framebuffer_render_pending;
AppFocusState app_focus_state;
Unobstructe... | connection_service_state_init(app_state_get_connection_service_state()) | ;
tick_timer_service_state_init(app_state_get_tick_timer_service_state());
#if CAPABILITY_HAS_HEALTH_TRACKING
health_service_state_init(app_state_get_health_service_state());
#endif
locale_init_app_locale(app_state_get_locale_info());
content_indicator_init_buffer(app_state_get_content_indicators_buffer());... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.