javascript - Pebble return carriages working on emulator but not on watch -


i have pebble smartwatch watchface gets text textarea in app's config page (html page), , puts value text layer on watchface.

unfortunately there 2 things cause not work intended (hopefully they'll both solved 1 solution):

1) return carriages (eg. \n don't work on text layer, instead of moving new line displays '\n' character 2) unpaired ' (apostrophes) , " (quotation marks) don't update page (i.e don't work)

i'm not amazing @ working communication between watchface , config else seems work fine apart 1 issue. below path took getting text text area text layer.

relevant script (in config.html)

[].foreach.call(document.queryselectorall("#save"), function(e1) {                 e1.addeventlistener("click", function() {                     console.log(saveoptions());                     var return_to = getqueryparam('return_to', 'pebblejs://close#');                     document.location = return_to + encodeuricomponent(json.stringify(saveoptions()));                 });             }); 

relevant javascript (script.js)

    pebble.addeventlistener('webviewclosed', function(e) {       var options = json.parse(decodeuricomponent(e.response));       message = options.message;  var dict = {     'message_data' : message   };    //send string pebble   pebble.sendappmessage(dict, function(e) {     console.log("send successful.");   }, function(e) {     console.log("send failed!");   }); } 

relevant main.c:

static void inbox_received_callback(dictionaryiterator *iterator, void *context) {   app_log(app_log_level_info, "message received!");    // first pair   tuple *t = dict_read_first(iterator);    // process pairs present   while(t != null) {   // process pair's key     switch (t->key) {       case message_data:         snprintf(message_buffer, sizeof(message_buffer), "%s", t->value->cstring);         app_log(app_log_level_info, "message_data received value %d", (int)t->value->int32);         break;       default:         app_log(app_log_level_error, "key %d not recognized!", (int)t->key);         break;     }      // next pair, if     t = dict_read_next(iterator);   } } 

edit: adding message.replace(/[\n\r]/g, ' '); didn't work solve problem 1 :/

i think lost in translation between js , c, since c will display return carriages correctly. should consider using special character replace return carriages # or $ won't appear in actual message want send. then, iterate through character array in c , replace instances of special character \n.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -