Giter Club home page Giter Club logo

bluefruit_le_connect_android's Introduction

Bluefruit LE Connect for Android - DEPRECATED

This repository is no longer supported or maintained - for the latest version of this app go to - https://github.com/adafruit/Bluefruit_LE_Connect_Android_v2

Android port of Adafruit's Bluefruit LE Connect app for iOS.

This application works with the following Adafruit breakouts:

Bluefruit LE Connect enables the exchange of information between your Bluefruit LE breakout and your BLE enabled Android device (Android 4.4 and higher required).

The application also enables over the air updates to keep your Bluefruit module up to date with the latest Bluefruit LE firmware.

License

Unless otherwise specified, all files produced by Adafruit are covered by an MIT license.

Files produced by Nordic Semiconductors are covered by their own license terms, as detailed in the file headers and appropriate folders. Please carefully review the license requirements before using this source code in your own application.

bluefruit_le_connect_android's People

Contributors

adamwolf avatar antonio-openroad avatar bobstevens avatar ladyada avatar microbuilder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bluefruit_le_connect_android's Issues

Delete bonding information for Bluetooth device?

We recently added a 'keyboard' demo, where the Bluetooth devices advertise and function as a Bluetooth Low Energy keyboard.

The SW (though still in development) works fine, and we can send characters to iOS and Android and connect the keyboard to the mobile devices through a process called 'bonding', where the two devices pair themselves together for secure data exchange. This happens in the Bluetooth config panel, similar to how you could connect Bluetooth headphones or speakers, etc.

The problem with this process is that it breaks the DFU SW since the bonding establishes an encryption key between the two devices, but when we reset into the bootloader to do a firmware update the bootloader is not aware of this key, and so the update process fails.

The work around is to delete the bonding information (via the Bluetooth config panel) before doing the DFU update, removing the link between the phone and the Bluetooth LE device and causing the connection to no longer be encrypted.

This isn't a great user experience, though. Is it possible to delete the bonding information for the connected Bluetooth Low Energy device purely in SW? That way, we can delete the bond information for the connected device BEFORE doing the DFU update, and then the user can rebond after the firmware update.

The user still has to rebond in this case, but it's less likely to get filed as a bug report since you will more naturally thing you have to rebond after a firmware update than before.

I'm not sure if iOS or Android allow us to delete bond data in SW, though, and they may restrict this behaviour???

Display 'DATA Mode' warning in Controller Activity

When the Controller activity is started, a popup should be displayed warning users to put their device in 'DATA/UART' mode, and there should be a checkbox to disable this warning in the future.

If they are running in 'CMD' mode they won't see the data, and it's likely to end up as a support request.

Please ensure that your Bluefruit LE module is set to DATA/UART mode when using this application

Add ability to update using any .hex file over DFU

Add the ability to update the connected device's firmware with any .hex file (selected from the user's file-system or Dropbox, etc.), not just the official .hex file found on github.com.

I'm not sure where the best place for this is. Is it possible to create a base 'ConnectedSettingsActivity' that is used as the settings menu whenever we are connected to a device (meaning the Device Information, UART, Pin I/O, etc. activities), with certain config settings that are common to every 'connected' mode activity, such as the option to upload a new firmware .hex file when the DFU service is detected? And then, by inheriting this ConnectedSettingsActivity (or whatever it should be called) base class, we can implement settings specific to each connected activity, like UART specific settings, if anyway?

So: ConnectedSettingsActivity <-- UartConnectedSettingsActivity, InformationConnectedSettingsActivity, etc.

Sorry if this should realistically be two issues, but they are related since the DFU functionality using a customer selected .hex file should be implemented in the base class common to any connected activity depending on whether the DFU activity was detected or not, or if we are running in DFU mode already (you can also enter DFU mode by holding the DFU button down when inserting the device).

discontinue/archive

hiya @antonio-openroad if this repository is discontinued, lets archive it. please respond to and close all pull requests, update the readme to say its compeltely unsupported/archived and i will archive it so no more issues/PRs can be created

