This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

multiple clients to server message on Mesh

 in the code below. implemented on a mesh form multiple Clients (Publication addresses)  to the  server (subscriped) to all the clients.

The code reads beacon data, removes the Minor ID, combine it with the Client UUID . This needs to be sent to the server.

I would like to know 

1.  how to use the function :  access_model_reliable_publish(); to transmit the array Result[24]  from the code below 

2. Max clients that can send data to 1 server on a mesh.


/* Models */
#include "generic_onoff_client.h"

/* Logging and RTT */
#include "log.h"
#include "rtt_input.h"

/* Example specific includes */
#include "app_config.h"
#include "nrf_mesh_config_examples.h"
#include "light_switch_example_common.h"
#include "example_common.h"
#include "ble_softdevice_support.h"
#include "nrf_delay.h"
#include "string.h"
#define APP_STATE_OFF                (0)
#define APP_STATE_ON                 (1)

#define APP_UNACK_MSG_REPEAT_COUNT   (2)

static generic_onoff_client_t m_clients[CLIENT_MODEL_INSTANCE_COUNT];
static bool                   m_device_provisioned;
char scanner_UUID[17]; // scanner 2 bytes + 1



//for below also investigate ? nrf_mesh_rx_cb_t This callback can be used to receive raw advertisement packets
static void rx_cb(const nrf_mesh_adv_packet_rx_data_t * p_rx_data) // used for listening for incoming packets  with function nrf_mesh_rx_cb_set(rx_cb);
{
    LEDS_OFF(BSP_LED_0_MASK);  /* @c LED_RGB_RED_MASK on pca10031 */
    char msg[64];
    char beacon_Minor_ID[5]; // the length of the eMbeacon unique ID
    char Result[24]; // 5+16+1 for nul term
    char beacon_uuid[37]; // the length of EM microelectronics packet**** check this it may be shorter
 

// copy the UUID of the beacon
    memcpy(beacon_uuid,p_rx_data->p_payload, p_rx_data->length); // copy the UUID of the beacon
 // check if it is a EMbeacon Beacon make in bit 2:9
       if ((beacon_uuid[2]==0x45)|(beacon_uuid[3]==0x4D)|(beacon_uuid[4]==0x42)|(beacon_uuid[5]==0x65)
          |(beacon_uuid[6]==0x61)|(beacon_uuid[7]==0x63)|(beacon_uuid[8]==0x6f)|(beacon_uuid[9]==0x6e)) // EMBeacon name check
// if it is a beacon send PCA10059 (scanner) UUID and Beacon UUID to the client on the mesh
    {     
      memcpy (beacon_Minor_ID,beacon_uuid + 10,5); // move the 5 unique beacon ID bytes for use in mesh to identify the beacon
      memcpy(Result, (void*) &scanner_UUID[0], 16);       // combine Beacon Minor UUID and Scanner complete UUID 
      memcpy(&Result[16], (void*) &beacon_Minor_ID[0], 8); // Advertisement address 
 
 // Transmit Result on the mesh  to the gateway server.


access_model_reliable_publish();

Thanks in advance

  • HI Edvin thanks for the help so far.  I think my message is being sent correctly. I slowed it down by triggering it manually.

    On the server side Im facing the same problems as Narin here https://devzone.nordicsemi.com/f/nordic-q-a/31256/receiving-simple-message-mesh/123576

    As per Bjorn I have included the simple_message into main.c (Mesh v3) and changed access_model_publish() function, use this statement instead:  status= access_model_publish(m_server.model_handle, &msg);

    However

    1. m_server is undeclared. - 

    2. Where do I extract the message in mesh v3, in the access.c or in simple_message_server.c

    static void rx_get_cb(access_model_handle_t handle, const access_message_rx_t * p_message, void * p_args)
    {
    simple_message_server_t * p_server = p_args;
    NRF_MESH_ASSERT(p_server->get_cb != NULL);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Get--");
    reply_status(p_server, p_message);
    }

    Once again thank you fpr the help and insight into converting mesh v1 simple_message to mesh v3 simple_message it is highly appreciated.

  • Hi Edvin

    I have decided to discard this simple_message model from mesh v1. Its to old and I will now focus my research on the simple_on_off vendor model on mesh v3.1.

    I will start another thread.

Related