Coder Social home page Coder Social logo

fromfile's Introduction

BLE_Button is a BLE service template. It handles a read-only characteristic with a simple input (boolean values). The input's source is the button on the board itself - the characteristic's value changes when the button is pressed or released.

The template covers:

  1. Setting up advertising and connection modes.

  2. Creating an input characteristic: read-only, boolean, with notifications.

  3. Constructing a service class and adding it to the BLE stack.

  4. Assigning UUIDs to the service and its characteristic.

  5. Pushing notifications when the characteristic's value changes.

Running the application

Requirements

The sample application can be seen on any BLE scanner on a smartphone. If you don't have a scanner on your phone, please install :

Hardware requirements are in the main readme.

Porting this example on new boards

This example requires a board with at least a button to work. While the pin name of the button is defined for the NRF51_DK, NRF52_DK, K64F and NUCLEO_F401RE, it is not specified for other boards.

It is easy to add the button configuration for your board:

  • Open the file named mbed_app.json at the root of this example.
  • In the section target_overides add a new object named after your target if it doesn't exist. This object contain overridden parameters for your target.
  • Override the property ble_button_pin_name in your target object. The value of the property should be equal to the pin name to use as a button.

As an example, this is the JSON bit which has to be added in the target_overrides section of mbed_app.json for a NUCLEO_F411RE board.

        "NUCLEO_F411RE": {
            "ble_button_pin_name": "USER_BUTTON"
        }

Note: You can get more informations about the configuration system in the documentation

Important: If your target use an ST BLE shield, other parameters have to be overridden for your target. More information are available in the global README

Building instructions

Building instructions for all samples are in the main readme.

Checking for success

Note: Screens captures depicted below show what is expected from this example if the scanner used is nRF Master Control Panel version 4.0.5. If you encounter any difficulties consider trying another scanner or another version of nRF Master Control Panel. Alternative scanners may require reference to their manuals.

  1. Build the application and install it on your board as explained in the building instructions.

  2. Open the BLE scanner on your phone.

  3. Start a scan.

    figure 1 How to start scan using nRF Master Control Panel 4.0.5

  4. Find your device; it should appear with the name Button in the scanner.

    figure 2 Scan results using nRF Master Control Panel 4.0.5

  5. Establish a connection with the device.

    figure 3 How to establish a connection using Master Control Panel 4.0.5

  6. Discover the services and the characteristics on the device. The Button service has the UUID 0xA000 and includes the Button state characteristic which has the UUID 0xA001. Depending on your scanner, non standard 16-bit UUID's can be displayed as 128-bit UUID's. If it is the case the following format will be used: 0000XXXX-0000-1000-8000-00805F9B34FB where XXXX is the hexadecimal representation of the 16-bit UUID value.

    figure 4 Representation of the Button service using Master Control Panel 4.0.5

  7. Register for the notifications sent by the button state characteristic then the scanner will automatically receive a notification containing the new state of the button every time the state of the button changes.

    figure 5 How to register to notifications using Master Control Panel 4.0.5

  8. Pressing Button 1 on your board updates the state of the button and sends a notification to the scanner. The new state of the button characteristic value should be equal to 0x01.

    figure 6 Notification of button pressed using Master Control Panel 4.0.5

  9. Releasing Button 1 on your board updates the state of the button and sends a notification to the scanner. The new state of the button characteristic value should be equal to 0x00.

    figure 7 Notification of button depressed using Master Control Panel 4.0.5

fromfile's People

Contributors

chocolatepatty avatar

Watchers

James Cloos avatar

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.