BluzDK and Lighblue app


#1

Hi!,it is possible to connect lighblue app with BluzDK device? … i tried, but, at first, it can connects to BluzDK. In addition, when i use nRF Connect app, i can connect to BluzDK … but in case it is running the code from “Local Communication” tutorial, it is possible to receive data from nRF Connect in order to BLuzDK send data back up?
thanks


#2

Are you trying to send data from an app to bluz DK for local communication? Or are you trying to send data to bluz to get sent to the cloud?

It could be possible to communicate with bluz from other apps, through clearly this isn’t something we have tested or know if it would work. I haven’t tried to use either of those apps with bluz before.

If you just want to send data from the phone to bluz, it would be a good feature for us to add to our own app. You could then just send down bytes from the app. I will put that on the list of features we will try to tackle in the next release.


#3

Hi @eric! … yes, i’m trying to send data from an app to the bluzdk device … i’m using BLE Scanner and it is OK for sending write/read commands to/from BluzDK … my question arises since i’ve been successfully using Lightblue (iOS) with other BLE devices, but apparently, it can not connect to BluzDK.


#4

We haven’t tested using bluz with the LightBlue app, so I can’t really say what the problem there would be.

It could be possible to send data from another BLE app, but it would have to be in a specific format that bluz understands, so it may be difficult.

It may be easiest for us to add the ability to send data from our app, that would be the most complete solution. Are you using iOS or Android?


#5

… i’m using both. BLEScanner is available for Android, and using some info i found on the forum regarding the data format for bluzdk (0x04 + Data + 0x0304) i successfully send some data to bluzDK from BLEScanner.


#6

Oh, great, so it works?


#7

… using BLEScanner app as Central device, yes, it worked. Not with Lightblue app. In addition, i successfully connected a RedBear Duo as Central with a BluzDK as Peripheral.
Best regards


#8

@fbtobajas: Can you provide some instructions on how you were able to send data down to the bluz over local communication with the BLEScenner app?

@Amitt and @Priya are trying to do the same thing. Any help you can give would be greatly appreciated. Thanks!


#9

Hi @eric, @fbtobajas & @Priya

I am trying to control D7 led from nrfconnect app. I am not getting where to specify data which will be sent to my bluzDK.

Please provide me the instructions. :slight_smile:

Thanks :slight_smile:


#10

The same issue I am having.
Please tell me anyone :slight_smile:


#11

Hi @Priya @Amitt and @eric … i’ll try to do my best to provide you the main issues required in order to control D7 led of BluzDK, from nRFConnect app. First, you can use the following example code to program the BluzDK device:

#include "application.h"
SYSTEM_MODE(MANUAL);

bool sendData = false;
uint16_t sav_length;
uint8_t sav_data[20];
uint8_t rsp_data[20];

void dataCallbackHandler(uint8_t *data, uint16_t length) {
    sav_length = length;
    for (int i=0; i<length; i++) sav_data[i] = *data++;
    sendData = true;  
}

void setup() {
    pinMode(D7, OUTPUT);
    
    BLE.registerDataCallback(dataCallbackHandler);

    pinMode(D6, INPUT_PULLDOWN);
    if (digitalRead(D6) == HIGH) {
        SYSTEM_MODE(AUTOMATIC);
    }
}

void loop() {
    System.sleep(SLEEP_MODE_CPU);
    if (sendData)
    {
        rsp_data[0] = 'H';
        rsp_data[1] = 'i';
        for (int i=0; i<sav_length; i++) rsp_data[i+2] = sav_data[i];
        
        BLE.sendData(rsp_data, (sav_length+2));
        switch (sav_data[0]) {
            case 0x6e: // led D7 ON
                digitalWrite(D7, HIGH);
                 break;        
            case 0x6f: // led D7 OFF
                digitalWrite(D7, LOW);
                break;
        }
       
        sendData = false;
    }
}

According to this code, D7 will turn ON when BLuzDK device receives from nRFConnect app the command 0x6E, and it will turn OFF when it receives the command 0x6F. So, once launched nRFConnect app (in my particular case on an Android device), you should find the BluzDK. Once you connect to BLuzDK, nRFConnect app will discover the services/characteristics/descriptors from BLuzDK, as shown in the following figure:

In order to send the 0x6e command to the BLuzDK device, you have to append a 1-byte header (0x04) and to send a final 2-bytes tail (0x0304) in order to BLuzDK to successfully process the command. So, on nRFConnect app you have first to select the write option from Characteristic with UUID 871e0225-… (the option with the arrow pointing up), and in the menu that appears, specify the value of the first packet you have to send to BluzDK, with the value 0x046e, as you can see on the following figure:

After you send it, you have to repeat the same procedure to send a second packet, but with the value 0x0304. If it works OK, you should see the D7 led turning ON on the BLuzDK device. Finally, you can also check the response packet sent from BluzDK to nRFConnect app. For that purpose, you have to select the read option from Characteristic with UUID 871e0224-… (the option with the arrow pointing down), and you will receive the vaue 0x04 4869 6e, corresponding to the 1-byte header (0x04), the hex values for ‘H’ ‘i’ ascii characters (0x4869) and the command received by BluzDK (0x6e), as you can see on the following figure:

I hope you find these instructions useful. best regards.


#12

Thank you @fbtobajas for providing us so detailed view of everything. Everything is clear now. :slight_smile:


#13

Awesome, thanks for he write up!


#14

Thanks Everyone :slight_smile:


#15

Hi @eric and @fbtobajas,
Suppose if I want to send the data 0xFFFF instead of 0x6E, then Please tell me How can I do this?


#16

It seems you type the value you would like to send into the app. There is a screenshot above that shows where you can enter in any data you would like to send.


#17

Thanks @eric but I wanted to send the specific type of data. I have tried that but 0xFFFF is uint16_t type data and 0x6E is uint8_t type data, because of this the bluz is not reading the data. So I think, I have to change the type of data first but I am not getting where should I exactly change this.

Please help!


#18

The data handler on bluz just takes a byte array, so an array of uint8_t types. So if you typed in 0x04FFFF into the app, it should arrive as a 2-byte long array in the data callback handler. Is that not what you are seeing?


#19

When I am sending a bye array of 0x04FFFF and reading the data on the characteristics, I am getting something like this:

After this, when I send the data 0x0304, It doesn’t work.

Thank you @eric for your help :slight_smile:


#20

What are you expecting this to do? Does bluz listen for the data 0xFFFF and re-send it back to the phone? Can you post the code running on bluz? I am unclear as to the expected outcome