pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • Examples
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

Pebble C API

  • Pebble C API
  • Pebble JavaScript API
  • PebbleKit JS
  • PebbleKit iOS
  • PebbleKit Android
  • Foundation
    • App
    • App Communication
    • App Glance
    • AppMessage
    • AppSync
    • AppWorker
    • DataLogging
    • DataStructures
      • UUID
    • Dictation
    • Dictionary
    • Event Service
      • AccelerometerService
      • AppFocusService
      • BatteryStateService
      • CompassService
      • ConnectionService
      • HealthService
      • TickTimerService
    • Exit Reason
    • Internationalization
    • Launch Reason
    • Logging
    • Math
    • Memory Management
    • Platform
    • Resources
      • File Formats
    • Storage
    • Timer
    • Wakeup
    • Wall Time
    • WatchInfo
    • Rocky
  • Graphics
    • Draw Commands
    • Drawing Paths
    • Drawing Primitives
    • Drawing Text
    • Fonts
    • Graphics Context
    • Graphics Types
      • Color Definitions
  • User Interface
    • Animation
      • PropertyAnimation
    • Clicks
    • Layers
      • ActionBarLayer
      • BitmapLayer
      • MenuLayer
      • RotBitmapLayer
      • ScrollLayer
      • SimpleMenuLayer
      • StatusBarLayer
      • TextLayer
    • Light
    • Preferences
    • UnobstructedArea
    • Vibes
    • Window
      • ActionMenu
      • NumberWindow
    • Window Stack
  • Standard C
    • Format
    • Locale
    • Math
    • Memory
    • String
    • Time

AppWorker

Runs in the background, and can communicate with the foreground app.

Function Documentation

bool app_worker_is_running(void)

Determine if the worker for the current app is running.

Returns

true if running

AppWorkerResult app_worker_launch(void)

Launch the worker for the current app. Note that this is an asynchronous operation, a result code of APP_WORKER_RESULT_SUCCESS merely means that the request was successfully queued up.

Returns

result code

AppWorkerResult app_worker_kill(void)

Kill the worker for the current app. Note that this is an asynchronous operation, a result code of APP_WORKER_RESULT_SUCCESS merely means that the request was successfully queued up.

Returns

result code

bool app_worker_message_subscribe(AppWorkerMessageHandler handler)

Subscribe to worker messages. Once subscribed, the handler gets called on every message emitted by the other task (either worker or app).

Parameters

handler

A callback to be executed when the event is received

Returns

true on success

bool app_worker_message_unsubscribe(void)

Unsubscribe from worker messages. Once unsubscribed, the previously registered handler will no longer be called.

Returns

true on success

void app_worker_send_message(uint8_t type, AppWorkerMessage * data)

Send a message to the other task (either worker or app).

Parameters

type

An application defined message type

data

the message data structure

Data Structure Documentation

struct AppWorkerMessage

Generic structure of a worker message that can be sent between an app and its worker.

Data Fields

uint16_t data0
uint16_t data1
uint16_t data2

Enum Documentation

enum AppWorkerResult

Possible error codes from app_worker_launch, app_worker_kill.

Enumerators

APP_WORKER_RESULT_SUCCESS

Success.

APP_WORKER_RESULT_NO_WORKER

No worker found for the current app.

APP_WORKER_RESULT_DIFFERENT_APP

A worker for a different app is already running.

APP_WORKER_RESULT_NOT_RUNNING

The worker is not running.

APP_WORKER_RESULT_ALREADY_RUNNING

The worker is already running.

APP_WORKER_RESULT_ASKING_CONFIRMATION

The user will be asked for confirmation.

Typedef Documentation

typedef void(* AppWorkerMessageHandler)(uint16_t type, AppWorkerMessage *data)

Callback type for worker messages. Messages can be sent from worker to app or vice versa.

Parameters

type

An application defined message type

data

pointer to message data. The receiver must know the structure of the data provided by the sender.

Need some help?

Functions

  • app_worker_is_running
  • app_worker_launch
  • app_worker_kill
  • app_worker_message_subscribe
  • app_worker_message_unsubscribe
  • app_worker_send_message

Data Structures

  • AppWorkerMessage

Enums

  • AppWorkerResult

Typedefs

  • AppWorkerMessageHandler

Getting Help

Do you have questions about the Pebble SDK?

Do you need some help understanding something on this page?

You can either take advantage of our awesome developer community and check out the SDK Help forums, or you can send us a message through the website!