Pebble Foundation Classes  0.2.0
C++ for Pebble
AppWorker

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

Collaboration diagram for AppWorker:

Classes

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

Typedefs

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

Enumerations

enum  AppWorkerResult {
  APP_WORKER_RESULT_SUCCESS = 0, APP_WORKER_RESULT_NO_WORKER = 1, APP_WORKER_RESULT_DIFFERENT_APP = 2, APP_WORKER_RESULT_NOT_RUNNING = 3,
  APP_WORKER_RESULT_ALREADY_RUNNING = 4, APP_WORKER_RESULT_ASKING_CONFIRMATION = 5, APP_WORKER_RESULT_SUCCESS = 0, APP_WORKER_RESULT_NO_WORKER = 1,
  APP_WORKER_RESULT_DIFFERENT_APP = 2, APP_WORKER_RESULT_NOT_RUNNING = 3, APP_WORKER_RESULT_ALREADY_RUNNING = 4, APP_WORKER_RESULT_ASKING_CONFIRMATION = 5
}
 Possible error codes from app_worker_launch, app_worker_kill. More...
 
enum  AppWorkerResult {
  APP_WORKER_RESULT_SUCCESS = 0, APP_WORKER_RESULT_NO_WORKER = 1, APP_WORKER_RESULT_DIFFERENT_APP = 2, APP_WORKER_RESULT_NOT_RUNNING = 3,
  APP_WORKER_RESULT_ALREADY_RUNNING = 4, APP_WORKER_RESULT_ASKING_CONFIRMATION = 5, APP_WORKER_RESULT_SUCCESS = 0, APP_WORKER_RESULT_NO_WORKER = 1,
  APP_WORKER_RESULT_DIFFERENT_APP = 2, APP_WORKER_RESULT_NOT_RUNNING = 3, APP_WORKER_RESULT_ALREADY_RUNNING = 4, APP_WORKER_RESULT_ASKING_CONFIRMATION = 5
}
 Possible error codes from app_worker_launch, app_worker_kill. More...
 

Functions

bool app_worker_is_running (void)
 
AppWorkerResult app_worker_launch (void)
 
AppWorkerResult app_worker_kill (void)
 
bool app_worker_message_subscribe (AppWorkerMessageHandler handler)
 
bool app_worker_message_unsubscribe (void)
 
void app_worker_send_message (uint8_t type, AppWorkerMessage *data)
 

Detailed Description

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

Typedef Documentation

◆ AppWorkerMessageHandler [1/2]

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
typeAn application defined message type
datapointer to message data. The receiver must know the structure of the data provided by the sender.

◆ AppWorkerMessageHandler [2/2]

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
typeAn application defined message type
datapointer to message data. The receiver must know the structure of the data provided by the sender.

Enumeration Type Documentation

◆ AppWorkerResult [1/2]

Possible error codes from app_worker_launch, app_worker_kill.

Enumerator
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.

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.

◆ AppWorkerResult [2/2]

Possible error codes from app_worker_launch, app_worker_kill.

Enumerator
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.

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.

Function Documentation

◆ app_worker_is_running()

bool app_worker_is_running ( void  )

Determine if the worker for the current app is running

Returns
true if running

◆ app_worker_kill()

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

◆ app_worker_launch()

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

◆ app_worker_message_subscribe()

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
handlerA callback to be executed when the event is received
Returns
true on success

◆ app_worker_message_unsubscribe()

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

◆ app_worker_send_message()

void app_worker_send_message ( uint8_t  type,
AppWorkerMessage data 
)

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

Parameters
typeAn application defined message type
datathe message data structure