1 2 Previous Next 25 Replies Latest reply on Jun 9, 2020 2:48 AM by DheerajP_41

    we need help with BLE MESH

    jama_4535901

      Good afternoon

      could you help me this is urgent

      I have 2 code with CYBT-213043-MESH

       

       

      1- It is a code that scans and can the mac adress or host of the devices that are nearby, and prints them on the line: WICED_BT_TRACE ("Host =% B RSSI:% d \ r \ n", p_scan_result-> remote_bd_addr, p_scan_result-> rssi); (this code works fine)

       

       

      2- It is the vendor specific code modified so that when it receives the message ("0x670x650x740x730x740x6c"), it responds with the same message or another message to the board with the code: Provision client / vendor client, (this code works well)

       

       

      I want to combine these 2 codes, so that the board with this code can receive the message ("0x670x650x740x730x740x6c") and then it responds with the message saved in the line: WICED_BT_TRACE ("Host =% B RSSI:% d \ r \ n ", p_scan_result-> remote_bd_addr, p_scan_result-> rssi);

       

       

      please

      I want you to review these codes, and we need you to combine these 2 codes

       

       

      In our work we want to buy 3000 or more BLE modules, but we only need this to buy BLE modules

        • 1. Re: we need help with BLE MESH
          DheerajP_41

          Hi,

           

          let me have a look at your code. I will try to give a simple solution to this problem soon.

           

          Thanks,

          -Dheeraj

          • 2. Re: we need help with BLE MESH
            jama_4535901

            Good morning

            excuse me

            could you try the codes and create a new one?

            we are very urged by this code

             

            I will greatly appreciate your responses

             

            If you want, our company can contact you by phone or email to explain any questions, I can give you the details of our company and our projects

             

            please help us with the code that I explain to you

            this is very urgent and very important for our company

            I will greatly appreciate your responses

            • 3. Re: we need help with BLE MESH
              DheerajP_41

              Hi,

               

              I have gone through the code.

               

              Let me give you a brief info about the mesh implementation.

              The mesh application is implemented in mesh_application.c This is a Top-level file containing application_start, stack initialization, Bluetooth management callback function, and other helper functions. You will be able to find wiced_bt_cfg.c which contains Runtime Bluetooth stack configuration parameters in btsdk-mesh library which is used by the mesh application.

              Current mesh application uses wiced_bt_ble_observe() which will filter the scan results to allow non-connectable packets. The function which is used star start and stop the scanning is mesh_start_stop_scan_callback(). And mesh_adv_report() will receive the adv packets. This scan is continuously done in background as and when requested by the core.

               

              You can call wiced_bt_ble_scan() inside the vendor_specific_app.c with the callback function myScanCallback(). It should take the bluetooth stack configuration from wiced_bt_cfg.c. Then you can Store the scan result and provide whenever you want. But make sure this scanning and following procedure/processes do not interfere with the mesh functionality.

               

              But, I would like to understand why do you need a scan function inside the vendor_specific app?

               

               

              I would suggest you to follow the coding convention that we follow in Modustoolbox. Keep separate files for main application, wiced_bt_cfg, etc. Also, I found that you are using two different timers for wiced_bt_ble_scan which may not be necessary (please check it once). Please have a look at the lab manual example projects which will be helpful for you to understand the usage of APIs. Lab Manual: Click Here

               

              Thnaks,

              -Dheeraj

              1 of 1 people found this helpful
              • 4. Re: we need help with BLE MESH
                VictorZ_46

                Hi Martinez,

                 

                I tried to read messages in the thread, but I am still not clear what you want to do. If I understand correctly you want to use mesh_provision_client on one side and mesh_vendor_specific_app on another side. But you want to modify the content of the message that is sent in mesh_vendor_server_send_data, and the content of the message should depend on what advertising packets you receive. If this is what you need, this should be very simple to do. The mesh_vendor_specific_app is scanning as close to 100% as possible and receives and processes all adverts. This is done (I assume you are using ModusToolbox) in the wiced_btsdk/dev-kit/libraries/btsdk-mesh/COMPONENT_mesh_app_lib/mesh_application.c in the function mesh_adv_report. For example, if you want to count number of adverts sent by a device with Bluetooth Device Address 010203040506 you can modify function as

                 

                // Handle received adv packet

                static void mesh_adv_report(wiced_bt_ble_scan_results_t *p_scan_result, uint8_t *p_adv_data)

                {

                    wiced_bool_t processed = WICED_FALSE;

                 

                    if (p_scan_result == NULL)

                        return;

                 

                    if ((p_scan_result->remote_bd_addr[0] == 0x01) &&

                        (p_scan_result->remote_bd_addr[1] == 0x02) &&

                        (p_scan_result->remote_bd_addr[2] == 0x03) &&

                        (p_scan_result->remote_bd_addr[3] == 0x04) &&

                        (p_scan_result->remote_bd_addr[4] == 0x05) &&

                        (p_scan_result->remote_bd_addr[5] == 0x06))

                        counter++;

                 

                RSSI is available for you to use as well in p_scan_result->rssi

                1 of 1 people found this helpful
                • 5. Re: we need help with BLE MESH
                  jama_4535901

                  I want the scan code to send the data of this line :  WICED_BT_TRACE( "HOST: %B  RSSI : %d \r\n",p_scan_result->remote_bd_addr,p_scan_result->rssi); to another board through the mesh network, so I used the code vendor specific  because I believed that to send this data, vendor specific app was the correct code to use and match the scan code

                   

                  I want the data printed on the line WICED_BT_TRACE( "HOST: %B  RSSI : %d \r\n",p_scan_result->remote_bd_addr,p_scan_result->rssi); to be sent to another board through the mesh network

                   

                  in the image shows what I want to do

                  aplicacion.jpeg

                  • 6. Re: we need help with BLE MESH
                    jama_4535901

                    Yes i am using modus toolbox

                    I tried to combine the scan code and the vendor specific code but I have not succeeded,

                     

                     

                    I want the scan code to send the data of this line: WICED_BT_TRACE ("HOST:% B RSSI:% d \ r \ n", p_scan_result-> remote_bd_addr, p_scan_result-> rssi); to another board through the mesh network,

                     

                     

                    I tried that the vendor specific code and the scan code send the data: ("HOST:% B RSSI:% d \ r \ n", p_scan_result-> remote_bd_addr, p_scan_result-> rssi) to the code board with the vendor client  but I have not succeeded

                     

                     

                    in the image shows what I want to do

                    aplicacion.jpeg

                    • 7. Re: we need help with BLE MESH
                      VictorZ_46

                      Do you want to send over the mesh network BDADDR and RSSI from every beacon that you see.

                       

                      // Handle received adv packet

                      static void mesh_adv_report(wiced_bt_ble_scan_results_t *p_scan_result, uint8_t *p_adv_data)

                      {

                          wiced_bool_t processed = WICED_FALSE;

                          if (p_scan_result == NULL)

                              return;

                       

                          if (here you make a smart decision on if you really want to send this report out)

                          {

                              uint8_t data[7];

                              memcpy (data, p_scan_result->remote_bd_addr, 6);

                              data[6] = p_scan_result->rssi;

                       

                              p_event = wiced_bt_mesh_create_event(0, YOUR_COMPANY_ID, YOUR_MODEL_ID, 0, 0);

                              if (p_event == NULL)

                              {

                                  WICED_BT_TRACE("the device is not configured for publications\n");

                                  return;

                              }

                             else

                             {

                                  mesh_vendor_server_send_data(p_event, YOUR_OPCODE, data, 7);

                             }

                          }

                      1 of 1 people found this helpful
                      • 8. Re: we need help with BLE MESH
                        jama_4535901

                        Yes i want to do what you think

                        I am going to review the information that you gave us, thank you very much

                         

                         

                        I combine the 2 codes, but when the function starts wiced_bt_stack_init( app_bt_management_callback, &wiced_bt_cfg_settings1, wiced_bt_cfg_buf_pools1 );

                        the board with the code vendor specific  and  the  code scan starts scanI but this board disconnects from the mesh network and does not want to connect again, this messages is printed in uart terminal and Mesh Client Control App

                         

                        purebas3.PNG

                         

                        prueba4.PNG

                         

                        Can you tell me why it disconnects, and How can I avoid disconnection?

                         

                         

                        This is the code vendor specific.c with the scanner code

                         

                        /*---------------------------------------------------------------------------------------------------------------------------------------------------*/

                        #include "wiced_bt_ble.h"

                        #include "wiced_bt_gatt.h"

                        #include "wiced_bt_mesh_models.h"

                        #include "wiced_bt_trace.h"

                        #include "wiced_timer.h"

                        #include "wiced_bt_mesh_app.h"

                        #include "wiced_bt_cfg.h"

                        #include "wiced_platform.h"

                        #include "sparcommon.h"

                        #include "wiced_bt_dev.h"

                        #include "wiced_hal_puart.h"

                        #include "wiced_bt_stack.h"

                        #include "wiced_rtos.h"

                        #include "string.h"

                        #include "cycfg.h"

                         

                         

                        #ifdef HCI_CONTROL

                        #include "wiced_transport.h"

                        #include "hci_control_api.h"

                        #endif

                        #include "mesh_vendor_specific_app.h"

                         

                         

                        #include "wiced_memory.h"

                        #include "wiced_bt_cfg.h"

                        extern wiced_bt_cfg_settings_t wiced_bt_cfg_settings;

                        const wiced_bt_cfg_settings_t wiced_bt_cfg_settings1;

                        const wiced_bt_cfg_buf_pool_t wiced_bt_cfg_buf_pools1[WICED_BT_CFG_NUM_BUF_POOLS];

                         

                         

                        /******************************************************

                        *          Constants

                        ******************************************************/

                        #define MESH_PID                0x3025

                        #define MESH_VID                0x0002

                        #define MESH_CACHE_REPLAY_SIZE  0x0008

                        #define MESH_APP_RPL_DELAY      30        // Value is seconds. Use RPL = 0 to update immediately so that message cannot be replayed

                        #define SLEEP_1MS (1)       /* 1 segundo */

                        #define SLEEP_10MS (10)       /* 10 segundos */

                        /* Globally define wiced_timer_t structure */

                        wiced_timer_t timer;

                        wiced_timer_t timer2;

                        uint8_t Scanning = 1;

                        uint8_t Stop = 0;

                        uint8_t    i = 0;

                        /******************************************************

                        *          Structures

                        ******************************************************/

                         

                         

                        /******************************************************

                        *          Function Prototypes

                        ******************************************************/

                        static void mesh_app_init(wiced_bool_t is_provisioned);

                        static uint32_t mesh_app_proc_rx_cmd(uint16_t opcode, uint8_t *p_data, uint32_t length);

                        static void mesh_vendor_server_send_data(wiced_bt_mesh_event_t *p_event, uint16_t opcode, uint8_t *p_data, uint16_t data_len);

                        static void mesh_vendor_server_process_data(wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len);

                        wiced_bt_dev_status_t app_bt_management_callback      ( wiced_bt_management_evt_t event, wiced_bt_management_evt_data_t *p_event_data );

                         

                         

                        void                    timer_cback                     ( uint32_t data );   // TIEMPO DE ESCANEO

                        void                    timer2_cback                    ( uint32_t data2 );  // TIEMPO DE PARO

                         

                         

                         

                         

                        #ifdef HCI_CONTROL

                        static void mesh_vendor_hci_event_send_data(wiced_bt_mesh_hci_event_t *p_hci_event, uint8_t *p_data, uint16_t data_len);

                        #endif

                         

                         

                        /******************************************************

                        *          Variables Definitions

                        ******************************************************/

                        uint8_t mesh_mfr_name[WICED_BT_MESH_PROPERTY_LEN_DEVICE_MANUFACTURER_NAME] = { 'C', 'y', 'p', 'r', 'e', 's', 's', 0 };

                        uint8_t mesh_model_num[WICED_BT_MESH_PROPERTY_LEN_DEVICE_MODEL_NUMBER]     = { '1', '2', '3', '4', 0, 0, 0, 0 };

                        uint8_t mesh_system_id[8]                                                  = { 0xbb, 0xb8, 0xa1, 0x80, 0x5f, 0x9f, 0x91, 0x71 };

                         

                         

                        wiced_bool_t mesh_vendor_server_message_handler(wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len);

                        uint16_t     mesh_vendor_server_scene_store_handler(uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len);

                        uint16_t     mesh_vendor_server_scene_recall_handler(uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len, uint32_t transition_time, uint32_t delay);

                         

                         

                        wiced_bt_mesh_core_config_model_t   mesh_element1_models[] =

                        {

                            WICED_BT_MESH_DEVICE,

                            { MESH_VENDOR_COMPANY_ID, MESH_VENDOR_MODEL_ID, mesh_vendor_server_message_handler, mesh_vendor_server_scene_store_handler, mesh_vendor_server_scene_recall_handler },

                        };

                        #define MESH_APP_NUM_MODELS  (sizeof(mesh_element1_models) / sizeof(wiced_bt_mesh_core_config_model_t))

                         

                         

                        #define MESH_VENDOR_SERVER_ELEMENT_INDEX   0

                         

                         

                        wiced_bt_mesh_core_config_element_t mesh_elements[] =

                        {

                            {

                                .location = MESH_ELEM_LOC_MAIN,                                 // location description as defined in the GATT Bluetooth Namespace Descriptors section of the Bluetooth SIG Assigned Numbers

                                .default_transition_time = MESH_DEFAULT_TRANSITION_TIME_IN_MS,  // Default transition time for models of the element in milliseconds

                                .onpowerup_state = WICED_BT_MESH_ON_POWER_UP_STATE_RESTORE,     // Default element behavior on power up

                                .default_level = 0,                                             // Default value of the variable controlled on this element (for example power, lightness, temperature, hue...)

                                .range_min = 1,                                                 // Minimum value of the variable controlled on this element (for example power, lightness, temperature, hue...)

                                .range_max = 0xffff,                                            // Maximum value of the variable controlled on this element (for example power, lightness, temperature, hue...)

                                .move_rollover = 0,                                             // If true when level gets to range_max during move operation, it switches to min, otherwise move stops.

                                .properties_num = 0,                                            // Number of properties in the array models

                                .properties = NULL,                                             // Array of properties in the element.

                                .sensors_num = 0,                                               // Number of sensors in the sensor array

                                .sensors = NULL,                                                // Array of sensors of that element

                                .models_num = MESH_APP_NUM_MODELS,                              // Number of models in the array models

                                .models = mesh_element1_models,                                 // Array of models located in that element. Model data is defined by structure wiced_bt_mesh_core_config_model_t

                            },

                        };

                         

                         

                        wiced_bt_mesh_core_config_t  mesh_config =

                        {

                            .company_id         = MESH_COMPANY_ID_CYPRESS,                  // Company identifier assigned by the Bluetooth SIG

                            .product_id         = MESH_PID,                                 // Vendor-assigned product identifier

                            .vendor_id          = MESH_VID,                                 // Vendor-assigned product version identifier

                            .replay_cache_size  = MESH_CACHE_REPLAY_SIZE,                   // Number of replay protection entries, i.e. maximum number of mesh devices that can send application messages to this device.

                        #if LOW_POWER_NODE

                            .features           = WICED_BT_MESH_CORE_FEATURE_BIT_LOW_POWER, // A bit field indicating the device features. In Low Power mode no Relay, no Proxy and no Friend

                            .friend_cfg         =                                           // Empty Configuration of the Friend Feature

                            {

                                .receive_window = 0,                                        // Receive Window value in milliseconds supported by the Friend node.

                                .cache_buf_len  = 0,                                        // Length of the buffer for the cache

                                .max_lpn_num    = 0                                         // Max number of Low Power Nodes with established friendship. Must be > 0 if Friend feature is supported.

                            },

                            .low_power          =                                           // Configuration of the Low Power Feature

                            {

                                .rssi_factor           = 2,                                 // contribution of the RSSI measured by the Friend node used in Friend Offer Delay calculations.

                                .receive_window_factor = 2,                                 // contribution of the supported Receive Window used in Friend Offer Delay calculations.

                                .min_cache_size_log    = 3,                                 // minimum number of messages that the Friend node can store in its Friend Cache.

                                .receive_delay         = 100,                               // Receive delay in 1 ms units to be requested by the Low Power node.

                                .poll_timeout          = 36000                              // Poll timeout in 100ms units to be requested by the Low Power node.

                            },

                        #else

                            .features           = WICED_BT_MESH_CORE_FEATURE_BIT_FRIEND | WICED_BT_MESH_CORE_FEATURE_BIT_RELAY | WICED_BT_MESH_CORE_FEATURE_BIT_GATT_PROXY_SERVER,   // In Friend mode support friend, relay

                            .friend_cfg         =                                           // Configuration of the Friend Feature(Receive Window in Ms, messages cache)

                            {

                                .receive_window        = 20,

                                .cache_buf_len         = 300,                               // Length of the buffer for the cache

                                .max_lpn_num           = 4                                  // Max number of Low Power Nodes with established friendship. Must be > 0 if Friend feature is supported.

                            },

                            .low_power          =                                           // Configuration of the Low Power Feature

                            {

                                .rssi_factor           = 0,                                 // contribution of the RSSI measured by the Friend node used in Friend Offer Delay calculations.

                                .receive_window_factor = 0,                                 // contribution of the supported Receive Window used in Friend Offer Delay calculations.

                                .min_cache_size_log    = 0,                                 // minimum number of messages that the Friend node can store in its Friend Cache.

                                .receive_delay         = 0,                                 // Receive delay in 1 ms units to be requested by the Low Power node.

                                .poll_timeout          = 0                                  // Poll timeout in 100ms units to be requested by the Low Power node.

                            },

                        #endif

                            .gatt_client_only          = WICED_FALSE,                       // Can connect to mesh over GATT or ADV

                            .elements_num  = (uint8_t)(sizeof(mesh_elements) / sizeof(mesh_elements[0])),   // number of elements on this device

                            .elements      = mesh_elements                                  // Array of elements for this device

                        };

                         

                         

                        /*

                        * Mesh application library will call into application functions if provided by the application.

                        */

                        wiced_bt_mesh_app_func_table_t wiced_bt_mesh_app_func_table =

                        {

                            mesh_app_init,          // application initialization

                            NULL,                   // Default SDK platform button processing

                            NULL,                   // GATT connection status

                            NULL,                   // attention processing

                            NULL,                   // notify period set

                            mesh_app_proc_rx_cmd,   // WICED HCI command

                            NULL,                   // LPN sleep

                            NULL                    // factory reset

                        };

                        const wiced_bt_cfg_settings_t wiced_bt_cfg_settings1 =

                        {

                         

                         

                            //.device_name                         = (uint8_t*)app_gap_device_name,

                            .device_class                        = {0x00, 0x00, 0x00},                                             /**< Local device class */

                            .security_requirement_mask           = BTM_SEC_NONE,                                                   /**< Security requirements mask (BTM_SEC_NONE, or combinination of BTM_SEC_IN_AUTHENTICATE, BTM_SEC_OUT_AUTHENTICATE, BTM_SEC_ENCRYPT (see #wiced_bt_sec_level_e)) */

                         

                         

                            .max_simultaneous_links              = 3,                                                              /**< Maximum number simultaneous links to different devices */

                         

                         

                            .br_edr_scan_cfg =                                              /* BR/EDR scan config */

                            {

                                .inquiry_scan_type               = BTM_SCAN_TYPE_STANDARD,                                     /**< Inquiry scan type (BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED) */

                                .inquiry_scan_interval           = WICED_BT_CFG_DEFAULT_INQUIRY_SCAN_INTERVAL,                 /**< Inquiry scan interval  (0 to use default) */

                                .inquiry_scan_window             = WICED_BT_CFG_DEFAULT_INQUIRY_SCAN_WINDOW,                   /**< Inquiry scan window (0 to use default) */

                         

                         

                                .page_scan_type                  = BTM_SCAN_TYPE_STANDARD,                                     /**< Page scan type (BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED) */

                                .page_scan_interval              = WICED_BT_CFG_DEFAULT_PAGE_SCAN_INTERVAL,                    /**< Page scan interval  (0 to use default) */

                                .page_scan_window                = WICED_BT_CFG_DEFAULT_PAGE_SCAN_WINDOW                       /**< Page scan window (0 to use default) */

                            },

                         

                         

                            .ble_scan_cfg =                                                 /* BLE scan settings  */

                            {

                                .scan_mode                       = BTM_BLE_SCAN_MODE_PASSIVE,                                  /**< BLE scan mode (BTM_BLE_SCAN_MODE_PASSIVE, BTM_BLE_SCAN_MODE_ACTIVE, or BTM_BLE_SCAN_MODE_NONE) */

                         

                         

                                /* Advertisement scan configuration */

                                .high_duty_scan_interval         = WICED_BT_CFG_DEFAULT_HIGH_DUTY_SCAN_INTERVAL,               /**< High duty scan interval */

                                .high_duty_scan_window           = WICED_BT_CFG_DEFAULT_HIGH_DUTY_SCAN_WINDOW,                 /**< High duty scan window */

                                .high_duty_scan_duration         = 5,                                                          /**< High duty scan duration in seconds (0 for infinite) */

                         

                         

                                .low_duty_scan_interval          = WICED_BT_CFG_DEFAULT_LOW_DUTY_SCAN_INTERVAL,                /**< Low duty scan interval  */

                                .low_duty_scan_window            = WICED_BT_CFG_DEFAULT_LOW_DUTY_SCAN_WINDOW,                  /**< Low duty scan window */

                                .low_duty_scan_duration          = 5,                                                          /**< Low duty scan duration in seconds (0 for infinite) */

                         

                         

                                /* Connection scan configuration */

                                .high_duty_conn_scan_interval    = WICED_BT_CFG_DEFAULT_HIGH_DUTY_CONN_SCAN_INTERVAL,          /**< High duty cycle connection scan interval */

                                .high_duty_conn_scan_window      = WICED_BT_CFG_DEFAULT_HIGH_DUTY_CONN_SCAN_WINDOW,            /**< High duty cycle connection scan window */

                                .high_duty_conn_duration         = 30,                                                         /**< High duty cycle connection duration in seconds (0 for infinite) */

                         

                         

                                .low_duty_conn_scan_interval     = WICED_BT_CFG_DEFAULT_LOW_DUTY_CONN_SCAN_INTERVAL,           /**< Low duty cycle connection scan interval */

                                .low_duty_conn_scan_window       = WICED_BT_CFG_DEFAULT_LOW_DUTY_CONN_SCAN_WINDOW,             /**< Low duty cycle connection scan window */

                                .low_duty_conn_duration          = 30,                                                         /**< Low duty cycle connection duration in seconds (0 for infinite) */

                         

                         

                                /* Connection configuration */

                                .conn_min_interval               = WICED_BT_CFG_DEFAULT_CONN_MIN_INTERVAL,                     /**< Minimum connection interval */

                                .conn_max_interval               = WICED_BT_CFG_DEFAULT_CONN_MAX_INTERVAL,                     /**< Maximum connection interval */

                                .conn_latency                    = WICED_BT_CFG_DEFAULT_CONN_LATENCY,                          /**< Connection latency */

                                .conn_supervision_timeout        = WICED_BT_CFG_DEFAULT_CONN_SUPERVISION_TIMEOUT,              /**< Connection link supervision timeout */

                            },

                         

                         

                            .ble_advert_cfg =                                               /* BLE advertisement settings */

                            {

                                .channel_map                     = BTM_BLE_ADVERT_CHNL_37 |                                    /**< Advertising channel map (mask of BTM_BLE_ADVERT_CHNL_37, BTM_BLE_ADVERT_CHNL_38, BTM_BLE_ADVERT_CHNL_39) */

                                                                   BTM_BLE_ADVERT_CHNL_38 |

                                                                   BTM_BLE_ADVERT_CHNL_39,

                         

                         

                                .high_duty_min_interval          = WICED_BT_CFG_DEFAULT_HIGH_DUTY_ADV_MIN_INTERVAL,            /**< High duty undirected connectable minimum advertising interval */

                                .high_duty_max_interval          = WICED_BT_CFG_DEFAULT_HIGH_DUTY_ADV_MAX_INTERVAL,            /**< High duty undirected connectable maximum advertising interval */

                                .high_duty_duration              = 30,                                                         /**< High duty undirected connectable advertising duration in seconds (0 for infinite) */

                         

                         

                                .low_duty_min_interval           = 1024,                                                       /**< Low duty undirected connectable minimum advertising interval */

                                .low_duty_max_interval           = 1024,                                                       /**< Low duty undirected connectable maximum advertising interval */

                                .low_duty_duration               = 0,                                                         /**< Low duty undirected connectable advertising duration in seconds (0 for infinite) */

                         

                         

                                .high_duty_directed_min_interval = WICED_BT_CFG_DEFAULT_HIGH_DUTY_DIRECTED_ADV_MIN_INTERVAL,   /**< High duty directed connectable minimum advertising interval */

                                .high_duty_directed_max_interval = WICED_BT_CFG_DEFAULT_HIGH_DUTY_DIRECTED_ADV_MAX_INTERVAL,   /**< High duty directed connectable maximum advertising interval */

                         

                         

                                .low_duty_directed_min_interval  = WICED_BT_CFG_DEFAULT_LOW_DUTY_DIRECTED_ADV_MIN_INTERVAL,    /**< Low duty directed connectable minimum advertising interval */

                                .low_duty_directed_max_interval  = WICED_BT_CFG_DEFAULT_LOW_DUTY_DIRECTED_ADV_MAX_INTERVAL,    /**< Low duty directed connectable maximum advertising interval */

                                .low_duty_directed_duration      = 0,                                                         /**< Low duty directed connectable advertising duration in seconds (0 for infinite) */

                         

                         

                                .high_duty_nonconn_min_interval  = WICED_BT_CFG_DEFAULT_HIGH_DUTY_NONCONN_ADV_MIN_INTERVAL,    /**< High duty non-connectable minimum advertising interval */

                                .high_duty_nonconn_max_interval  = WICED_BT_CFG_DEFAULT_HIGH_DUTY_NONCONN_ADV_MAX_INTERVAL,    /**< High duty non-connectable maximum advertising interval */

                                .high_duty_nonconn_duration      = 30,                                                         /**< High duty non-connectable advertising duration in seconds (0 for infinite) */

                         

                         

                                .low_duty_nonconn_min_interval   = WICED_BT_CFG_DEFAULT_LOW_DUTY_NONCONN_ADV_MIN_INTERVAL,     /**< Low duty non-connectable minimum advertising interval */

                                .low_duty_nonconn_max_interval   = WICED_BT_CFG_DEFAULT_LOW_DUTY_NONCONN_ADV_MAX_INTERVAL,     /**< Low duty non-connectable maximum advertising interval */

                                .low_duty_nonconn_duration       = 0                                                           /**< Low duty non-connectable advertising duration in seconds (0 for infinite) */

                            },

                         

                         

                            .gatt_cfg =                                                     /* GATT configuration */

                            {

                                .appearance                     = APPEARANCE_GENERIC_TAG,                                     /**< GATT appearance (see gatt_appearance_e) */

                                .client_max_links               = 0,                                                          /**< Client config: maximum number of servers that local client can connect to  */

                                .server_max_links               = 1,                                                          /**< Server config: maximum number of remote clients connections allowed by the local */

                                .max_attr_len                   = 512,                                                       /**< Maximum attribute length; gki_cfg must have a corresponding buffer pool that can hold this length */

                                .max_mtu_size                   = 515                                                         /**< Maximum MTU size for GATT connections, should be between 23 and (max_attr_len + 5) */

                            },

                         

                         

                            .rfcomm_cfg =                                                   /* RFCOMM configuration */

                            {

                                .max_links                      = 0,                                                          /**< Maximum number of simultaneous connected remote devices*/

                                .max_ports                      = 0                                                           /**< Maximum number of simultaneous RFCOMM ports */

                            },

                         

                         

                            .l2cap_application =                                            /* Application managed l2cap protocol configuration */

                            {

                                .max_links                      = 0,                                                          /**< Maximum number of application-managed l2cap links (BR/EDR and LE) */

                         

                         

                                /* BR EDR l2cap configuration */

                                .max_psm                        = 0,                                                          /**< Maximum number of application-managed BR/EDR PSMs */

                                .max_channels                   = 0,                                                          /**< Maximum number of application-managed BR/EDR channels  */

                         

                         

                                /* LE L2cap connection-oriented channels configuration */

                                .max_le_psm                     = 0,                                                          /**< Maximum number of application-managed LE PSMs */

                                .max_le_channels                = 0,                                                          /**< Maximum number of application-managed LE channels */

                         

                         

                                /* LE L2cap fixed channel configuration */

                                .max_le_l2cap_fixed_channels    = 0                                                           /**< Maximum number of application managed fixed channels supported (in addition to mandatory channels 4, 5 and 6). > */

                         

                         

                            },

                         

                         

                            .avdt_cfg =

                            /* Audio/Video Distribution configuration */

                            {

                                .max_links                      = 0,                                                          /**< Maximum simultaneous audio/video links */

                                .max_seps                       = 0                                                           /**< Maximum number of stream end points */

                         

                         

                            },

                         

                         

                            .avrc_cfg =                                                     /* Audio/Video Remote Control configuration */

                            {

                                .roles                          = 0,                                                          /**< Mask of local roles supported (AVRC_CONN_INITIATOR|AVRC_CONN_ACCEPTOR) */

                                .max_links                      = 0                                                           /**< Maximum simultaneous remote control links */

                            },

                         

                         

                            /* LE Address Resolution DB size  */

                            .addr_resolution_db_size            = 5,                                                          /**< LE Address Resolution DB settings - effective only for pre 4.2 controller*/

                         

                         

                            .max_number_of_buffer_pools         = 4,                                                              /**< Maximum number of buffer pools in p_btm_cfg_buf_pools and by wiced_create_pool */

                         

                         

                            /* Interval of  random address refreshing */

                            .rpa_refresh_timeout                = WICED_BT_CFG_DEFAULT_RANDOM_ADDRESS_CHANGE_TIMEOUT,             /**< Interval of  random address refreshing - secs */

                            /* BLE white list size */

                            .ble_white_list_size                = 0,                                                               /**< Maximum number of white list devices allowed. Cannot be more than 128 */

                         

                         

                            .default_ble_power_level            = 12

                        /**< Default LE power level, Refer lm_TxPwrTable table for the power range */

                         

                         

                         

                         

                        };

                         

                         

                        extern uint8_t wiced_bt_mesh_core_adv_tx_power;

                         

                         

                        wiced_bool_t disable_ntwk_retransmit = FALSE;

                         

                         

                        /******************************************************

                        *               Function Definitions

                        ******************************************************/

                        void mesh_app_init(wiced_bool_t is_provisioned)

                        {

                        #if 0

                            // Set Debug trace level for mesh_models_lib and mesh_provisioner_lib

                            wiced_bt_mesh_models_set_trace_level(WICED_BT_MESH_CORE_TRACE_INFO);

                        #endif

                        #if 0

                            // Set Debug trace level for all modules but Info level for CORE_AES_CCM module

                            wiced_bt_mesh_core_set_trace_level(WICED_BT_MESH_CORE_TRACE_FID_ALL, WICED_BT_MESH_CORE_TRACE_DEBUG);

                            wiced_bt_mesh_core_set_trace_level(WICED_BT_MESH_CORE_TRACE_FID_CORE_AES_CCM, WICED_BT_MESH_CORE_TRACE_INFO);

                        #endif

                         

                         

                        #if 0

                            // App can set TX power here. 0 means minimum power nad 4 is the max. Actual power table is on the controller.

                            WICED_BT_TRACE("tx_power:%d to 0\n", wiced_bt_mesh_core_adv_tx_power);

                            wiced_bt_mesh_core_adv_tx_power = 0;

                        #endif

                         

                         

                            WICED_BT_TRACE("app_init provisioned:%d\n", is_provisioned);

                         

                         

                            wiced_bt_cfg_settings.device_name = (uint8_t *)"Smart Flow Node";

                            wiced_bt_cfg_settings.gatt_cfg.appearance = APPEARANCE_GENERIC_TAG;

                            // Adv Data is fixed. Spec allows to put URI, Name, Appearance and Tx Power in the Scan Response Data.

                            if (!is_provisioned)

                            {

                                wiced_bt_ble_advert_elem_t  adv_elem[3];

                                uint8_t                     buf[2];

                                uint8_t                     num_elem = 0;

                                adv_elem[num_elem].advert_type = BTM_BLE_ADVERT_TYPE_NAME_COMPLETE;

                                adv_elem[num_elem].len = (uint16_t)strlen((const char*)wiced_bt_cfg_settings.device_name);

                                adv_elem[num_elem].p_data = wiced_bt_cfg_settings.device_name;

                                num_elem++;

                         

                         

                                adv_elem[num_elem].advert_type = BTM_BLE_ADVERT_TYPE_APPEARANCE;

                                adv_elem[num_elem].len = 2;

                                buf[0] = (uint8_t)wiced_bt_cfg_settings.gatt_cfg.appearance;

                                buf[1] = (uint8_t)(wiced_bt_cfg_settings.gatt_cfg.appearance >> 8);

                                adv_elem[num_elem].p_data = buf;

                                num_elem++;

                         

                         

                                wiced_bt_mesh_set_raw_scan_response_data(num_elem, adv_elem);

                            }

                        }

                        const wiced_bt_cfg_buf_pool_t wiced_bt_cfg_buf_pools1[WICED_BT_CFG_NUM_BUF_POOLS] =

                        {

                        /*  { buf_size, buf_count } */

                            { 64,       12  },      /* Small Buffer Pool */

                            { 360,      6   },      /* Medium Buffer Pool (used for HCI & RFCOMM control messages, min recommended size is 360) */

                            { 1056,     6   },      /* Large Buffer Pool  (used for HCI ACL messages) */

                            { 1056,     0   },      /* Extra Large Buffer Pool - Used for avdt media packets and miscellaneous (if not needed, set buf_count to 0) */

                        };

                        /*

                        * This function is called when core receives a valid message for the define Vendor

                        * Model (MESH_VENDOR_COMPANY_ID/MESH_VENDOR_MODEL_ID) combination.  The function shall return TRUE if it

                        * was able to process the message, and FALSE if the message is unknown.  In the latter case the core

                        * will call other registered models.

                        */

                        wiced_bool_t mesh_vendor_server_message_handler(wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)

                        {

                            WICED_BT_TRACE("Servidor_handler: Solicitante:%x model_id:%x\n", p_event->opcode, p_event->model_id);

                         

                         

                            // 0xffff model_id means request to check if that opcode belongs to that model

                            if (p_event->model_id == 0xffff)

                            {

                                switch (p_event->opcode)

                                {

                                case MESH_VENDOR_OPCODE1:

                                case MESH_VENDOR_OPCODE2:

                                case MESH_VENDOR_OPCODE3:

                                case MESH_VENDOR_OPCODE4:

                                    p_event->status.rpl_delay = MESH_APP_RPL_DELAY;

                                    break;

                                default:

                                    return WICED_FALSE;

                                }

                                return WICED_TRUE;

                            }

                         

                         

                            switch(p_event->opcode)

                            {

                            case MESH_VENDOR_OPCODE1:

                            case MESH_VENDOR_OPCODE2:

                            case MESH_VENDOR_OPCODE3:

                            case MESH_VENDOR_OPCODE4:

                                mesh_vendor_server_process_data(p_event, p_data, data_len);

                                break;

                         

                         

                            default:

                                wiced_bt_mesh_release_event(p_event);

                                return WICED_FALSE;

                            }

                            return WICED_TRUE;

                        }

                         

                         

                        /*

                        * Scene Store Handler.  If the model need to be a part of a scene, store the data in the provided buffer.

                        */

                        uint16_t mesh_vendor_server_scene_store_handler(uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len)

                        {

                            // return number of the bytes stored in the buffer.

                            return 0;

                        }

                         

                         

                        /*

                        * Scene Store Handler.  If the model need to be a part of a scene, restore the data from the provided buffer.

                        */

                        uint16_t mesh_vendor_server_scene_recall_handler(uint8_t element_idx, uint8_t *p_buffer, uint16_t buffer_len, uint32_t transition_time, uint32_t delay)

                        {

                            // return number of the bytes read from the buffer.

                            return 0;

                        }

                         

                         

                        void mesh_vendor_server_process_data(wiced_bt_mesh_event_t *p_event, uint8_t *p_data, uint16_t data_len)

                        {

                            uint8_t *p_buffer = NULL;

                            wiced_bt_mesh_event_t * p_reply_event = NULL;

                        #if defined HCI_CONTROL

                            wiced_bt_mesh_hci_event_t *p_hci_event;

                        #endif

                         

                         

                         

                         

                            WICED_BT_TRACE("vs Process data from:%04x Respuesta:%04x Medida:%d\n", p_event->src, p_event->reply, data_len);

                         

                         

                            // Because the same app publishes and subscribes the same model, it will receive messages that it

                            //sent out.

                            if (p_event->src == wiced_bt_mesh_core_get_local_addr())

                            {

                                wiced_bt_mesh_release_event(p_event);

                                return;

                            }

                        #if defined HCI_CONTROL

                            if ((p_hci_event = wiced_bt_mesh_create_hci_event(p_event)) != NULL)

                                mesh_vendor_hci_event_send_data(p_hci_event, p_data, data_len);

                        #endif

                            if (p_event->opcode == MESH_VENDOR_OPCODE1)

                            {

                         

                         

                            if (*p_data == *Comand_operate)

                            {

                                if ((p_buffer = (uint8_t*)wiced_bt_get_buffer(data_len + 1)) != NULL)

                                {

                                unsigned char comprxd[Buffer_counter];

                                    uint8_t CipherKey[8] =

                                    { 0x01,0x32,0xff,0x33};

                         

                         

                                    memcpy(p_buffer, p_data, data_len);

                                    p_buffer[data_len] = (uint8_t)p_event->ttl;

                         

                         

                                    //p_reply_event = wiced_bt_mesh_create_reply_event(p_event);

                                    //strncpy((char*)comprxd,(char*)p_buffer,1);

                         

                         

                                    if(disable_ntwk_retransmit)

                                        p_reply_event->retrans_cnt = 0x80;

                                    //WICED_BT_TRACE("Comando aceptado: %B",p_data);

                                    WICED_BT_TRACE("Comando aceptado");

                                    memset(p_buffer,'C', 6);

                                    application_start1();

                                    mesh_vendor_server_send_data(wiced_bt_mesh_create_reply_event(p_event), MESH_VENDOR_OPCODE2, p_buffer, data_len +1);

                                    wiced_bt_free_buffer( p_buffer );

                                }

                                }

                            else

                            {WICED_BT_TRACE("Comando denegado");}

                            }

                            else if (p_event->opcode == MESH_VENDOR_OPCODE3) // adv tx power

                            {

                                if((data_len == 1) && p_data[0] <= 4)

                                {

                                    wiced_bt_mesh_core_adv_tx_power  = p_data[0];

                         

                         

                                    // This application returns the data that it received in the command plus TTL value. The Client can figure out number of hops based on that.

                                    // Real app can send anything it wants.

                                    if ((p_buffer = (uint8_t*)wiced_bt_get_buffer(data_len + 1)) != NULL)

                                    {

                                        memcpy(p_buffer, p_data, data_len);

                                        p_buffer[data_len] = (uint8_t)p_event->ttl;

                         

                         

                                        mesh_vendor_server_send_data(wiced_bt_mesh_create_reply_event(p_event), MESH_VENDOR_OPCODE3, p_buffer, data_len +1);

                                        wiced_bt_free_buffer( p_buffer );

                                    }

                                }

                            }

                            else if (p_event->opcode == MESH_VENDOR_OPCODE4)  // disable network retransmit

                            {

                                if((data_len == 1) && p_data[0] <= 4)

                                {

                                    disable_ntwk_retransmit  = (wiced_bool_t) p_data[0];

                         

                         

                                    // This application returns the data that it received in the command plus TTL value. The Client can figure out number of hops based on that.

                                    // Real app can send anything it wants.

                                    if ((p_buffer = (uint8_t*)wiced_bt_get_buffer(data_len + 1)) != NULL)

                                    {

                                        memcpy(p_buffer, p_data, data_len);

                                        p_buffer[data_len] = (uint8_t)p_event->ttl;

                         

                         

                                        mesh_vendor_server_send_data(wiced_bt_mesh_create_reply_event(p_event), MESH_VENDOR_OPCODE4, p_buffer, data_len +1);

                                        wiced_bt_free_buffer( p_buffer );

                                    }

                                }

                            }

                            else

                            {

                                wiced_bt_mesh_release_event(p_event);

                            }

                        }

                         

                         

                        /*

                        * In 2 chip solutions MCU can send commands to set vendor specific status.

                        */

                        uint32_t mesh_app_proc_rx_cmd(uint16_t opcode, uint8_t *p_data, uint32_t length)

                        {

                            wiced_bt_mesh_event_t *p_event;

                            uint16_t dst         = p_data[0] + (p_data[1] << 8);

                            uint16_t app_key_idx = p_data[2] + (p_data[3] << 8);

                            uint8_t  element_idx = p_data[4];

                            uint16_t company_id  = p_data[5] + (p_data[6] << 8);

                            uint16_t model_id    = p_data[7] + (p_data[8] << 8);

                            uint8_t  cmd_opcode  = p_data[9];

                         

                         

                            WICED_BT_TRACE("[%s] cmd_opcode 0x%02x\n", __FUNCTION__, opcode);

                         

                         

                            if (opcode != HCI_CONTROL_MESH_COMMAND_VENDOR_DATA)

                                return WICED_FALSE;

                         

                         

                            p_event = wiced_bt_mesh_create_event(element_idx, company_id, model_id, dst, app_key_idx);

                            if (p_event == NULL)

                            {

                                WICED_BT_TRACE("app_proc_rx_cmd: no mem\n");

                                return WICED_TRUE;

                            }

                            mesh_vendor_server_send_data(p_event, cmd_opcode, p_data + 6, length - 6);

                            return WICED_TRUE;

                        }

                         

                         

                        void application_start1( void )

                        {

                            int i=0;

                         

                         

                        #if ((defined WICED_BT_TRACE_ENABLE) || (defined HCI_TRACE_OVER_TRANSPORT))

                        /* Select Debug UART setting to see debug traces on the appropriate port */

                        wiced_set_debug_uart( WICED_ROUTE_DEBUG_TO_PUART );

                        #endif

                         

                         

                        WICED_BT_TRACE( "**** CYW20819 App Startx **** \r\n\n" );

                         

                         

                        if(i==0){

                        /* Initialize Stack and Register Management Callback */

                        wiced_bt_stack_init( app_bt_management_callback, &wiced_bt_cfg_settings1, wiced_bt_cfg_buf_pools1 );

                        }

                        }

                         

                         

                        wiced_result_t app_bt_management_callback( wiced_bt_management_evt_t event, wiced_bt_management_evt_data_t *p_event_data )

                        {

                        wiced_result_t status = WICED_BT_SUCCESS;

                         

                         

                        switch( event )

                        {

                        case BTM_ENABLED_EVT: // Bluetooth Controller and Host Stack Enabled

                        if( WICED_BT_SUCCESS == p_event_data->enabled.status )

                        {

                         

                         

                         

                         

                        WICED_BT_TRACE( "Bluetooth Enabled\r\n\n" );

                         

                         

                         

                         

                        /* Use Application Settings dialog to set BT_DEVICE_ADDRESS = random */

                         

                         

                                          wiced_bt_device_address_t static_addr;

                                wiced_bt_dev_read_local_addr(static_addr );

                         

                         

                        WICED_BT_TRACE( "Local Bluetooth Device Address: [%B]\r\n", static_addr );

                         

                         

                                     /* Start a periodic timer */

                                        wiced_init_timer( &timer, timer_cback, 0, WICED_SECONDS_TIMER );

                                        wiced_init_timer( &timer2, timer2_cback, 0, WICED_SECONDS_TIMER );

                         

                         

                                        wiced_start_timer( &timer, SLEEP_1MS);

                         

                         

                        }

                        break;

                         

                         

                        case BTM_LOCAL_IDENTITY_KEYS_REQUEST_EVT:

                        break;

                         

                         

                        case BTM_BLE_SCAN_STATE_CHANGED_EVT:

                        switch( p_event_data->ble_scan_state_changed )

                        {

                        case BTM_BLE_SCAN_TYPE_NONE:

                         

                         

                        WICED_BT_TRACE( " DISPOSITIVOS ESCANEADOS: %d\r\n",i);

                        WICED_BT_TRACE( "Scanning stopped.\r\n\n" );

                                            i=0;

                        break;

                         

                         

                        case BTM_BLE_SCAN_TYPE_HIGH_DUTY:

                        WICED_BT_TRACE( "High duty scanning.\r\n" );

                        break;

                         

                         

                        }

                        break;

                         

                         

                        default:

                        WICED_BT_TRACE( "Unhandled Bluetooth Management Event: 0x%x (%d)\n", event, event );

                        break;

                        }

                         

                         

                         

                         

                        return status;

                        }

                         

                         

                        void myScanCallback( wiced_bt_ble_scan_results_t *p_scan_result, uint8_t *p_adv_data )

                        {

                         

                         

                            WICED_BT_TRACE( "%B%d\r\n", p_scan_result->remote_bd_addr,p_scan_result->rssi );

                                     i+=1;

                        }

                         

                         

                         

                         

                        /*******************************************************************************

                        * Function Name: void timer_cback( uint32_t *data )

                        ********************************************************************************/

                        void timer_cback( uint32_t data )

                        {

                            wiced_bt_ble_scan(BTM_BLE_SCAN_TYPE_HIGH_DUTY, WICED_TRUE, myScanCallback );

                            wiced_start_timer( &timer2, SLEEP_1MS);

                        }

                         

                         

                        void timer2_cback( uint32_t data )

                        {

                            wiced_start_timer( &timer, SLEEP_10MS);

                        }

                         

                         

                        /*

                        * Send Vendor Data status message to the Client

                        */

                        void mesh_vendor_server_send_data(wiced_bt_mesh_event_t *p_event, uint16_t opcode, uint8_t *p_data, uint16_t data_len)

                        {

                            p_event->opcode = opcode;

                            wiced_bt_mesh_core_send(p_event, p_data, data_len, NULL);

                        }

                         

                         

                        #ifdef HCI_CONTROL

                        /*

                        * Send Vendor Data received from the mesh over transport

                        */

                        void mesh_vendor_hci_event_send_data(wiced_bt_mesh_hci_event_t *p_hci_event, uint8_t *p_data, uint16_t data_len)

                        {

                            uint8_t *p = p_hci_event->data;

                         

                         

                            ARRAY_TO_STREAM(p, p_data, data_len);

                         

                         

                            mesh_transport_send_data(HCI_CONTROL_MESH_EVENT_VENDOR_DATA, (uint8_t *)p_hci_event, (uint16_t)(p - (uint8_t *)p_hci_event));

                        }

                        #endif

                        • 9. Re: we need help with BLE MESH
                          VictorZ_46

                          sorry, i do not understand what you are trying to combine and why. i specified what needs to be done.

                          • 10. Re: we need help with BLE MESH
                            jama_4535901

                            I add the scanner code to the code vendor specific  in only code

                             

                            I start the scan on these lines in the function applicacion_start1 ();

                             

                            WICED_BT_TRACE ("Command accepted");

                                         memset (p_buffer, 'C', 6);

                                         application_start1 ();

                            pruebas5.PNG

                             

                            then enter the function

                            wiced_bt_stack_init (app_bt_management_callback, & wiced_bt_cfg_settings1, wiced_bt_cfg_buf_pools1);

                             

                            when it enters that function the board starts scanning devices, and prints them on the line:

                             

                             

                            WICED_BT_TRACE ("% B% d \ r \ n", p_scan_result-> remote_bd_addr, p_scan_result-> rssi);

                                          i + = 1;

                             

                             

                            the problem is that when it enter the function: wiced_bt_stack_init (app_bt_management_callback, & wiced_bt_cfg_settings1, wiced_bt_cfg_buf_pools1);

                             

                            the board disconnects from the mesh network and I want it to scan but not disconnect

                            prueba6.PNG

                             

                             

                             

                            the board already scans the devices and prints them on the line:

                            WICED_BT_TRACE ("% B% d \ r \ n", p_scan_result-> remote_bd_addr, p_scan_result-> rssi);

                            but the problem is that the board was disconnected and cannot receive messages from the board with vendor client code

                             

                            What can I do to make this code work without disconnecting?

                            If you want ?, I will send you the project code to do this test and you will try to solve the problem

                            • 11. Re: we need help with BLE MESH
                              VictorZ_46

                              hmm, do you think it would make sense for you to read what i wrote? what you are doing does not make much sense.

                              • 12. Re: we need help with BLE MESH
                                jama_4535901

                                I understood what you wrote

                                 

                                I uploaded 2 codes

                                 

                                first code: scan code

                                second code: vendor specific code modified

                                 

                                pruebas7.PNG

                                 

                                I want to join these 2 codes and create a new code

                                 

                                 

                                I want this new code to scan and send the data stored in the line: WICED_BT_TRACE ("% B% d \ r \ n", p_scan_result-> remote_bd_addr, p_scan_result-> rssi); send to another board through the mesh network

                                 

                                 

                                I tried to unite these 2 codes and create a new code,

                                 

                                 

                                I create a network with mesh control app

                                 

                                 

                                I provided the new code to the network (RED1) as shown in the image

                                 

                                prueba4.PNG

                                When I send the message: (0x670x650x740x730x740x6c) from the board with vendor client code to the board with the new code, the message is received and saved in p_data, then it starts the function: application_start1 ();

                                 

                                 

                                  if (disable_ntwk_retransmit)

                                                p_reply_event-> retrans_cnt = 0x80;

                                            // WICED_BT_TRACE ("Command accepted:% B", p_data);

                                            WICED_BT_TRACE ("Command accepted");

                                            memset (p_buffer, 'C', 6);

                                            application_start1 ();

                                            mesh_vendor_server_send_data (wiced_bt_mesh_create_reply_event (p_event), MESH_VENDOR_OPCODE2, p_buffer, data_len +1);

                                 

                                 

                                when the code enter the function application_start1 (); , the board starts scanning or starts to see (p_scan_result-> remote_bd_addr, p_scan_result-> rssi) but the board with the new code disconnects from the mesh network,

                                 

                                 

                                If you want, I send you the project code for you to look and understand

                                • 13. Re: we need help with BLE MESH
                                  VictorZ_46

                                  You do not need to scan in the mesh application because it is already scanning. It would be good if you read what I wrote again. I pointed you to the place where advertisement reports are received. And explained how to send them.

                                  • 14. Re: we need help with BLE MESH
                                    jama_4535901

                                    Yes, this is what I wanted, thank you very much

                                    it already scans and also receives and responds messages the vendor specific code and continues connected, thank you very much

                                     

                                    I have another question

                                    the next

                                    I need to send the data: "MAC:% B RSSI:% d \ r \ n", p_scan_result-> remote_bd_addr, p_scan_result-> rssi "to another card through the mesh network

                                    I tried to use this code that you suggested to me

                                     

                                    if (p_scan_result! = NULL)

                                        {

                                            uint8_t data [7];

                                     

                                            memcpy (data, p_scan_result-> remote_bd_addr, 6);

                                            data [6] = p_scan_result-> rssi;

                                     

                                            p_event = wiced_bt_mesh_create_event (0, YOUR_COMPANY_ID, YOUR_MODEL_ID, 0, 0);

                                     

                                            if (p_event == NULL)

                                            {

                                                WICED_BT_TRACE ("the device is not configured for publications \ n");

                                                return;

                                            }

                                           else

                                           {

                                                mesh_vendor_server_send_data (p_event, YOUR_OPCODE, data, 7);

                                           }

                                        }

                                     

                                    but I don't know how I get the data: YOUR_COMPANY_ID YOUR_MODEL_ID

                                     

                                    How can I get this data (YOUR_COMPANY_ID YOUR_MODEL_ID)

                                    and then send this data to another board through the mesh network

                                    1 2 Previous Next