Giter Site home page Giter Site logo

sandeepmistry / arduino-bleperipheral Goto Github PK

View Code? Open in Web Editor NEW
460.0 460.0 178.0 1.17 MB

An Arduino library for creating custom BLE peripherals with Nordic Semiconductor's nRF8001 or nR51822.

License: MIT License

C++ 42.84% C 57.03% Shell 0.13%

arduino-bleperipheral's Introduction

๐Ÿ‘‹๐Ÿฝ Hi there, I'm Sandeep ๐Ÿ‘จ๐Ÿฝโ€๐Ÿ’ป

๐Ÿ‘จ๐Ÿฝโ€๐Ÿ”ฌ Personal Projects

Current

  • Arduino Libraries: ๐Ÿ“ก LoRa | โš™๏ธ nRF5 | ๐Ÿฅซ CAN | ๐Ÿš˜ OBD2 |

Past

๐Ÿ‘จ๐Ÿฝโ€๐Ÿ”ง Past work for @arduino

arduino-bleperipheral's People

Contributors

bojh avatar cbolgiano avatar dsanders11 avatar floe avatar gbuesing avatar george-hawkins avatar jacobrosenthal avatar mlu avatar per1234 avatar sandeepmistry avatar vojtamolda avatar zfields 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-bleperipheral's Issues

Can not notify data to central

I set one characteristic's property with notify. when I use LightBlue to write data via another characteristic with the write without respond property, I notify the length of the data to it via the notify characteristic, but LightBlue only shows that it received a notification(according to the latest time it received notification changed), no data shows on the screen. The board I using is Blend Micro. The sketch is here: https://gist.github.com/XuGuohui/844d676c3de72a36c83e

Temperature sensor example

Thanks @sandeepmistry for this great library!

A common BLE peripheral use case is for transmitting sensor data -- I think it would be helpful to include an example sketch that could be used as a base for sensor peripherals.

I pulled together a demo temperature sensor sketch: https://gist.github.com/gbuesing/b6b526c7579320c726d3

I'm using the TimerOne library (https://code.google.com/p/arduino-timerone/) to run a function once per second that sets the temp characteristic from a fresh sensor read (which is just a random number generator to keep things simple for the demo.)

Wondering if this is the right approach? Or will this somehow interfere with the work that the BLEPeripheral library does?

If this does look good, I'd be happy to prepare a pull request.

Cannot change the timing of a pipe (rf_interval) via BLEPeripheral API

