Giter VIP home page Giter VIP logo

nrf8001's Introduction

nRF8001

Last updated: 2015/06/04

Provides simple API for nRF8001 BLE chip such as the BLE Shield and Blend Micro to exchange data via RBL TxRx Service to BLE Central device (e.g. iPhone 5).

Other 3rd party breakout breads may also be workable.

Tested with Arduino IDE 1.6.4 (we will only support this version).

Installation

You have to see this for installing libraries first. http://www.arduino.cc/en/Guide/Libraries

Method 1 - Using Library Manager

Follow this guide:

https://github.com/RedBearLab/BLEShield/blob/master/Docs/LibraryManager.pdf

Method 2 - Manual installation ("Importing a .zip Library")

Step 1: Get the latest release of Nordic nRF8001 SDK for Arduino.

Step 2: Get the latest release of RBL nRF8001 API.

Step 3: Load an example to your Arduino board.

How to use

The library structure and dependency: YourSketch.ino -> RBL_nRF8001 -> Nordic's BLE

Also, you can use Nordic's library directly such as: YourSketch.ino -> Nordic's BLE

Nordic also provides many examples and tutorials.

Read Nordic's BLE SDK for Arduino for details with tutorials to write your own services.

There are two Apps available from the Apple AppStore:

  1. BLE Arduino
    It is for the BLEFirmata sketch and works for iOS 6

  2. BLE Controller
    It is for the BLEController sketch and works for iOS 7

Change BLE Advertising Name

Before calling to ble_begin(), you can make use of ble_set_name("My BLE") to change the name.

Supported Boards

Arduino UNO (328p), Leonardo (32u4), MEGA2560, DUE and their compatible.
ChipKit Uno32

API

ble_begin

void ble_begin();
  • ble_begin starts the BLE stack and broadcasting the advertising packet

ble_set_name

void ble_set_name(char *name);
  • Call ble_set_name by giving name before calling to ble_begin to set the broadcasting name.

ble_write

void ble_write(unsigned char data);
  • ble_write sends a single byte data to the BLE Central.

ble_write_bytes

void ble_write_bytes(unsigned char *data, unsigned char len);
  • ble_write_bytes writes an array of bytes in data with length in len.

ble_do_events

void ble_do_events();
  • ble_do_events allows the BLE to process its events, if data is pending, it will be sent out.

ble_read

int ble_read();
  • ble_read reads a byte from BLE Central, It returns -1 if nothing to be read.

ble_available

unsigned char ble_available();
  • Returns the number of bytes ready for reading.

ble_connected

unsigned char ble_connected(void);
  • ble_connected returns 1 if connected by BLE Central or 0 if not.

ble_set_pins

void ble_set_pins(uint8_t reqn, uint8_t rdyn);
  • ble_set_pins is to specify the REQN and RDYN pins to the BLE chip, i.e. the jumper on the BLE Shield.

ble_busy

unsigned char ble_busy();
  • ble_busy return the status if the BLE is busy, i.e. it is using the SPI interface. It is for using the SPI for other components at the same time.

ble_reset

void ble_reset(uint8_t reset_pin);
  • ble_reset resets the BLE chip using the specified pin, reset_pin

Resources

  1. Nordic nRF8001 SDK for Arduino - Library

  2. Nordic nRF8001 SDK for Arduino - Forum

  3. Nordic Developer Zone

  4. Bluetooth SIG

License

Copyright (c) 2012-2014 RedBearLab

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

nrf8001's People

Contributors

amoriello avatar cheong2k avatar sandeepmistry avatar shokai 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

Watchers

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

nrf8001's Issues

BlendMicro not read data from node.js

On blend micro i use SimpleChat.ino. On RPI3 i use https://www.npmjs.com/package/blendmicro this library. Blend micro send data to the node, and rpi3 read this data. If i send data to from blendmicro to the node, node not read. On node i use this code

var BlendMicro = require("#{__dirname}/../../");
// var BlendMicro = require("blendmicro");

var bm = new BlendMicro(process.argv[2]);

bm.on("open", function(){
  console.log("open");
});

bm.on("data", function(data){
  console.log(data.toString());
});

process.stdin.setEncoding("utf8");

// write data from STDIN
process.stdin.on("readable", function(){
  var chunk = process.stdin.read();
  if(chunk == null) return;
  chunk = chunk.toString().replace(/[\r\n]/g, '');
  bm.write(chunk);
});

Compatibility with USB Host Shield 2.0 library

Hi,

Im facing some compatibility issue when I am using BLE Shield together with USB Host Shield 2.0

Whenever add codes to start the USB Host Shield, BLE shield will stop working.

Any idea where can i start to troubleshoot?

#include <RBL_nRF8001.h>
#include <boards.h>
#include <SPI.h>
#include <EEPROM.h>

// for USB Host
#include <adk.h>

// for BLE
static byte buf_len = 0;
byte queryDone = false;
uint32_t timer1;