thanx!

Control Pad Orientation Issue

When you use the controller if you have the app open and turn the device off then turn it back on it opens to a screen without the buttons rendered.

Tested on a 2014 Moto G running Android 5.0.2, same on a Nexus 7.

screenshot_2015-02-23-11-38-27

Add Apple and Google Beacon helper activity?

Any Adafruit device with the UART service can be sent 'AT' commands to configure the device, including setting the device up as an Apple iBeacon or a Google UriBeacon via the following commands:

If the device is detected as being UART enabled, should we add a new activity to configure iBeacon and UriBeacon information from the phone?

Talking to Google, this was the biggest complaint from customers ... "How do I configure the UriBeacon once it's deployed?".

By having an activity in the Android app for these two beacon options, we can generate the AT command ourselves and send it via the UART service: +++\r\nAT+BLEBEACON=xxx\r\n+++\r\n, though we should test first if we have access to the AT Parser via AT\r\n which should response with OK\r\n.

iBeacon Requirements

iBeacon is relatively easy to implement:

Inputs

  • 16-bit Bluetooth Vendor ID (with options for Apple 0x004C, Nordic 0x0059 or custom)
  • 128-bit UUID (which we can have a button to randomly generate)
  • 16-bit Major Value
  • 16-bit Minor Value
  • RSSI @ 1m (which we should auto-populate based on the RSSI we get from the connected device to make accurate results easy)

Outputs

UriBeacon Requirements

UriBeacon is a bit more complicated since you can (and often should) use a URI shortener beyond a certain link size, but the advantage of an Activity for this is that we can do this automatically for user's once the length exceeds a certain size.

