Skip to content

Commit

Permalink
SDK 3.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
cpfair committed Apr 5, 2015
1 parent 9d4c93f commit 4c508e8
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 59 deletions.
38 changes: 22 additions & 16 deletions appinfo.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
{
"versionLabel": "1.2",
"uuid": "da96ea4e-7793-4301-9d9a-68714a902730",
"appKeys": {
"AMSetUTCOffset": 0,
"AMClearTokens": 5,
"AMCreateToken": 1,
"AMCreateToken_ID": 2,
"AMCreateToken_Name": 3,
"AMDeleteToken": 4,
"AMClearTokens": 5,
"AMReadTokenList": 6,
"AMReadTokenList_Result": 7,
"AMReadTokenList_Finished": 8,
"AMUpdateToken": 9,
"AMSetTokenListOrder": 10
"AMReadTokenList_Result": 7,
"AMSetTokenListOrder": 10,
"AMSetUTCOffset": 0,
"AMUpdateToken": 9
},
"longName": "Pebble Authenticator",
"versionCode": 4,
"capabilities": [
"configurable"
],
"companyName": "Public Domain",
"shortName": "Authenticator",
"watchapp": {
"watchface": false
},
"longName": "Pebble Authenticator",
"projectType": "native",
"resources": {
"media": [
{
"type": "png",
"file": "images/icon.png",
"menuIcon": true,
"name": "ICON",
"file": "icon.png",
"menuIcon": true
"type": "png"
}
]
},
"sdkVersion": "3",
"shortName": "Authenticator",
"targetPlatforms": [
"aplite",
"basalt"
],
"uuid": "da96ea4e-7793-4301-9d9a-68714a902730",
"versionCode": 4,
"versionLabel": "1.3",
"watchapp": {
"watchface": false
}
}
File renamed without changes
20 changes: 18 additions & 2 deletions src/pTOTP.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include "pebble.h"

#include "generate.h"
#include "unixtime.h"


// #define TEST_TOKEN 1

#define P_UTCOFFSET 1
#define P_TOKENS_COUNT 2
Expand Down Expand Up @@ -205,8 +207,11 @@ void show_no_tokens_message(bool show) {
void refresh_all(void){
static unsigned int lastQuantizedTimeGenerated = 0;

#ifdef PBL_PLATFORM_BASALT
unsigned long utcTime = time(NULL);
#else
unsigned long utcTime = time(NULL) - utc_offset;

#endif
unsigned int quantized_time = utcTime/30;

if (quantized_time == lastQuantizedTimeGenerated && !key_list_is_dirty) {
Expand Down Expand Up @@ -416,6 +421,17 @@ void handle_init() {
token_list_add(key);
}
}
#ifdef TEST_TOKEN
token_list_clear();
TokenInfo* key = malloc(sizeof(TokenInfo));
strcpy(key->name, "TEST TOKEN!");
key->id = 0;
void* secret = malloc(10);
memset(secret, 65, 10);
key->secret = secret;
key->secret_length = 10;
token_list_add(key);
#endif

window = window_create();
window_stack_push(window, true /* Animated */);
Expand Down
23 changes: 0 additions & 23 deletions src/unixtime.c

This file was deleted.

18 changes: 0 additions & 18 deletions src/unixtime.h

This file was deleted.

62 changes: 62 additions & 0 deletions wscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

#
# This file is the default set of rules to compile a Pebble project.
#
# Feel free to customize this to your needs.
#

import os.path
try:
from sh import CommandNotFound, jshint, cat, ErrorReturnCode_2
hint = jshint
except (ImportError, CommandNotFound):
hint = None

top = '.'
out = 'build'

def options(ctx):
ctx.load('pebble_sdk')

def configure(ctx):
ctx.load('pebble_sdk')

def build(ctx):
if False and hint is not None:
try:
hint([node.abspath() for node in ctx.path.ant_glob("src/**/*.js")], _tty_out=False) # no tty because there are none in the cloudpebble sandbox.
except ErrorReturnCode_2 as e:
ctx.fatal("\nJavaScript linting failed (you can disable this in Project Settings):\n" + e.stdout)

# Concatenate all our JS files (but not recursively), and only if any JS exists in the first place.
ctx.path.make_node('src/js/').mkdir()
js_paths = ctx.path.ant_glob(['src/*.js', 'src/**/*.js'])
if js_paths:
ctx(rule='cat ${SRC} > ${TGT}', source=js_paths, target='pebble-js-app.js')
has_js = True
else:
has_js = False

ctx.load('pebble_sdk')

build_worker = os.path.exists('worker_src')
binaries = []

for p in ctx.env.TARGET_PLATFORMS:
ctx.set_env(ctx.all_envs[p])
ctx.set_group(ctx.env.PLATFORM_NAME)
app_elf='{}/pebble-app.elf'.format(p)
ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'),
target=app_elf)

if build_worker:
worker_elf='{}/pebble-worker.elf'.format(p)
binaries.append({'platform': p, 'app_elf': app_elf, 'worker_elf': worker_elf})
ctx.pbl_worker(source=ctx.path.ant_glob('worker_src/**/*.c'),
target=worker_elf)
else:
binaries.append({'platform': p, 'app_elf': app_elf})

ctx.set_group('bundle')
ctx.pbl_bundle(binaries=binaries, js='pebble-js-app.js' if has_js else [])

0 comments on commit 4c508e8

Please sign in to comment.