// for USB Host
USB Usb;
ADK adk(&Usb, "TKJElectronics", // Manufacturer Name
              "ArduinoBlinkLED", // Model Name
              "Example sketch for the USB Host Shield", // Description (user-visible string)
              "1.0", // Version
              "http://www.tkjelectronics.dk/uploads/ArduinoBlinkLED.apk", // URL (web page to visit if no installed apps support the accessory)
              "123456789"); // Serial Number (optional)
uint32_t counter;
uint32_t sendcounter;
uint32_t timer;
bool connected;

void setup() {
  Serial.begin(57600);

  Serial.print("\r\nArduino Blink LED Started");
  if (Usb.Init() == -1) {
    Serial.print("\r\nOSCOKIRQ failed to assert");
    while (1); // halt
  }

  // Init. and start BLE library.
  ble_begin();
}

static unsigned char spi_old;

void loop()
{


  spi_old = SPCR;
    SPI.setBitOrder(LSBFIRST);
    SPI.setClockDivider(SPI_CLOCK_DIV8);
    SPI.setDataMode(SPI_MODE0);

  if(ble_available())
  {
    byte cmd;
    cmd = ble_read();

    Serial.print(cmd, HEX);

    // send out any outstanding data
    ble_do_events();
    buf_len = 0;
  }
  else {
      ble_do_events();

      if (millis() - timer1 >= 1000) { // Send data every 1s
      timer1 = millis();
      Serial.println(F("\nBLE not available"));
     }
  }

  ble_do_events();

  SPCR = spi_old;
  SPI.begin();

  buf_len = 0;

  Usb.Task();
  if (adk.isReady())
  {
    if (!connected) 
    {
      connected = true;
      Serial.println(F("\r\nConnected to accessory"));
    }
  }
  else 
  {  
   if (millis() - timer >= 1000) { // Send data every 1s
      timer = millis();
      Serial.println(F("adk not ready"));
   }
   if (connected) 
   {
      connected = false;
      Serial.print(F("\r\nDisconnected from accessory"));
    }
  } 
}

Range issue with blend micro...!

Hai

i am using blend micro to control my devices in my project via bluetooth.Now everything is working fine but the problem is with its range i have only getting a range of 13M but that is not enough for my project so can i increase the transmission power of my board to get more range ............?
or can i increase the range by any other means.......?

Compilation in Arduino 1.6.0?

Any chance that you can get the code to compile in the new 1.6.0 environment?
Arduino: 1.6.0 (Windows 8), Board: "Arduino Uno"

D:\Arduino\libraries\RBL_nRF8001\RBL_nRF8001.cpp:25:23: error: setup_msgs causes a section type conflict with __c
static hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] PROGMEM = SETUP_MESSAGES_CONTENT;

                   ^

In file included from D:\Arduino\libraries\BLE/hal_platform.h:32:0,
from D:\Arduino\libraries\BLE/lib_aci.h:34,
from D:\Arduino\libraries\RBL_nRF8001\RBL_nRF8001.h:17,
from D:\Arduino\libraries\RBL_nRF8001\RBL_nRF8001.cpp:14:
D:\Arduino\hardware\arduino\avr\cores\arduino/WString.h:38:74: note: '__c' was declared here
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
^
D:\Arduino\libraries\RBL_nRF8001\RBL_nRF8001.cpp:388:32: note: in expansion of macro 'F'
Serial.println(F("Advertising started"));

                            ^

Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

RBL_LOG is unconditionally using the serial port

Please allow developers to turn off all use of the serial port by your code. The serial port is not to be used unconditionally by libraries for debugging/status, as that messes up the communication of actual data.

Also I noted that the library manager uses an old version of this code where Serial.xxxxx calls are even inline. I had to comment out all calls so I could combine a MIDI Shield with a BLE Shield.

¿Advertising or broadcasting data using set_name?

I'm starting developing with Blend board, so sorry if this is an stupid issue but maybe you can help us.

We are trying to do a broadcasting of sensor data through BLE to be read after from a smartphone app. At the moment, we are trying to write the data through the set_name() function because we just found that way to do the broadcast without pairing.

The problem appears when we try to set a variable name, it is not working at all, because just the first name written is sent, it seems the code is ignoring the rest of the set_name() calls in the loop().

I assume this is not the right way of doing it, so ¿Is there another (easy) way of sending data broadcast? ¿Or should we pair the devices and create a GATT connection?

Thank you very much.

ble_set_name before ble_begin doesn't work.

The README clearly states: "Before calling to ble_begin(), you can make use of ble_set_name("My BLE") to change the name." However, if you open up the simple chat example, uncomment the ble_set_name line, and then upload the program, the name will still be "BLE Shield" and not "My Name" as expected. I checked this using the Red Bear's Simple Chat iOS app.

I am using BLE Shield v2.0 on an Arduino Mega 2560 v3 using the latest version of the library. I am uploading to the board with an AVRISP MkII.

Issues with android

I have some issues with android, (nRF UART v2.0 APP)

I didn't receive this message "Hello World, works" when connection is established, and when I try to send a message, toast notification says that device is not UART capable, and disconnect.

Also tested with iPhone (with same app), works fine.

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.