1 2 Previous Next 24 Replies Latest reply on Sep 5, 2019 7:03 AM by VictorZ_46

    Mesh Location Client and Server in Snip folder

    PICH_4397076

      Dear All,,

       

      I hoped to find the location server and client code example, just like the other examples in demo / application.

      However, since I only searched the location server and client example in snip / application.

       

      From the mesh_location_client.c file of the mesh location code example in snip/application, I can see "mesh_app_proc_rx_cmd" function.

      Without "mesh_app_proc_rx_cmd" function,  I'm going to create and take a test any mesh communication between mesh location client and server according to broadcast mesh message.

       

      In the process, I have the following question.

       

      From the mesh_location_client.c file of the mesh location client code example, I can see "mesh_app_proc_rx_cmd" function.

      In this function, I can see "wiced_bt_mesh_create_event_from_wiced_hci" function.

       

      To use without "mesh_app_proc_rx_cmd" function, I'm going to call "wiced_bt_mesh_create_event" function instead of "wiced_bt_mesh_create_event_from_wiced_hci" function.

       

      Question 1 : To call "wiced_bt_mesh_create_event" function directly, how can I put app_key_idx among the function argument?

      (As you know, in case of using "mesh_app_proc_rx_cmd" function, the value of the command packet is parsed and inserted)?

       

      Question 2: In case of "wiced_bt_mesh_create_event" function, I can see the description below at API reference.

      But, I can not understand fully about this function.

      Please explain in detail so that I can understand???

       

      ===========================================================================================================================

      /**

      * \brief Create mesh event for an unsolicited message.

      * \details In case dst is 0 the function takes all information from the model's publication or fails if publication is not configured for the specified model.

      * In case non-0 dst the function uses specified dst and app_key_idx and fills all other fields with default values.

      * In special case with company_id equals to 0xffff the function creates a message event with default ttl.

      *

      * @param      element_index  Element index.

      * @param      company_id      Company ID.

      * @param      model_id        Model ID.

      * @param      dst            Destination address. If parameter is 0, the function finds publication and take uses its fields for the mesh event.

      * @param      app_key_idx    Global app key index. The parameter is ignored if dst is equal to 0. The 0xffff means device key.

      *

      * @return      p_event Pointer to a newly allocated mesh event.

      */

      wiced_bt_mesh_event_t *wiced_bt_mesh_create_event(uint8_t element_index, uint16_t company_id, uint16_t model_id, uint16_t dst, uint16_t app_key_idx);

      =============================================================================================================================

       

      Question 3: Using the client control mesh application, I'll be a beginner with a guide on how to test the location mesh client and server in the snip folder and follow the instructions as directed?

        • 1. Re: Mesh Location Client and Server in Snip folder
          PICH_4397076

          Dear All,,,

           

          Question 3 is solved.

          Please provide feedback to me on Question 1 and 2.

           

          Thanks,,,

          • 2. Re: Mesh Location Client and Server in Snip folder
            PICH_4397076

            Dear All,,,

             

            Any update for us?

             

            Thanks,

            • 3. Re: Mesh Location Client and Server in Snip folder
              VictorZ_46

              In BLE mesh, the Provisioner/Configuration Manager is responsible to configure everything.  For example, if you use a phone, to provision your device, the phone will read the Composition Data of your device and discover that your device has a Location Client.  Among other things, the phone will add an application key,  it will bind the Location Client model to this application key, and it will configure Location Client model to publish messages to the specific destination address.

               

              When your application calls wiced_bt_mesh_create event, it should use zeroes for dst and app_key_idx. If your device was properly configured for publication, the mesh core will fill all required values (dst, app_key_idx, ttl, retransmission params,...).  If your device is not property configured for publications the function will return NULL and you should not try to send anything. 

               

              To test your applications, I wonder if it will be easier to use MeshClient to provision your devices. The document should be installed with your SDK. If you create a group before provisioning the devices, and then set Current group to be the group you created, the Mesh Client will configure Location Client to publish messages to the group and configure Location Server to subscribe to messages sent to this group.

              1 of 1 people found this helpful
              • 4. Re: Mesh Location Client and Server in Snip folder
                PICH_4397076

                Dear All,,,

                 

                I have one more question!

                 

                After calling wiced_bt_mesh_create_event() function, when should I call  wiced_bt_mesh_release_event() function???

                 

                Thanks,

                • 5. Re: Mesh Location Client and Server in Snip folder
                  VictorZ_46

                  Typically you pass the event down to the mesh stack, and the event is released by the stack when the message is sent out.  If you created an event and for some reason decided not to send it, you should definitely release it.

                   

                  When you receive an event, and you do not need to send a reply using the same event, you should release it.

                  • 6. Re: Mesh Location Client and Server in Snip folder
                    PICH_4397076

                    Dear All,,,

                     

                    I modified the mesh location client code provided by Cypress with the attached file. To get global location information from mesh location server every 10 seconds.

                     

                    The attached modified code is using the Generic appKey index value for app_key_idx in the JSON file generated by provisioning and the 0xffff meaning broadcast message for dst  iwhen creating the event.
                    I've seen that with the modified code, I get the global location value from the mesh location server as well.

                     

                    But, You gave the following in the previous comments:

                    =====================================================================

                    When your application calls wiced_bt_mesh_create event, it should use zeroes for dst and app_key_idx. If your device was properly configured for publication, the mesh core will fill all required values (dst, app_key_idx, ttl, retransmission params,...).  If your device is not property configured for publications the function will return NULL and you should not try to send anything.

                    ===========================================================

                     

                    So, Could you please review the attached code, what's wrong with my purpose?

                     

                    Thanks,

                    • 7. Re: Mesh Location Client and Server in Snip folder
                      VictorZ_46

                      If your device is a provisioner and has access to the mesh database, your method will indeed work (although I would not recommend to use broadcast).

                       

                      If your device is not a provisioner, the provisioner needs to configure your device so that when you want to publish your message, you know the destination address, application key index and other parameters.

                      • 8. Re: Mesh Location Client and Server in Snip folder
                        PICH_4397076

                        Dear all,,,

                         

                        Would you please try my modified code attached.

                         

                        When I create an event like this, if dst and app_key_idx are set to 0, no event is generated and always null.

                        =================================================================

                        wiced_bt_mesh_event_t *p_event = wiced_bt_mesh_create_event(MESH_LOCATION_CLIENT_ELEMENT_INDEX, MESH_COMPANY_ID_BT_SIG, WICED_BT_MESH_CORE_MODEL_ID_GENERIC_LOCATION_CLNT, 0, 0);

                        =================================================================

                         

                        The below is console capture.

                        =====================================================================

                        location restart timer:10000

                        pool size/cur/max/total 64/5/17/42 140/0/3/20 376/0/3/12 1024/0/0/3

                        Pub needed period

                        wiced_bt_mesh_create_event error!!!

                        location restart timer:10000

                        Pub needed period

                        wiced_bt_mesh_create_event error!!!

                        location restart timer:10000

                        Pub needed period

                        wiced_bt_mesh_create_event error!!!

                        location restart timer:10000

                        =====================================================================

                         

                        What does it mean about "If your device is not property configured for publications"???

                        And, How to do for property configured for publications???

                         

                        Thanks,

                        • 9. Re: Mesh Location Client and Server in Snip folder
                          VictorZ_46

                          How did you provision/configure your device.  You device is probably not configured for publication.

                          • 10. Re: Mesh Location Client and Server in Snip folder
                            PICH_4397076

                            Here is what I tested:

                             

                            First, the following 1 to 5 are the test methods that Cypress has informed.

                             

                            Steps: (1~5)

                            1. Download mesh_provision_client  and mesh_location_server on two devices. (make sure you enable location_client model for mesh_provision_client by selecting 'change application settings')
                            2. Open ClientControl - Light Control tab and open COM port of the mesh_provision_client device. And then, provision location_server device.
                            3. Note down the address allocated to mesh_location_server device (Eg: 0002).
                            4. Goto ClientControl directory (.\components\BT-SDK\common\apps\snip\mesh\ClientControl\Release) and open Network.JSON. And check the appKeys generated.
                            5. Select model tab on MeshClientControl and use appropriate destination address and app_key_index. (For GET messages you have to use Generic appKey index and for SET messages you have to use Setup appKey index.)
                            6. Select location from the drop down menu and then use location commands (GET/SET) to change it’s parameters.

                             

                            In this way I successfully sent and received location information via get / set message on clientcontrol model tab.

                             

                            After that, I modified the mesh location client code provided by Cypress with the attached file and want to get global location information from mesh location server every 10 seconds.

                            (Pls, refer to the attached file)

                             

                            Step (7~8)

                             

                            6.Download the modified code to the new device.

                            7.Added new device (modified mesh location client) to mesh network. On ClientControl, Light Control tab and open COM port of the mesh_provision_client device. And then, provision location_client device

                             

                            When an event is generated from the modified code, dst is used 0xffff as the meaning of broadcast message and generic app_key index is used in the existing JSON file for app_key_idx. As shown below, the global location information is imported.

                            Pub time:4408505

                            location restart timer:10000

                            company_id:ffff opcode:40

                            location clt msg:4

                            Global lat/long/alt:4/5/6

                            no trans buffer

                            pool size/cur/max/total 64/5/18/42 140/1/3/20 376/0/3/12 1024/0/0/3

                            Pub needed period

                            location clt msg:255

                            tx complete status:2

                            no trans buffer

                            company_id:ffff opcode:8225

                            ignored

                            wiced_bt_mesh_model_location_client_send_global_get: 0

                            Pub time:4418509

                            location restart timer:10000

                            company_id:ffff opcode:40

                            location clt msg:4

                            Global lat/long/alt:4/5/6

                            no trans buffer

                            Pub needed period

                            9. As your instructions, when I create an event, dst and app_key_idx are set to 0, no event is generated and always null
                            The below is capture screen..

                            location restart timer:10000

                            pool size/cur/max/total 64/5/17/42 140/0/3/20 376/0/3/12 1024/0/0/3

                            Pub needed period

                            wiced_bt_mesh_create_event error!!!

                            location restart timer:10000

                            Pub needed period

                            wiced_bt_mesh_create_event error!!!

                            location restart timer:10000

                            Pub needed period

                            wiced_bt_mesh_create_event error!!!

                            location restart timer:10000

                             
                            From your instructions, I think I provisioned the test I wanted, but I didn't configure that device.
                            Please let me know how to provision and configure the device for the test I want.
                            • 11. Re: Mesh Location Client and Server in Snip folder
                              PICH_4397076

                              Here is what I tested:

                               

                              First, the following 1 to 5 are the test methods that Cypress has informed.

                               

                              Steps: (1~5)

                              1. Download mesh_provision_client  and mesh_location_server on two devices. (make sure you enable location_client model for mesh_provision_client by selecting 'change application settings')
                              2. Open ClientControl - Light Control tab and open COM port of the mesh_provision_client device. And then, provision location_server device.
                              3. Note down the address allocated to mesh_location_server device (Eg: 0002).
                              4. Goto ClientControl directory (.\components\BT-SDK\common\apps\snip\mesh\ClientControl\Release) and open Network.JSON. And check the appKeys generated.
                              5. Select model tab on MeshClientControl and use appropriate destination address and app_key_index. (For GET messages you have to use Generic appKey index and for SET messages you have to use Setup appKey index.)
                              6. Select location from the drop down menu and then use location commands (GET/SET) to change it’s parameters.

                               

                              In this way I successfully sent and received location information via get / set message on clientcontrol model tab.

                               

                              After that, I modified the mesh location client code provided by Cypress with the attached file and want to get global location information from mesh location server every 10 seconds.

                              (Pls, refer to the attached file)

                               

                              Step (6~9)

                               

                              6.Download the modified code to the new device.

                              7.Added new device (modified mesh location client) to mesh network. On ClientControl, Light Control tab and open COM port of the mesh_provision_client device. And then, provision location_client device

                               

                              8.When an event is generated from the modified code, dst is used 0xffff as the meaning of broadcast message and generic app_key index is used in the existing JSON file for app_key_idx. As shown below, the global location information is imported.

                              *** Console Capture ***

                              Pub time:4408505

                              location restart timer:10000

                              company_id:ffff opcode:40

                              location clt msg:4

                              Global lat/long/alt:4/5/6

                              no trans buffer

                              pool size/cur/max/total 64/5/18/42 140/1/3/20 376/0/3/12 1024/0/0/3

                              Pub needed period

                              location clt msg:255

                              tx complete status:2

                              no trans buffer

                              company_id:ffff opcode:8225

                              ignored

                              wiced_bt_mesh_model_location_client_send_global_get: 0

                              Pub time:4418509

                              location restart timer:10000

                              company_id:ffff opcode:40

                              location clt msg:4

                              Global lat/long/alt:4/5/6

                              no trans buffer

                              Pub needed period

                               

                              9.As your instructions, when I create an event, dst and app_key_idx are set to 0. no event is generated

                              and always null is returned.

                              *** Console Capture ***

                              location restart timer:10000

                              pool size/cur/max/total 64/5/17/42 140/0/3/20 376/0/3/12 1024/0/0/3

                              Pub needed period

                              wiced_bt_mesh_create_event error!!!

                              location restart timer:10000

                              Pub needed period

                              wiced_bt_mesh_create_event error!!!

                              location restart timer:10000

                              Pub needed period

                              wiced_bt_mesh_create_event error!!!

                              location restart timer:10000

                               

                              From your instructions, I think I provisioned the test I wanted, but I didn't configure that device.

                              Pls, let me know how to provision and configure the device for the test I want.

                              • 12. Re: Mesh Location Client and Server in Snip folder
                                VictorZ_46

                                1. Download mesh_location client on one board, and mesh_location_server on another board.

                                2. Start MeshClient (you can also use ClientControl with a third board running mesh_provision_client). 

                                3. Type in network name, click Create and then Open.

                                4. Type in Group name, click on Create

                                5. Select newly created group in the Current group box,

                                6. Scan unprovisioned/stop scan/provision for the first device (does not matter which one)

                                7. Scan unprovisioned/stop scan/provision for the second device

                                 

                                I believe your client should be now publishing location data to the Group address (most likely 0xC000) and your server should be processing location commands because it is subscribed to the group address 0xC000.

                                 

                                You can check JSON file to see if client is configured for publication and if server is configured for subscription.  You can also check trace.txt to see what Configuration Manager was doing.  You should see Add Key, Subscription Change....

                                 

                                You can also reconfigure your client to publish to different address.  In the MeshClient select Use Device / Configure Publication. (I am not sure it will work, because it has been tested with lighting scenarios).

                                 

                                It is also possible to do using Configuration tab of the Client Control, but its a bit painful.  Not sure what your goal is.

                                1 of 1 people found this helpful
                                • 13. Re: Mesh Location Client and Server in Snip folder
                                  PICH_4397076

                                  Dear All,,,

                                   

                                  I have tested many times as instructed below.

                                   

                                  1. Download mesh_location client on one board, and mesh_location_server on another board.

                                  2. Start MeshClient (you can also use ClientControl with a third board running mesh_provision_client).

                                  3. Type in network name, click Create and then Open.

                                  4. Type in Group name, click on Create

                                  5. Select newly created group in the Current group box,

                                  6. Scan unprovisioned/stop scan/provision for the first device (does not matter which one)

                                  7. Scan unprovisioned/stop scan/provision for the second device

                                   

                                  But, I wasn't successful, it fails on event creation in the attached code, and returns null.

                                   

                                  So I attached json file for provisioning and configure.
                                  I haven't seen publish information in the json file.

                                  Would you please review the attached json file?

                                   

                                  And, Let me know how to check trace.txt you informed?

                                   

                                  Thanks,,,

                                  • 14. Re: Mesh Location Client and Server in Snip folder
                                    VictorZ_46

                                    Please check if attached would work for you

                                    1 of 1 people found this helpful
                                    1 2 Previous Next