We are tuning the timing of a pipe to increase message rate (it's a notification and we want to send ~20+ notifications a second).

our previous code, where we used the nRF SDK API directly, had this:
case ACI_EVT_PIPE_STATUS: {
if (lib_aci_is_pipe_available(&aci_state, PIPE_VALUE_TX) && !timing_change_done) {
lib_aci_change_timing(6, 6, 0, 600); // Low-latency parameters
timing_change_done = true;
}

which is based on the nRF SDK API example:
https://github.com/NordicSemiconductor/ble-sdk-arduino/blob/master/libraries/BLE/examples/ble_bandwidth_test/ble_bandwidth_test.ino#L332

It looks like the BLEPeripheral/BLEDevice classes don't support changing the timing (I grepped the code for calls to lib_aci_change_timing, and didn't see any).

HID not working after reconnect

Hi
I'm experimenting with HID (HID_volume) on RFduino.
At the moment I'm having an issue on device reconnect.
The first time I connect the RFduino with my smartphone, the volume function works correctly.
If the RFduino is already paired with my phone and I reconnect it, the phone doesn't receive the volume command.
I'm trying on Samsung J5 and also on a Asus Laptop.
I activated the NRF_51822_DEBUG flag and what I see is this:

Starting...
BLE HID Peripheral - clearing bond data
version = 6 89 46
Start advertisement
BLE HID Volume Knob
Evt Connected dc:85:de:e5:08:30
Connected to central: dc:85:de:e5:08:30
Evt Sec Params Request 0 1 1 4 0 0 16
Evt Conn Sec Update 1 2 16
Evt Auth Status
0
Storing bond data
Evt Conn Param Update 0xC 0xC 0x0 0x3C0
Evt Sys Attr Missing 0
Evt Write, handle = 11
02 00 
Evt Write, handle = 21
01 00 
Evt Conn Param Update 0x30 0x30 0x0 0x3C0
Evt Conn Param Update 0x8 0x8 0x0 0xC8


#after sending HID key
Evt TX complete 1
Evt TX complete 1


#Turning off and on the BT on the host:

Evt Disconnected
Start advertisement
Disconnected from central: dc:85:de:e5:08:30
Evt Connected dc:85:de:e5:08:30
Connected to central: dc:85:de:e5:08:30
Evt Sec Info Request 16189 1 0 0
Evt Conn Sec Update 1 2 16


#trying to send HID keys but no effect



#Resetting RFduino without clearing bond data:

Starting...
version = 6 89 46
Restoring bond data
Start advertisement
BLE HID Volume Knob
Evt Connected dc:85:de:e5:08:30
Connected to central: dc:85:de:e5:08:30
Evt Sec Info Request 16189 1 0 0
Evt Conn Sec Update 1 2 16

#again trying to send HID keys but no effect

I'm digging deeper with some more debug and it seems that a possible problem is that
localCharacteristicInfo->notifySubscribed
in the method:
bool nRF51822::updateCharacteristicValue(BLECharacteristic& characteristic)
is FALSE
(row 961 in nRF51822.cpp)

Can you please help me?
Thankyou

Matteo

hi i want write a gamepag HID descriptor i have some question about the function

hi i want write a gamepag HID descriptor i have some question about the function

BLEMouse::BLEMouse() :
BLEHID(descriptorValue, sizeof(descriptorValue), 11),
_reportCharacteristic("2a4d", BLERead | BLENotify, 4),
_reportReferenceDescriptor(BLEHIDDescriptorTypeInput),
_button(0)
{
}

  1. how do you decide the number 11? it seems like reportIdOffset, but how do you decide to set 11?
    BLEHID::BLEHID(const unsigned char* descriptor, unsigned char descriptorLength, unsigned char reportIdOffset) :
    _reportId(0),
    _descriptor(descriptor),
    _descriptorLength(descriptorLength),
    _reportIdOffset(reportIdOffset)
    {
    _numHids++;
    }

2._reportCharacteristic("2a4d", BLERead | BLENotify, 4),
the number represent the send value is 4 bytes
but the MOUSE HID DESCRIPTOR only set
3 button 1bytes
1 X 1bytes
1Y 1bytes
the last byte is wheel but i didn't see it in mouse HID descriptor

3.i will use the descriptor like below to control the gamepad.

how do i set the number 11 and 4 as below
BLEHID(descriptorValue, sizeof(descriptorValue), 11),
_reportCharacteristic("2a4d", BLERead | BLENotify, 4),

0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x05, // Usage (Game Pad)
0xA1, 0x01, // Collection (Application)
0x85, 0x07, // Report ID (7)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x32, // Usage (Z)
0x09, 0x35, // Usage (Rz)
0x15, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x00, // Logical Maximum (255)
0x75, 0x08, // Report Size (8)
0x95, 0x04, // Report Count (4)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0xC0, // End Collection

Thank you for always answer my question so quickly.

Blend micro's default service can't be override by my code using BLEPeripheral library

Hi, my redbear labs Blend Micro worked before with the new service I registered using BLEPeripheral library. Your library really helped a lot! Thanks! But after some of the update, I'm not sure what is changed. The new service and characteristics are not shown in my Blend Micro. It always show the default Blend TX/RX service '713d0000-503e-4c75-ba94-3148f18d941e'. My created service is never shown. The board only shows the service id and device name in advertisement data. But the real service is still blend micro's default one.

Could you help me to identify what's the problem? Thanks a lot in advance!

Arduino Version 1.6.8 (Tried in 1.6.6, same problem)
RedbearLab AVR Boards version 1.0.2 (for blend micro)
BLEPeripheral version 0.1.8
RBL_nRF8001 version 1.0.0

Here is my code
`
// Import libraries (BLEPeripheral depends on SPI)

include <SPI.h>

include <BLEPeripheral.h>

// define pins (varies per shield/board, UNUSED for nRF51822)

define BLE_REQ 6

define BLE_RDY 7

define BLE_RST 4

// LED and button pin

define SWITCH_PIN 3

// create peripheral instance, see pinouts above
BLEPeripheral blePeripheral = BLEPeripheral(BLE_REQ, BLE_RDY, BLE_RST);

// create service
BLEService ledService = BLEService("ffe0");

// create device id characteristic
BLECharacteristic deviceIdChar = BLECharacteristic("ffe1", BLERead | BLEWrite, 20);

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

if defined (AVR_ATmega32U4)

delay(5000); //5 seconds delay for enabling to see the start up comments on the serial board

endif

// set LED pin to output mode, button pin to input mode
pinMode(SWITCH_PIN, OUTPUT);
digitalWrite(SWITCH_PIN, LOW);

// set advertised local name and service UUID
blePeripheral.setDeviceName("LED");
blePeripheral.setLocalName("LED");
blePeripheral.setAdvertisedServiceUuid(ledService.uuid());

// add service and characteristics
blePeripheral.addAttribute(ledService);
blePeripheral.addAttribute(deviceIdChar);

// begin initialization
blePeripheral.begin();

Serial.println(F("BLE LED Peripheral"));
}

void loop() {
// poll peripheral
blePeripheral.poll();

BLECentral central = blePeripheral.central();

if (central)
{
// has the value changed since the last read
if (deviceIdChar.written()) {
unsigned char len = deviceIdChar.valueLength();
const unsigned char *data = deviceIdChar.value();
Serial.println(len, DEC);
deviceIdChar.setValue(data, (int)len);
}
}
}
`

Sketch size is too big for Arduino UNO

Hi!

I'm trying to optimise library to reduce the size of sketch and libraries. But so far, it is not going well.
Any suggestions on this will be much helpful.

I disabled DEBUG printouts.

What else can I do?

Thanks,

iBeacon code is a little brittle around manufacturerData value

I'm raising an issue against code that I submitted!

The array holding the iBeacon manufacturerData is created on the stack - see iBeacon.cpp:14:

void iBeacon::begin(const char* uuidString, unsigned short major, unsigned short minor, char measuredPower) {
  unsigned char manufacturerData[MAX_UUID_LENGTH + 9]; // 4 bytes of header and 5 bytes of trailer.

I hadn't realized when calling BLEPeripheral::setManufacturerData(...) that it doesn't copy its input.

This doesn't matter as the only method that currently needs this data is also called from the iBeacon::begin(...) method so our data is luckily still in scope. But the minute we leave the iBeacon::begin(...) method the value of BLEPeripheral::_manufacturerData is junk.

I noticed this when I tried adding a getter alongside the existing BLEPeripheral::setManufacturerData(...).

Sorry to post this issue without posting a fix - I could get around this problem another way in my code but I just wanted to point out the brittleness.

BLEPeripheral.begin function not executing

Having powered up my new nRF8001 module, it isn't showing up on any bluetooth devices ( I am primarily using the Bluefruit LE app recommended by ADA Fruit, on iPhone 5s, iOS 8.3 ).

Having traced the code, blePeripheral.begin (); isn't working in main.cpp (approx. line 68)

This is because nRF8001::begin isn't working in nRF8001.cpp

Because waitForSetupMode(); isn't working in nRF8001.cpp (approx. line 201)

I have traced this to the "while (!setupMode){" loop in nRF8001.cpp (approx. line 778)

Where and why does "setupMode" get activated is this a software issue, or is it triggered by a hardware input? I will continue tracing, but any thoughts would be much appreciated.

bool lib_aci_event_get(aci_state_t *aci_stat, hal_aci_evt_t *p_aci_evt_data)
{
  bool status = false;

  status = hal_aci_tl_event_get((hal_aci_data_t *)p_aci_evt_data);

  /**
  Update the state of the ACI with the 
  ACI Events -> Pipe Status, Disconnected, Connected, Bond Status, Pipe Error
  */
  if (true == status)
  {
    aci_evt_t * aci_evt;
  ...

What causes the โ€œlib_aci_event_get(&this->_aciState, &this->_aciDataโ€ condition to be met?

Redbearlab BLE Nano comptatibility

I have a BLE nano board (http://redbearlab.com/blenano/, rev. 1.5). I tried running the same HID keyboard example on it as on an Arduino Uno with a BLE shield. I'm not able to connect to the Nano device.

Is there any kind of setup that I need to do for this device? Set any of the BLE_REQ/BLE_RDY/BLE_RST - I got the impression that I don't have to set those when using this board.

The examples from https://github.com/RedBearLab/nRF51822-Arduino appar to work. I tried to program the HR example which works out of the box (I can connect to the device from a HR app on my phone).

Support for requesting SoC temperature for nrf51822 application.

For to use/retrieve the temperature value from the nrf51822 SoC, it would be nice to have a:

public void requestTemperature() { this->_device->requestTemperature(); } 

method for the BLEPeripheral class.
For to get notified with the value, we can create a new derived MyBLE class overloading BLEPeripheral virtual method:

void MyBLE::BLEDeviceTemperatureReceived(BLEDevice& device, float temperature); 

method. An optional alternative would be to register a callback giving back (only) the temperature.

Problem connecting to peripheral

First, thanks for a great library Sandeep, it is such a great idea to get rid of the nRFGO-studio package.

I've set up the device and it runs great, advertises correctly.

When trying to connect to the peripheral with CoreBluetooth on MacOS 10.9 It seems to connect but the callback didConnectPeripheral is never fired. Using a nRFGO-studio configuration it connects and fires this callback.

I wondering if there is any handler that needs to be called from the Arduino code in order for the handshake to complete.

Using the BTLExplorer iOS app it works and can see the service and characteristic which is a bit strange.

I'm using the LED Switch example.

Thanks again for a great library.
Fredrik

GCC warnings

When compiling I am used to use -Wall -Werror as two of the options to gcc to force me to write warning free code (and hopefully/eventually more error free code). If there are warnings that I decide not to handle, then I either use pragma's to switch them off, or use macro's to trick the compiler to ignore them.

The arduino-BLEPeripheral lib gives quite alot of warnings. (unused parameters, no return statement in function returning non-void, enumeration value not handled in switch etc)

Are there any plans to reduce number of warnings in the library?

Arne

Setting up

Great work sandeep!
I'm trying to work up on this project which is much similar to making an iBeacon/estimote.
The hardware I'm currently using is- (multiple) Blend's(which has embedded BLE) and linux comps/Intel galileo's(many). My ultimate aim to get the RSID/signal strength between these devices.
I tried working with Noble and Bleno(although in the noble example- I only get the 'name' as 'Blend' but no manufacture data(with which I can get the SSID).. What would you recommend I should start? Any suggestions would be hugely appreciated! Don't mind buying additional hardware as well..

Lost data when sending amount of data to Lightblue

Hi @sandeepmistry ,

When I want to send amount of data to BLEController app continuously, app can not receive all of the data. I think there is the reason that the data credit is not enough to hold the data, so we have to listening event from nRF8001 to see whether there is available credit to send data. But I can't see an API to deal with it. How do you know if there is available credit to send data? What will happen if I send data to BLE central continuously? The board I using is BlendMicro and the sketch is here:https://gist.github.com/XuGuohui/34e5e341ade0116fc7de
You can see the log printed on Serial Monitor.

Best regards,
Guohui

"Unsupported platform" error with BLE Nano

I am using the BLE Nano board with nRF51822 Arduino Add-on from https://github.com/RedBearLab/nRF51822-Arduino and can compile the "blink" example without problems for the BLE Nano board.

However, when trying to #include <BLEPeripheral.h> I'm getting the following:

In file included from /Users/ncr/Documents/Arduino/libraries/BLEPeripheral/utility/lib_aci.h:34:0,
                 from /Users/ncr/Documents/Arduino/libraries/BLEPeripheral/nRF8001.h:6,
                 from /Users/ncr/Documents/Arduino/libraries/BLEPeripheral/BLEPeripheral.h:23,
                 from /Users/ncr/dev/blego/blego/blego.ino:3:
/Users/ncr/Documents/Arduino/libraries/BLEPeripheral/utility/hal_platform.h:75:6: error: #error "Unsupported platform"
     #error "Unsupported platform"

      ^
exit status 1
Error compiling.

The complete code I'm trying to compile:

#include <SPI.h>
#include <BLEPeripheral.h>

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Is BLE Nano supposed to work stand-alone or only as an add-on to an Arduino UNO (or similar) board?

Compatibility with USB Host Shield 2.0 library

I am trying to combine the Circuits@Home USB Host Shield 2.0 with the RedBearLabs BLE Shield 2.0 to build a bridge from my rowing machine to get data to my phone.

My initial approach was using the RBL_nRF8001 library to abstract somewhat low-level-ness of the BLE library. But then I discovered this BLEPeripheral and figured it would give me a lot more control. So off I went integrating it instead.

I am hitting a bit of an issue though. As it appears that library processing calls (BLEPeripheral::central() and USB::Task()) don't like each other very much. Where calling one will basically break the functionality of the other library. And I can't quite figure out why. Since the RBL_nRF8001 library seemed to co-exist just fine.

I did initially have similar symptom with the RBL_nRF8001 library. But that turned out to simply be conflicts on the use of pin 9. And was easily fixed on the BLE Shield (lucky since it requires soldering on the USB Host shield).

Bonding with multiple centrals (specifically iOS devices)

I'm trying to work out how bonding with multiple centrals would be achieved.

My current understanding is that you would have to swap out the bonding data based on which central was trying to connect (I think by calling lib_aci_write_dynamic_data). I'm guessing this can be based on the central's address, and can be done after the connection event.

Unfortunately it looks like iOS devices use Random Private Resolvable addresses (involving an Identity Resolution Key). I can't see anything in the repository that resolves the addresses, and I'm not even sure if it's a part of the supported BLE 4.0 specification (I'm using the nRF8001).

Does anyone if I'm on the right track, or know how I can uniquely identify iOS devices for bonding purposes?

Error compiling with RedBearLab BLE Nano with S130 branch/release

The error message is as follows:
/Documents/Arduino/libraries/BLEPeripheral/nRF51822.h:9:30: fatal error: s110/ble_gatts.h: No such file or directory
ย ย ย #include <s110/ble_gatts.h>
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ^
compilation terminated.
Error compiling.

broadcasting an Eddystone URL and running a GATT service simultaneously via RFDuino

Hello!
In the code below I am attempting to use EddystoneBeacon as both a URL broadcaster and a GATT service on an RFDuino. However it appears that the line

eddystoneBeacon.setAdvertisedServiceUuid(ledService.uuid());

prevents the URL from being broadcast. If I comment it out, the URL broadcasts but the service is not discoverable (the latter makes sense, it being an advertisement call). Curious if this has been experienced before, or if this isn't the proper way to combine the two features?
Thanks!

#include <SPI.h>
#include <EddystoneBeacon.h>

#define EDDYSTONE_BEACON_REQ   6
#define EDDYSTONE_BEACON_RDY   7
#define EDDYSTONE_BEACON_RST   4
EddystoneBeacon eddystoneBeacon = EddystoneBeacon(EDDYSTONE_BEACON_REQ, EDDYSTONE_BEACON_RDY, EDDYSTONE_BEACON_RST);
BLEService ledService = BLEService("19b10000e8f2537e4f6cd104768a1214");
BLECharCharacteristic switchCharacteristic = BLECharCharacteristic("19b10001e8f2537e4f6cd104768a1214", BLERead | BLEWrite);

void setup() {
  initBeacon();
}

void initBeacon() {
  Serial.begin(115200);
  #if defined (__AVR_ATmega32U4__)
  delay(5000);  //5 seconds delay for enabling to see the start up comments on the serial board
  #endif

  eddystoneBeacon.setConnectable(true);
  eddystoneBeacon.setLocalName("CANDY BOY");
  eddystoneBeacon.setAdvertisedServiceUuid(ledService.uuid());
  eddystoneBeacon.addAttribute(ledService);
  eddystoneBeacon.addAttribute(switchCharacteristic);
  eddystoneBeacon.begin(-18, "https://example.com");
}

void loop() {
  eddystoneBeacon.loop();
}

hi i use the example HID_joystick_mouse in BLEPeripheral library and i test it in cell phone. Althoung it recevied the data from BLE but it seems not control the cursor.

hi i use the example HID_joystick_mouse in BLEPeripheral library and i test it in cell phone. Actually the cell phone recevied the data from BLE like 00 0f ff 01.
because i set :
int x=15;
int y=255;
if (x || y) {
bleMouse.move(x, y,1);
Serial.println(x);
Serial.println(y);
}
but it seems not control the cursor.
i modify the code as below. I suppose it should control the cursor and i can select the item in the cell phone, like the ipeda bluetooth controller, shown as below. May you have any idea about that?
Or i need to set some configuration in GATT.
https://www.youtube.com/watch?v=Ua6MDKx2xwg

void loop() {
BLECentral central = bleHIDPeripheral.central();

if (central) {
// central connected to peripheral
Serial.print(F("Connected to central: "));
Serial.println(central.address());

while (central.connected()) {
  Serial.println(central.connected())
  int x=15;
  int y=255;
  if (x || y) {
    bleMouse.move(x, y,1);
    Serial.println(x);
    Serial.println(y);
  }
}

// central disconnected
Serial.print(F("Disconnected from central: "));
Serial.println(central.address());

}
}

Limitation on BLEPeripheral.addAttribute with 128-bit UUIDs

Hello Sandeep,

first of all, thanks a lot for that great lib. Made my first steeps on BLE very easy.
My application is a connection from iPad to BLE Nano connected to dive computers having irda or similar strange interfaces.
For setup, errorhandling and information exchange I am going to use several services and characteristics. Crossing the limit of 16 added services / characteristics showed, that all services / characteristics above 16 are not supported / processed anymore
I walked through the source but couldnโ€™t find a restriction. Can you please support me?

I tested on BLE Nano and Blend Micro (Blend Mirco has not enough RAM/ROM to go ahead with processing the dive data, so BLE Nano is in focus).
I tested with static implementation as well as dynamic (new). Appending my source. The BLEPeripheral/BLECharacteristic is modified with a EventListener to be included inside a class (maybe you can include this code into your lib (search for: // Added by Thomas Heberlein)

See DriverBLE.h/cpp for handling the BLE interface.
Archiv.zip

Regards and thanks a lot
Thomas

HID output reports? (also multiple report IDs)

Maybe I've overlooked something obvious, but are there any guides/samples to follow when using HID output reports to send data from central to the peripheral (to control LEDs, motors, etc).

I see a reference to it in the keyboard sample in the mentioned LEDs but nothing fleshed out to work from.
( ~/arduino-BLEPeripheral/examples/HID/HID_keyboard/ )

Also, is there a pointer on how to receive the data from the second or third (etc) HID report?

I ask because my reverse engineering attempts on this gaming controller at the point now where the primary button/joystick inputs in the first report work perfectly, but now I want to (attempt to) send force feedback rumble commands.

Here is the (USB derived) descriptor i'm working with if anyone's curious.


0x05, 0x01,        // Usage Page (Generic Desktop Ctrls)
0x09, 0x05,        // Usage (Game Pad)
0xA1, 0x01,        // Collection (Application)
    0xA1, 0x02,        //   Collection (Logical)
        0x85, 0x01,        //     Report ID (1)
        0x75, 0x08,        //     Report Size (8)
        0x95, 0x04,        //     Report Count (4)
        0x15, 0x00,        //     Logical Minimum (0)
        0x26, 0xFF, 0x00,  //     Logical Maximum (255)
        0x35, 0x00,        //     Physical Minimum (0)
        0x46, 0xFF, 0x00,  //     Physical Maximum (255)
        0x09, 0x30,        //     Usage (X)
        0x09, 0x31,        //     Usage (Y)
        0x09, 0x32,        //     Usage (Z)
        0x09, 0x35,        //     Usage (Rz)
        0x81, 0x02,        //     **Input** (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
        0x75, 0x04,        //     Report Size (4)
        0x95, 0x01,        //     Report Count (1)
        0x25, 0x07,        //     Logical Maximum (7)
        0x46, 0x3B, 0x01,  //     Physical Maximum (315)
        0x66, 0x14, 0x00,  //     Unit (System: English Rotation, Length: Centimeter)
        0x09, 0x39,        //     Usage (Hat switch)
        0x81, 0x42,        //     **Input** (Data,Var,Abs,No Wrap,Linear,Preferred State,Null State)
        0x66, 0x00, 0x00,  //     Unit (None)
        0x75, 0x01,        //     Report Size (1)
        0x95, 0x0C,        //     Report Count (12)
        0x25, 0x01,        //     Logical Maximum (1)
        0x45, 0x01,        //     Physical Maximum (1)
        0x05, 0x09,        //     Usage Page (Button)
        0x19, 0x01,        //     Usage Minimum (0x01)
        0x29, 0x0C,        //     Usage Maximum (0x0C)
        0x81, 0x02,        //     **Input** (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
        0x95, 0x01,        //     Report Count (1)
        0x75, 0x08,        //     Report Size (8)
        0x06, 0x00, 0xFF,  //     Usage Page (Vendor Defined 0xFF00)
        0x26, 0xFF, 0x00,  //     Logical Maximum (255)
        0x46, 0xFF, 0x00,  //     Physical Maximum (255)
        0x09, 0x00,        //     Usage (0x00)
        0x81, 0x02,        //     **Input** (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
    0xC0,              //   End Collection

    0xA1, 0x02,        //   Collection (Logical)
        0x85, 0x02,        //     Report ID (2)
        0x95, 0x07,        //     Report Count (7)
        0x75, 0x08,        //     Report Size (8)
        0x26, 0xFF, 0x00,  //     Logical Maximum (255)
        0x46, 0xFF, 0x00,  //     Physical Maximum (255)
        0x06, 0x00, 0xFF,  //     Usage Page (Vendor Defined 0xFF00)
        0x09, 0x03,        //     Usage (0x03)
        0x81, 0x02,        //     **Input** (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
    0xC0,              //   End Collection

    0xA1, 0x02,        //   Collection (Logical)
        0x85, 0x03,        //     Report ID (3)
        0x09, 0x04,        //     Usage (0x04)
        0x91, 0x02,        //     **_Output_** (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
    0xC0,              //   End Collection
0xC0,              // End Collection

// 119 bytes

// best guess: USB HID Report Descriptor

Thanks for the great work on this library, without it I would have still be stuck fighting the losing battle against nrfgo studio

Can not discover device with HID examples

Hi,

I have been trying all the samples. Scanning shows BLE device with ancs,start and test examples. But none of the other examples let me see BLE device on scans.

But when I upload HID or any other examples. Bluetooth device becomes undiscoverable. I can not see it no matter how long I wait.

I am using Arduino UNO with Adafruit BLE nrf8001.

Another thing; I could not discover BLE device on my MacBook with any of the examples. I tried with LightBlue as well.

Thank you for the great work ๐Ÿ‘

Blend Micro: Device not discoverable by Android BLE Controller app

I tried BLEControllerSketch and SimpleChat example on Blend Micro, but I can't connect to the board with BLE Controller app for Android. The board is not discoverable.
I don't have this problems with Read bear lab examples.
I'm doing something wrong? I see pins are already set correctly for blend micro.

Service locking

The size of the application I'm writing for my blend micro is starting to bump up against the limits of what it can store. I was thinking about it, and wondered if writing the config for my BLE service and characteristics to the nRF8001's OTP config would allow me to remove the BLE service setup code from the project and free up some space. Which actually first requires asking if you had any plans to add that sort of service locking to this library? Since its based in part of reverse engineering, I wasn't sure if the commands for doing such a thing were even known.

Does not work with SD library

The 0.1.7 version does not work with SD library. I think some kind of SPI setting is the problem, because if I first setup the ble, then the sd then it is not connecting, but if I set first the sd and then the ble it works. And after a while I do some sd functions, and than it is again broken.

Board specifics that need porting

I'm currently looking through the code, with the aim of porting this library to run on the STM32F4-Discovery board with an nRF8001. From what I can see, the only changes I need to make are pins, but I'm not sure this is entirely accurate. Guidance would be great in the lieu of porting documentation.

Display caller ID, message title, message etc..

First of all thank you for your help before. I hope i am not bothering you with this.I want to ask u only is there any way to display caller ID, message text etc...? Oh yes...one more thing ...do u have an error when u try to compile ancs example with U8GLIB Library?

nRF5 branch: bondStore->putData(...) does block working

pairing a device the program stops at:
experimental branch: nRF5
File: nrf51822.cpp line 717:

#ifdef NRF_51822_DEBUG
        Serial.println(F("Evt Auth Status"));
        Serial.println(bleEvt->evt.gap_evt.params.auth_status.auth_status);
#endif
        if (BLE_GAP_SEC_STATUS_SUCCESS == bleEvt->evt.gap_evt.params.auth_status.auth_status) {
#if !defined(NRF5) && !defined(NRF51_S130)
          *this->_authStatus = bleEvt->evt.gap_evt.params.auth_status;
#endif
          if (this->_bondStore) {
#ifdef NRF_51822_DEBUG
            Serial.println(F("Storing bond data"));
#endif
#if defined(NRF5) || defined(NRF51_S130)
            this->_bondStore->putData(this->_bondData, 0, sizeof(this->_bondData));  // <==!!!
#else
            this->_bondStore->putData(this->_authStatusBuffer, 0, sizeof(this->_authStatusBuffer));
#endif
          }

call setLocalName() with BLEDevice address before advertising

I am porting an Arduino code that currently uses the Nordic nRF8001 SDK to use arduino-BLEPeripheral.
Our firmware sets the visible name to include part of the local device's address. We achieved this using the Nordic SDK by requesting the address, waiting for the address to be available while pumping the event stack, and capturing the address in setup phase, then starting advertising with that name.

I tried to do this via BLEPeripheral and hit several snags:
0) I tried to do it through vanilla API actions, but couldn't. It seems like you can't access the device address until BLEPeripheral.begin() is called, and you can't change the local name/re-advertise it after begin() is called.

  1. the BLEPeripheral doesn't expose the local device address to users. I worked around this by defining a subclass of BLEPeripheral that handles BLEDeviceAddressReceived and saves the address as an instance variable.

  2. Even then, I can only do peripheral.setLocalName(value) before peripheral.begin(). Calling it after has no effect, at least it does not seem to change the name that is visible when scanning the device.

So basically my question is:

  1. is it possible to do this via the vanilla API (access the device local address, and use it to set the local name, before advertising)?
  2. if not, what is the right way to achieve this?

BondStore on RBL_nrf51822 does not write in a persistent way

working with the new master branch (and the previous one), I have mentioned that the bond store is not written to the nrf81522 program memory. For the following log I have inserted a hasData() in front of clearData() onto the BLEHIDPeripheral.clearBondStore() method:
Coupling with a central device (iOS App: BLE Tool) and switched on define NRF_51822_DEBUG, we can see following log:

Evt Prim Srvc Disc Rsp 0x0
Evt Prim Srvc Disc Rsp 0x10A
Evt Sec Params Request 0 1 1 4 0 0 16
Evt Conn Sec Update 1 2 16
Evt Auth Status
Evt Write, handle = 21
01 00 
Evt Write, handle = 25
01 00 
Evt Write, handle = 29
01 00 
Evt Write, handle = 33
01 00 
Evt Conn Param Update 0xC 0xC 0x4 0x12C
Evt Disconnected
Storing bond data

Additional question: Why is the bondstore written at the disconnect event and not before sending the BLEDeviceBonded() event in the BLE_GAP_EVT_AUTH_STATUS case?

Disconnect can be done by releasing the device in the iOS system BT configuration. At this moment I expect the bond data should be written. Rebooting my device calls clearBondstore() with a tweeked output with the bondstore.hasData() method:

ClearBondStore!
Bondstore: 0
version = 6 89 73
4
1
155
Start advertisement
BLE HID

... but the Bondstore data seems be not existent or written.

Question: Does anyone know of a "blend micro on steriods".

The Blend Micro just has ~28KB flash available which is very little if you want to use it for something a bit more serious than just playing around.. :)
It would have been nice to have a "blend micro variant" with ATmega64/128 or even 256... :) (With similar small physical footprint)

Anyone who knows of such a device?

Arne

Compile Error

Hi...i have problem with verifying example codes like ancs etc
I placed the BLEPeripheral Library normally in my documents arduino library file and opened it in arduino IDE....after hitting verify button i got this error:

 processing.app.debug.RunnerException: Couldn't create: /var/folders/cw/kgqbm6bn5v1b1h_lfcj6kbc80000gn/T/build6693720258264982059.tmp/SPI
at processing.app.debug.Compiler.createFolder(Compiler.java:705)
at processing.app.debug.Compiler.compile(Compiler.java:149)
at processing.app.Sketch.build(Sketch.java:1585)
at processing.app.Sketch.build(Sketch.java:1562)
at processing.app.Editor$DefaultRunHandler.run(Editor.java:1899)
at java.lang.Thread.run(Thread.java:695)
    Users/myname/Documents/Arduino/libraries/BLEPeripheral/BLEProgmemConstantCharacteristic.cpp: In constructor 'BLEProgmemConstantCharacteristic::BLEProgmemConstantCharacteristic(const char*, const char*)':
  /Users/myname/Documents/Arduino/libraries/BLEPeripheral/BLEProgmemConstantCharacteristic.cpp:10: error: 'strlen_PF' was not declared in this scope  
 /Users/myname/Documents/Arduino/libraries/BLEPeripheral/BLEProgmemConstantCharacteristic.cpp:10: error: 'strlen_PF' was not declared in this scope

RedBearLab Blend Micro (V1.0) & Android Marshmallow compatibility

I'm try to connect the module Blend Micro to my Nexus 5 with Android 6.0.1 and the pairing seems to work: using the HID examples (which are the ones I am interested in), the output on the serial monitor seems correct but it does not perform any "function" on my smartphone. I tried the HID_test.ino sketch, with all the 4 methods of the object bleMouse, bleKeyboard, bleMultimedia, bleSystemControl uncommented to be sure that any class works with my phone. Any suggestion?

Thanks.

P.S.: I set the correct pin

define BLE_REQ 6

define BLE_RDY 7

define BLE_RST 4

.

Sharing SPI lines with second radio

Hello, and thank you for such an awesome library to get started with BLE!

I am connecting the nRF8001 (Bluefruit Le breakout) to Arduino Uno. Changed REQ pin to 8 and changed RDY pin to 3. Works great. I then add a second radio (RFm69HW), sharing SCK, MOSI, and MISO with the nRF8001. Without adding any new code to get the second radio working, I test the nordic radio, and it still works. I then import and use this library to control the 2nd radio. Now, neither radio will initialize.

I have fallen back to the nRF8001 library used here, and both radios can work together. It is only with BLEPeripheral that the SPI communication breaks down.

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.