sandeepmistry / arduino-BLEPeripheral

An Arduino library for creating custom BLE peripherals with Nordic Semiconductor's nRF8001 or nR51822.
MIT License
462 stars 179 forks source link

Interesting idea...BUT FAILING! #131

Closed laynier closed 7 years ago

laynier commented 7 years ago

Hello! I am working with your arduino-BLEPeripheral libraries for an eddystone URL beacon and it works great! however I wanted to add configuration by bluetooth as well, so I am thinking to combine one of the serial examples with the eddystone. This is, works like a serial for a while, maybe 40 second at begining or until string is received by serial, only to receive the url string and then I want to end serial and start eddystone. But it is not working! could I get some help please? I have an ArduinoUno+nRF8001. It also says it has low memory and could be unstable. I see it does not works to get the data, maybe the end() function is not finishing the serial object? maybe something is missing here... I add the example for you to understand better.

include

include

include "BLESerial.h"

include

// define pins (bluefruit)

define BLE_REQ 10

define BLE_RDY 2

define BLE_RST 9

// create ble serial instance, see pinouts above BLESerial BLESerial(BLE_REQ, BLE_RDY, BLE_RST);

EddystoneBeacon nowBeacon() { BLESerial.end(); //this not working :´( EddystoneBeacon newBeacon = EddystoneBeacon(10, 2, 9); //Then it looks like it never arrives here! newBeacon.setLocalName("BeaconArduino"); newBeacon.begin(-18, "http://thepandabear.com"); // power, URI newBeacon.loop(); }

void setup() { // custom services and characteristics can be added as well BLESerial.setLocalName("UART");

Serial.begin(115200); BLESerial.begin(); }

void loop() { BLESerial.poll();

forward(); // loopback(); // spam();

nowBeacon(); }

Thank you so much for your time! Best regards,

sandeepmistry commented 7 years ago

@laynier if you take a look at the code for BLESerial and EddystoneBeacon they both extend BLEPeripheral so 2 instances will conflict with each other.

For advanced stuff like this, I would suggest you not use these helper classes. Instead build your own code that combines the aspects you are interested in manually.