Receiveing uint32 variable from PSoC 4 BLE via AppInventor’s BLE extension

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
EfAv_4380776
Level 1
Level 1

Hello everyone , I'm trying to read a sensor's data from PSoC4 BLE kit and display it on my android phone (Xiaomi Mi 9).

For this I have configured the BLE module of the PSoC's 4 BLE as a peripheral GAP and a GATT Server with a Custom Service. The characteristic has the read and notify properties, plus I have the UUID for service and characteristic. The value's type I'm trying to get is uint32.

I know it's working because I've read the value using CySmart App for debugging and it also works on the BLE Scanner app.

So far, the app connects succesfully to the PSoC but I don't seem to get the data.

I attach the app inventor project. If more info is needed please let me know

Thanks, I appreciate your help

0 Likes
1 Solution

This is what happens in the Android code when you click on Notify button.

void prepareBroadcastDataNotify(

            BluetoothGattCharacteristic gattCharacteristic) {

        Logger.i("Notify called");

        final BluetoothGattCharacteristic characteristic = gattCharacteristic;

        final int charaProp = characteristic.getProperties();

        if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {

            BluetoothLeService.setCharacteristicNotification(characteristic,

                    true);

        }

    }

In AppInventor, you need to call the function setCharacteristicNotification that is part of BluetoothLEService class. You can find the API reference information here.

When you click Read, the function readDescriptor is called. You can find more information on this API here.

BluetoothLeService.readDescriptor(mDescriptor);

Note that this function only initiates the read operation and returns a boolean. The actual value of the descriptor needs to be read in the GATT callback onDescriptorRead().

Hope this helps

Regards,

Dheeraj

View solution in original post

0 Likes
3 Replies
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

I could not able to open the project attached by you. The attachment contains only .aia file.

As per my understanding, you are not able to send the notification to the client application. Am I correct? If yes, what is the application you are mentioning?

Please find the attached project, where I am able to send the notifications to Client (which is CySmart android app in my case). You can press '1' on your keyboard after connection to send the notifications from psoc 4 ble to Client. Please note that you have to enable notifications from the Client application before sending notifications.

Please go through the attached project and let us know if you have any queries.

Thanks

Ganesh

0 Likes

Hello! thanks for your reply

The .aia file is the app inventor's project.

My PSoC's project is working because using the CySmart Android App I can read the uint32 in hex values. What I'm trying to accomplish is to get the data on an android app developed using MIT App Inventor

This is what I'm trying:

blocks.png

I get I need to activate the notifications from the client to the server using this app but I don't understand what exactly CySmart App does when you press the Notification button and then the Read button.

In order to setup my BLE component on the PSoC I followed the tutorial series:
How to Create a PSoC Android BLE App: Lesson 4 Write the Firmware - YouTube

Unluckily for me, I don't have the required knowledge to develop the android's app using android studio

greetings

0 Likes

This is what happens in the Android code when you click on Notify button.

void prepareBroadcastDataNotify(

            BluetoothGattCharacteristic gattCharacteristic) {

        Logger.i("Notify called");

        final BluetoothGattCharacteristic characteristic = gattCharacteristic;

        final int charaProp = characteristic.getProperties();

        if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {

            BluetoothLeService.setCharacteristicNotification(characteristic,

                    true);

        }

    }

In AppInventor, you need to call the function setCharacteristicNotification that is part of BluetoothLEService class. You can find the API reference information here.

When you click Read, the function readDescriptor is called. You can find more information on this API here.

BluetoothLeService.readDescriptor(mDescriptor);

Note that this function only initiates the read operation and returns a boolean. The actual value of the descriptor needs to be read in the GATT callback onDescriptorRead().

Hope this helps

Regards,

Dheeraj

0 Likes