Avatar for user149778

user149778

Member since Oct 2022 • Last active Oct 2022
  • 1 conversations
  • 1 comments

Most recent activity

  • in Bangle.js
    Avatar for user149778

    I love tinkering with the Bangle2. It's so fun.

    My goal is to write an app that opens a URL in the browser on my Android device. I was hoping the right way to do this is to send an intent with code like this. I'm unsure what the correct intent would look like, and tried a variety of ideas but none seemed to work. However, there is a weird thing in the Android ADB logs that suggest perhaps this isn't the issue anyway.

    const reddit = JSON.stringify({t:"intent",       
                                   category:"android.intent.category.DEFAUL­T", 
                                   target:"activity", 
                                   data: "https://reddit.com", 
                                   action: "android.intent.action.VIEW"});
    
    const reddit2 = JSON.stringify({
      t:"intent", 
      data: "https://reddit.com", 
      action: "ACTION_VIEW"});
    
    const reddit3 = JSON.stringify({t:"intent", data: "https://reddit.com", action: "android.intent.action.VIEW"});
    
    E.showPrompt("Open url?",{
      title:"Open URL",
      buttons : {"One":1,"Two":2,"Three": 3}
    }).then(function(v) {
      if (v===1) {
       E.showMessage("reddit");
       Bluetooth.println(reddit);
      } else if (v===2) {
       E.showMessage("reddit2");
       Bluetooth.println(reddit2);
      } else {
       E.showMessage("reddit3");
        Bluetooth.println(reddit3));
      }
    });
    

    Strangely, when I look at the android adb logs I see this:

    10-05 00:02:32.980 16912 10602 D nodomain.freeyourgadget.gadgetbridge.ser­vice.btle.BtLEQueue: characteristic changed: 6e400003-b5a3-f393-e0a9-e50e24dcca9e value: 0x7b 0x22 0x74 0x22 0x3a 0x22 0x69 0x6e2
    10-05 00:02:32.980 16912 10602 I nodomain.freeyourgadget.gadgetbridge.ser­vice.devices.banglejs.BangleJSDeviceSupp­ort: RX: {"t":"intent","data"
    10-05 00:02:32.983 16912 10602 D nodomain.freeyourgadget.gadgetbridge.ser­vice.btle.BtLEQueue: characteristic changed: 6e400003-b5a3-f393-e0a9-e50e24dcca9e value: 0x3a 0x22 0x68 0x74 0x74 0x70 0x73 0x3af
    10-05 00:02:32.983 16912 10602 I nodomain.freeyourgadget.gadgetbridge.ser­vice.devices.banglejs.BangleJSDeviceSupp­ort: RX: :"https://reddit
    10-05 00:02:32.984 16912 10602 D nodomain.freeyourgadget.gadgetbridge.ser­vice.btle.BtLEQueue: characteristic changed: 6e400003-b5a3-f393-e0a9-e50e24dcca9e value: 0x64 0x61 0x74 0x61 0x3d 0x22 0x2c 0x224
    10-05 00:02:32.985 16912 10602 I nodomain.freeyourgadget.gadgetbridge.ser­vice.devices.banglejs.BangleJSDeviceSupp­ort: RX: ","action":"ACT
    10-05 00:02:32.986 16912 10602 D nodomain.freeyourgadget.gadgetbridge.ser­vice.btle.BtLEQueue: characteristic changed: 6e400003-b5a3-f393-e0a9-e50e24dcca9e value: 0x49 0x4f 0x4e 0x5f 0x56 0x49 0x45 0x57a
    10-05 00:02:32.986 16912 10602 I nodomain.freeyourgadget.gadgetbridge.ser­vice.devices.banglejs.BangleJSDeviceSupp­ort: RX: ION_VIEW"}
    10-05 00:02:32.986 16912 10602 I nodomain.freeyourgadget.gadgetbridge.ser­vice.devices.banglejs.BangleJSDeviceSupp­ort: UART RX LINE: >{"t":"intent","data":"https://reddit.co­m","action":"ACTION_VIEW}
    10-05 00:02:32.987 16912 10602 I nodomain.freeyourgadget.gadgetbridge.ser­vice.devices.banglejs.BangleJSDeviceSupp­ort: UART RX line started with 62 - ignoring
    

    In other words, the code to receive the JSON is getting a "<" character at the front of it, which means it hits this line and does not try to parse it.

    https://github.com/gfwilliams/Gadgetbrid­ge/commit/60c7f79366f3d62df711bd0d87c333­bd8e67f11d#diff-28d26af2b02f3df362db1ead­5920145a8d90650859a256590ddf1e0926d3368b­R425

    (

    LOG.info("UART RX line started with "+(int)line.charAt(0)+" - ignoring");
    

    )

    Is there something I'm doing wrong with Bluetooth.print() or JSON.stringify() that is adding this extra character? Or, a work around?

Actions