11 Replies Latest reply on May 5, 2016 8:42 PM by huangj

    Multiple Slave Write command

    huangj

      Hi all,

       

      I have 4 custom boards. One is master base on Hello_client. The others are slave base on Hello_sensor.

       

      I try to send write command to all hello_sensor. I use the API like this:

       

      bleprofile_sendWriteCmd(handle, data, data_size);

       

      But only one slave can receive the command packet.

       

      What is the method can send packet to all slave?

        • 1. Re: Multiple Slave Write command
          ChristopherA_76

          Hi Jack,

           

          Have you given all your devices unique BD_ADDRs?

           

          Gregg

          • 2. Re: Multiple Slave Write command
            huangj

            Hi ChristopherA_76

             

            Thank for your response.

             

            Yes, I add different address with my make target(BT_DEVICE_ADDRESS=XXXXXXXXXXXX).

             

            All slaves are same firmware. It mean the GATT is same.

             

            Jack,

            • 3. Re: Multiple Slave Write command
              huangj

              Could you have any suggestion and comment for changing the GATT database of slave handle on run time?

              • 4. Re: Multiple Slave Write command
                BoonT_56

                Thinking out loud, if you know the BD address of the four servers, perhaps you can try doing it from the whitelist approach.

                • 5. Re: Multiple Slave Write command
                  huangj

                  Hi boont,

                   

                  Thank for your comment.

                   

                  How can I use the whitelist to implement it?

                   

                  Here is my assumption:

                   

                  1.The master would like to send data1 to slave 1 and slave 2.

                   

                  2.The master connect to slave 1 by whitelist, and then send the packet.

                   

                  3.The master will disconnect with slave 1 after send the packet.

                   

                  4.The master will connect to slave 2 by whitelist, and then send the packet.

                   

                  5.The master will disconnect with slave 2 after send the packet.

                   

                  6.The master would like to send data2 to slave 1 and slave 2. => go to step1

                   

                  Is the assumption right?

                   

                  Jack,

                  • 6. Re: Multiple Slave Write command
                    BoonT_56

                    Your algorithm is correct. By having a whitelist, your client will know exactly which server (defined by the known BD address on its whitelist) to send its data to. And doing this for one server at a time.

                    • 7. Re: Multiple Slave Write command
                      huangj

                      Hi boont,

                       

                      Thank for your comment.

                       

                      In addition to using the whitelis send packet to multiple slaves, I have another idea. But not sure the ideal is feasible.

                       

                      Here is the work flow:

                       

                      1.The two slaves are the same firmware, and it mean the GATT is the same.

                       

                      2.The master connect to slave1(GATT1).

                       

                      3.The master connect to slave2, and then the slave2 will switch to GATT2.

                       

                      4.The master would like to send dataA to all slaves.

                      for(){

                           bleprofile_sendWriteCmd(Slave1 GATT1 handle, dataA, sizeof(dataA))

                           bleprofile_sendWriteCmd(Slave2 GATT2 handle, dataA, sizeof(dataA))

                      }

                       

                      The slave1 and slave2 is different GATT, so it has different handle. Is it possible switch GATT after APPLICATION_INIT?

                       

                      Jack,

                      • 8. Re: Multiple Slave Write command
                        BoonT_56

                        It sounds kind of like odd to me, but you can try. Unless you have some have very good reasons, perhaps let's stick to known methodologies.

                        • 9. Re: Multiple Slave Write command
                          huangj

                          Hi boont,

                           

                          I hope that all the slaves stay connected, so I don't want to use a whitelist approach.

                           

                          Did BRCM support sample code for  multiple slaves write command?

                           

                          Jack,

                          • 10. Re: Multiple Slave Write command
                            BoonT_56

                            The 20737 device supports a piconet just like your scenario where there are one master and a few slaves. Check out

                            the "Multiple Slaves" in the below thread where this feature is demonstrated using hello_client/sensor.

                             

                            Testing Master and Slave Roles

                            • 11. Re: Multiple Slave Write command
                              huangj

                              Hi boont,

                               

                              Thank for your help.

                               

                              I have already see the  article. The case is multiple slaves send packet to the master. But I can't find the sample that master can send the packet to multiple slaves. I found the answer in the thread:hello-client switch to slaves after smartphone connectes. The master will create unique HCI handle in each connection.If the master would like to send packet to the slave1, and the master must to switch handle to handle1(unique HCI handle for slave1).

                               

                              Master would like to send packet to all slaves, and the code was shown as following:

                               

                              UINT8 con_index;

                              for (con_index = 0; con_index < HELLO_CLIENT_MAX_SLAVES; con_index++)     {

                                    hello_client.dev_info[con_index].connHandle);

                                    blecm_SetPtrConMux(hello_client.dev_info[con_index].connHandle);

                                    bleprofile_sendWriteReq(HANDLE, data, datasize);

                              }

                               

                              Jack,