13 Replies Latest reply on Mar 31, 2019 2:00 AM by FaBi_2763241

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

    FaBi_2763241

      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

       

        • 1. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
          FaBi_2763241

          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

          • 2. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
            PY_21

            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.

            1 of 1 people found this helpful
            • 3. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
              FaBi_2763241

              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

              • 4. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
                FaBi_2763241

                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

                 

                 

                • 5. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
                  DheerajK_81

                  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

                  1 of 1 people found this helpful
                  • 6. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
                    FaBi_2763241

                    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

                    • 7. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
                      FaBi_2763241

                      ...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

                      • 8. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
                        PY_21

                        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.

                        • 9. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
                          FaBi_2763241

                          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

                          • 10. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
                            PY_21

                            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.

                            • 11. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
                              FaBi_2763241

                              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

                              • 12. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
                                FaBi_2763241

                                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

                                • 13. Re: Project examples 100 days: Day 052 and 049 with CySmart Android
                                  FaBi_2763241

                                  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