Project examples 100 days: Day 052 and 049 with CySmart Android

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

cross mob
FaBi_2763241
Level 4
Level 4
10 likes given 5 likes given First like received

Hello,

I can connect to a peripheral running the Day 052 example firmware (of 100 days projects) using the dongle board on the computer.

However the CySmart android app can not establish a first connection to the peripheral.

Why wouldn't connect with the phone app and write to the characteristics in the GATT DB screen similarly to what is done with Cysmart dongle?

I hope there is a workaround...

Fausto

0 Likes
1 Solution

Hello Fausto,

Can you please let us know what is the BLE device you are using. At my end I'm able to connect with the Cysmart App.
In the Cysmart App, after connection please click on the second custom service handle and write to the characteristics in the GATT DB similarly what we done in Cysmart dongle.

Thanks,
P Yugandhar.

View solution in original post

13 Replies
FaBi_2763241
Level 4
Level 4
10 likes given 5 likes given First like received

actually, I tried this: I have assigned the address using the dongle debug board and Cysmart pc, and once the peripheral is advertising as Titan, now I can connect with the Cysmart android app. But still I can't understand why the peripheral before being subscribed (named MMMMM) can not be connected to at that stage with the cysmart android app?

Fausto

0 Likes

Hello Fausto,

Can you please let us know what is the BLE device you are using. At my end I'm able to connect with the Cysmart App.
In the Cysmart App, after connection please click on the second custom service handle and write to the characteristics in the GATT DB similarly what we done in Cysmart dongle.

Thanks,
P Yugandhar.

Hello P Yugandhar

the nodes are the same as in the hardware of the example, for Android device a relatively cheap phone brand Komu model RoboL2 with Android OS 4.4

I am hoping to build a simple network for leds without the need of compliant mesh stack.

If you suspect my issue could be due to bluetooth adapter of the phone, what phones and android os have been tested to connect okay?

I could not connect to the nodes almost all times, neither could pair with any(after changing to Bonding in the Security setting of BLE component).

Are you suggesting in my case is a problem related to the adapter in the phone I am using (I have not a second phone to test and see a difference).

With the dongle it works 100% okay.

I'd like to achieve an automatic reconnection between client app and the node after it disconnects to relay data, instead of doing it manually,

could this be modified in BluetoothLeService class in app source code?

Thanks

Fausto

0 Likes

In the Android app, since you have bonding enabled on the peripheral side, you can implement the createBond() API to create the bond on initial connection:

    private void bondDevice(BluetoothDevice device) {

          try {

              device.createBond();

              Log.d(TAG, "Bonding started");  

          } catch (Exception e) {

              e.printStackTrace();

          }

    }

Then on reconnection, you can search for the bonded devices using a filter for your device as shown below and then connect:

void findBluetoothDevice(BluetoothAdapter myBluetoothAdapter,
 
String filter) {
           
Log.d(TAG, "Initialising Bluetooth connection for device: " + filter);

           
if(myBluetoothAdapter.isEnabled()) {
                 
for (BluetoothDevice pairedDevice : myBluetoothAdapter.getBondedDevices()) {
                         
if (pairedDevice.getName().contains(filter)) {
                              
Log.d(TAG, "\tDevice Name: " +  pairedDevice.getName());
                              
Log.d(TAG, "\tDevice MAC: " + pairedDevice.getAddress());

                                activeDevice
=  pairedDevice;
                               
break;
                            
}
                  
}
            
}

           
Log.d(TAG, "\tDidnt find any device!");
}

Regards,

Dheeraj

hello Dheeraj

thanks for helping out with the android api, first i must solve the problem i am having to connect using the phone as opposed to cysmart dongle.

Thanks

Fausto

0 Likes

Hello P Yugandhar

I also found that the piconet byte is not really at ADDR1 field but ADDR2 in the payload order as depicted in the PDF notes.

"The first byte indicates if the address in the payload is general addressing (0x00) or Piconet addressing (0x01). If general addressing is set, then the node will look for either 0x00 0x00 or its own 2 byte node address at ADDR1 and ADDR2 location of payload before it processes RGB data. If Piconect Addressing is set, then the node will look for only ADDR1 byte..."

therefore to address as group node example: 01.00.00.01.FF.FF.FF.FF to send full white colour at piconet 1.

firmware seems okay, but couldn't use it with phone app, beside that, it would be great to auto reconnect from client app to server node after sending a colour data.

Thanks

Fausto

0 Likes

...Another issue I am encountering is that if enabling Low Power routine it will not start the stack. I tried other low power implementations taken from other examples but had same result in this firmware.

Regards

Fausto

0 Likes

Hello Fausto,

The project is configured for lowest latency involved in transferring data between nodes. This involves frequent BLE TX/RX activity, causing higher current consumption. Do not operate the project on low power mode battery/coin cell and use only USB power. Please refer to the page no:2 in BLE_Mesh pdf for more information.

Can you please check with other phones ?

Thanks,

P Yugandhar.

0 Likes

Hello P Yugandhar

yes I did read the whole document as a reference, however the original project has a low power implementation which is disabled,

and if enabled the nodes will not start advertising...

The requirement is to use a psoc module inside a lamp powered by a solar cell of 6v and rechargeable lithium battery feeding a 2w LED.

Do you think 6-7 hours of activity at dusk shall be possible after a day of solar charge?

Currently I am trying to get hold of another phone to test cysmart app connection...

Thanks

Fausto

0 Likes
lock attach
Attachments are accessible only for community members.

Hello Fausto,

In the attached pdf, in the NOTE it was stated that due to frequent BLE TX/RX activity causes higher current consumption. Thought the project can be modified to support Low Power, it is not part of this project. So do not operate the project on battery/coin cell and use only USB power.

Please decrease the advertising interval value to some low values (for example minimum value to 30ms and maximum value to 90ms) to see node advertisement.

For battery life estimation please refer to the AN92584 datasheet which shows how to implement a low-power solution and estimation of battery life for the device.

Thanks,

P Yugandhar.

0 Likes
lock attach
Attachments are accessible only for community members.

Hello P Yugandhar

i tried another phone with android 7 but still can't connect (disabled low power, same preferred connection settings untouched).

see attached short log file from cysmart app folder. It get a disconnection gatt event. Changing preferred connection min and max didn't get any result.

What phone was tested with successfully if I may ask?

Thanks

Fausto

0 Likes

By disabling the #define ENABLE_ADV_DATA_COUNTER I can connect and discovery services with Cysmart android app, but this is not a workaround as the data count must be advertised for the colour data update.

Fausto

0 Likes

I re-enabled the macro #define ENABLE_ADV_DATA_COUNTER , in the main.c inside the InitializeSystem function I commented these lines

// new_advData.advData[ADV_DATA_NAME_START_INDEX] = 'T';

// new_advData.advData[ADV_DATA_NAME_START_INDEX+1] = 'i';

// new_advData.advData[ADV_DATA_NAME_START_INDEX+2] = 't';

// new_advData.advData[ADV_DATA_NAME_START_INDEX+3] = 'a';

// new_advData.advData[ADV_DATA_NAME_START_INDEX+4] = 'n';

// cyBle_discoveryModeInfo.advData = &new_advData;

Now with the android cysmart can connect to any of the nodes, if I enable those lines would not be able to connect.

I tried two phones and had the same result.

Regards

Fausto

0 Likes