Inputs

  • Uri to encode (that's it, but there is some logic to encode around this)

Outputs

Sample JavaScript code

This code is pretty basic, but if it helps here is some simple JavaScript code in an HTML file I wrote to encode a UriBeacon payload from the supplied URI.

The basis of this code is here: https://github.com/google/uribeacon/tree/master/specification

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

<div>UriBeacon URI: <input id="uri" type="text" /> <input id="clickMe" type="button" value="Generate" onclick="jsGenerateUri();" />  </div>
<label>Advertising Data: </label><label id="advData">--</label>

<!-- See: https://github.com/google/uribeacon/tree/master/specification#uribeacon-advertising-data -->
<script>
    function $(element) {
        return document.getElementById(element);
    }

    function asc2hex(string) {
        var temp = '';
        var a;
        for (a = 0; a < string.length; a++) {
            temp += ('-' + string.charCodeAt(a).toString(16));
        }
        return temp.toUpperCase();
    }

    function jsGenerateUri() {
        var input = $('uri').value;

        var header1 = '03-03-D8-FE'; /* Complete 16-bit Service List Flag, UUID = 0xFED8 */
        var header2 = '-16-D8-FE';   /* Service Data AD Type and UUID again */
        var flags   = '-00';
        var txpower = '-00';
        var prefix  = '';
        var len     = 6; /* Payload len counter, minus header1 */

        /* Make sure we have a valid string */
        if (input.length < 1) {
            alert("Invalid URI");
            return -1;
        }

        /* See if we can chop off the Uri prefix */
        if (input.indexOf('urn:uuid:') > -1) {
            prefix = '-04';
            input = input.substr(9, input.length - 9);
        }
        else if (input.indexOf('http://www.') > -1) {
            prefix = '-00';
            input = input.substr(11, input.length - 11);
        }
        else if (input.indexOf('https://www.') > -1) {
            prefix = '-01';
            input = input.substr(12, input.length - 12);
        }
        else if (input.indexOf('http://') > -1) {
            prefix = '-02';
            input = input.substr(7, input.length - 7);
        }
        else if (input.toLowerCase().indexOf('https://') > -1) {
            prefix = '-03';
            input = input.substr(8, input.length - 8);
        }
        else {
            alert("Prefix must be one of the following values:\n\nhttp://www.\nhttps://www.\nhttp://\nhttps://\nurn:uuid:");
            return -1;
        }

        /* Get the total payload length so far (minus the header and the len byte) */
        len += input.length;

        /* Generate the full URI payload (minus the header and len byte) */
        var uri = flags + txpower + prefix + asc2hex(input);

        /* See if we can chop off the suffix in the Uri */
        if (input.indexOf('.com/') > -1) {
            uri = uri.replace(asc2hex('.com/'), '-00');
            len -= 4;
        }
        else if (input.indexOf('.org/') > -1) {
            uri = uri.replace(asc2hex('.org/'), '-01');
            len -= 4;
        }
        else if (input.indexOf('.edu/') > -1) {
            uri = uri.replace(asc2hex('.edu/'), '-02');
            len -= 4;
        }
        else if (input.indexOf('.net/') > -1) {
            uri = uri.replace(asc2hex('.net/'), '-03');
            len -= 4;
        }
        else if (input.indexOf('.info/') > -1) {
            uri = uri.replace(asc2hex('.info/'), '-04');
            len -= 5;
        }
        else if (input.indexOf('.biz/') > -1) {
            uri = uri.replace(asc2hex('.biz/'), '-05');
            len -= 4;
        }
        else if (input.indexOf('.gov/') > -1) {
            uri = uri.replace(asc2hex('.gov/'), '-06');
            len -= 4;
        }
        else if (input.indexOf('.com') > -1) {
            uri = uri.replace(asc2hex('.com'), '-07');
            len -= 3;
        }
        else if (input.indexOf('.org') > -1) {
            uri = uri.replace(asc2hex('.org'), '-08');
            len -= 3;
        }
        else if (input.indexOf('.edu') > -1) {
            uri = uri.replace(asc2hex('.edu'), '-09');
            len -= 3;
        }
        else if (input.indexOf('.net') > -1) {
            uri = uri.replace(asc2hex('.net'), '-0A');
            len -= 3;
        }
        else if (input.indexOf('.info') > -1) {
            uri = uri.replace(asc2hex('.info'), '-0B');
            len -= 4;
        }
        else if (input.indexOf('.biz') > -1) {
            uri = uri.replace(asc2hex('.biz'), '-0C');
            len -= 3;
        }
        else if (input.indexOf('.gov') > -1) {
            uri = uri.replace(asc2hex('.gov'), '-0D');
            len -= 3;
        }

        /* Generate the len string (zero-padding if necessary) */
        var lenStr = '';
        if (len < 16) {
            lenStr = '-0' + len.toString(16).toUpperCase();
        }
        else {
            lenStr = '-' + len.toString(16).toUpperCase();
        }

        /* Add header1 and the payload len byte to the len count */
        len += 5;

        /* Make sure we don't exceed the 27 byte advertising payload limit */
        if (len > 27) {
            alert('Invalid payload length. The encoded UriBeacon payload must be <= 27' +
                  'bytes (16 characters max for the custom URI segment).\n\n' +
                  'The current payload is ' + len.toString() + ' bytes long.');
            $('advData').innerHTML = '--';
            return -1;
        }

        /* Update the page with the fully encoded UriBeacon payload */
        $('advData').innerHTML = header1 + lenStr + header2 + uri;
    }
</script>

</body>
</html>

iBeacon Trademark Issues

We need to change any 'iBeacon' strings to 'Beacon' since iBeacon is an Apple trademark.

I think this only concerns the tab header which should be changed to "BEACON" and "URIBEACON"

Display DFU version number?

Is it possible to display the DFU Version characteristic's value in the Info activity? I don't seem to get any value here:

screenshot_2015-02-01-12-41-53

'Controller' mode data is incorrect

Color data should be in the following format (rather than the four byte float as previously documented):

0x21 0x43 uint8_tR uint8_tG uint8_tB CRC8

All of the other values should also end with a CRC8 checksum byte ... they don't have this at present.

As an example of what iOS sends: "!C", which works out to: 0x21 '!', 0x43 'C', 0x4e (78), 0x37 (55), 0xff (255), 0x17 (checksum) for the color red = 78, green=55, blue=255

Characteristic UUID/String Typo?

There seems to be a typo in the string for the Device Information Service.

The Bluefruit LE Friend is sending out UUID 0x2A27, which corresponds to the "Hardware Revision String", but the string says "Software Revision String" (which is UUID 0x2A28).

Looking here, though, the strings seem to be correct, which is odd: https://github.com/adafruit/Bluefruit_LE_Connect_Android/blob/master/app/src/main/java/com/adafruit/bluefruit/le/connect/ble/StandardUUIDs.java#L124

        aMap.put("2A28", "Software Revision String");
        aMap.put("2A27", "Hardware Revision String");

Why are we seeing 'Software Revision String' below (0x2A28) if the device is sending out the 'Hardware Revision String' UUID (0x2A27):

  ble_gatts_char_handles_t hdlHardware;
  char_def.uuid.uuid = BLE_UUID_HARDWARE_REVISION_STRING_CHAR;
  char_def.p_data    = (uint8_t*) strHardwareRevision,
  char_def.min_len   = char_def.max_len = strlen(strHardwareRevision);
  ASSERT_STATUS( custom_add_characteristic(&char_def, &hdlHardware) );

BLE_UUID_HARDWARE_REVISION_STRING_CHAR corresponds to: #define BLE_UUID_HARDWARE_REVISION_STRING_CHAR 0x2A27

screenshot_2015-01-22-14-49-18

Stuck on 'Checking Updates...' for new board targets

When I use a firmware image with a new device name that isn't found in the firmware .xml file (BLEFRIEND32), we get stuck in 'Checking Updates...' forever.

If an unknown board is found, I propose we only show the custom .hex file button as a default?

Update bootloader to detect old and new version

Current there are 2 bootloader version.

  • old bootloader (0.0): used by already-on-the-shelf blefriend board
  • new bootloader (0.5): used by all other products.

The major difference in android's point of view is that the new bootloader requies an Init Packet http://developer.nordicsemi.com/nRF51_SDK/doc/7.2.0/s110/html/a00065.html to perform DFU. It is a separated binary file containing metadata of firmware image such as CRC, Revision etc ... Init Packet is generated during firmware make and included together with the firmware hex (e.g blefriend_s110_xxaa_dfu_init.bin )

To detect if the bootloader is old or new version:

  • new version always have the bootloader revision characteristics (3rd chars) with the value at least 0x0005 (little endian)
    new_bootloader
  • old version is either has the revision characteristic = 0x0000 or does not have the char at all when it is in bootloader mode.
    old_boolder2
    old_boolder1

Change DFU Device Information Checks

Note: See #4 before editing this issue!

Newer versions of the Bluefruit LE firmware changed the contents to the Device Information Service string so that only the 'Firmware Revision String' contains a "#.#.# - DATE" string (example 0.5.0 - Jan 22 2015).

The Software Revision String now contains RevA but should be considered TBD.

As a result, trying to connect to devices running new firmware gets stuck on the 'Checking Updates ...' screen and blocks, presumably because it is trying to check the Software Revision String which is no longer in a format it understands.

Please update the version checks to be based on the Firmware Revision String, Manufacturer Name String and perhaps the Model Number exclusively ... the Software Revision String should be ignored for now and may be replaced with something else in the future.

screenshot_2015-01-22-14-49-18

screenshot_2015-01-22-14-49-44

Bluefruit LE Connect NeoPixels and Android device

I've been trying to find an answer. I have successfully tested my device with iOS and it works with my neopixel jewel perfectly. I get the color change and I get dimming etc. When I try the exact same setup on the Android version I don't get barely anything, I get maybe 2 colors, and there on the right color choice. I do get dimming however but only blue and green. Can someone PLEASE help, I've been trying to get answers for months! Thank you kindly in advance!

Update service/char/descriptor UUIDs before update

Before an update is released, the official UUID list for standard services and characteristics should be updated to take into account recently adopted services and characteristics:

Note: There was a small typo in the last release that was recently fixed: 5c06274

Quat issues with Controller Data

The Quaternion output on Android doesn't work when enabled with other sensors. Enabling Quat + Accel only sends accel, whereas Accel+Mag+Gyro (etc.) seems to work fine.

Is the issue that quats are missing here?

Also ... there should be a fourth float in the QUAT output for 'w' or rotation. If this isn't available on Android, four 00 bytes should be inserted instead.

BluetoothAdaptor().startLeScan() is Deprecated.

Bluefruit_LE_Connect_Android/app/src/main/java/com/adafruit/bluefruit/le/connect/ble/BleDevicesScanner.java
Line number 70 & 78
mBluetoothAdapter.startLeScan(mLeScanCallback);
startLeScan() is Deprecated.
stopLeScan() is Deprecated.

Battery service displays -1%

After configuring and starting the battery service on an NRF52 bluefruit, app displays -1% battery, regardless of what blebas is set to. To duplicate this, I used the stock bleuart peripheral example, where blebas.write(100); was used to set battery status to 100%. Included a screenshot. Bluefruit firmware 0.8.4

screencap

Add QR Code Support for AIO Keys (MQTT)

Adafruit IO now shows QR codes for the user key since they are too long to enter by hand. Support scanning the QR code for the username should be added to the MQTT section of the app. To see the QR code, just open the modal dialogue with your AIO key.

DIS Switched to byte array

When I looked at the Device Information Service in the app once it worked the first time, then I placed the Nexus 4 running 5.0.1 down on the my desk, and picked it up again to check something (perhaps after a screen rotation), and everything switched to byte array data.

Testing again, it seems a simple orientation change is enough to reproduce the issue:

screenshot_2015-02-03-12-06-35

Add EddyStone UUIDs

The latest firmware (0.6.6) includes support for EddyStone (UriBeacon 2.0), which introduces a set of custom UUIDs we don't currently have in the lookup table.

Stirngs should be added for all of the UUIDs present here: https://github.com/google/eddystone/blob/master/eddystone-url/docs/config-service-spec.md

Ideally, 'Eddystone' should be added in front of the names, so (in order of appearance in the link above):

Service

  • Eddystone Config Service

Service Characteristics

  • Eddystone Lock State
  • Eddystone Lock
  • Eddystone Unlock
  • Eddystone URI Data
  • Eddystone Flags
  • Eddystone Adv. TX Power Levels
  • Eddystone TX Power Mode
  • Eddystone Beacon Period
  • Eddystone Reset
  • Eddystone (Reserved)

Add 'Refresh Services' as a config option

Currently, when we switch between DFU Targ and UART mode with the bootloader, Android often seems to get 'stuck' with the DFU Targ service list and it's really hard to force it to do a fresh service scan. Even disabling and enabling Bluetooth doesn't seem to clear the cache, not does a factory reset of the nRF51.

There is an option in the Master Control Panel app from Nordic that does force a service refresh, but I don't know the underlying code since I don't have the source for this app.

Is this something we can easily add ourselves? If you're stumped on how to do this, let me know and I'll ping someone at Nordic if necessary, but hopefully there's an easy function to do this in the BLE API?

refreshservices

Update firmware version tracker to use XML

Since we will soon have multiple Bluetooth Low Energy products, and they may require different firmware versions, we should probably migrate the current text file pointing to the latest firmware version to XML, which allows for richer data management.

A new releases.xml file has been added to the firmware repo to this effect.

Each board has it's own section with the name field based on the contents of the Device Information Service's Model Number string.

Inside each board entry there is a new firmware section, where all firmware versions are listed to the latest version can be determined, but to also allow users to back-peddle to previous official versions if necessary (an optional dialogue should be added to this effect).

The firmwarerelease field also contains an initfile tag. This is necessary for new versions of the bootloader, but isn't yet used on the BLEFriend boards which use the old bootloader. The SPISlave boards will use the new bootloader requiring two files, which will be added early next week. The initfile field will point to the file to use for this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.