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

Establish Smart Phone Data Link from Mesh Proxy

Hi, 

Here I met a problem, please help.

I am using proxy.c to establish an data link with smartphone via mesh_GATT.

What I am doing is like this:

For TX ,

it is actually a service notification

1. I created a function to use proxy_connection,  I understand, only one connection permited.

static void send_data_to_smartphone(proxy_connection_t * p_connection)
{

__LOG(LOG_SRC_BEARER, LOG_LEVEL_INFO, "START TX\n");

proxy_enable();
if (packet_alloc(p_connection, MESH_GATT_PDU_TYPE_NETWORK_PDU, SEAT_BELT_PACKET_SIZE, NRF_MESH_SERVICE_BORDER_TOKEN) ==
NRF_SUCCESS)

{
memcpy(p_connection->p_alloc_packet, seat_belt_data.tx_data, sizeof(seat_belt_data.tx_data));
// memset(seat_belt_data.tx_data,0xFF,SEAT_BELT_PACKET_SIZE);
}

packet_send(p_connection);

}

2. I  called this function  in

" static void gatt_evt_handler(const mesh_gatt_evt_t * p_evt, void * p_context)"

at  position:

  case MESH_GATT_EVT_TYPE_TX_READY:
__LOG(LOG_SRC_BEARER, LOG_LEVEL_INFO, "TX ready\n");

send_data_to_smartphone(p_connection);
beacon_cycle_send(p_connection);
break;

3. Smartphone side: start nRF Connect

Result:   1)  from smartphone I can see data keep coming ,but it is not my data;

                2)  in debug process, 
__LOG(LOG_SRC_BEARER, LOG_LEVEL_INFO, "START TX\n");

     do not show up?


for RX

I follow  rx_handle function , 

case MESH_GATT_EVT_TYPE_RX:
__LOG(LOG_SRC_BEARER, LOG_LEVEL_INFO, "RX\n");
rx_handle(p_connection,
p_evt->params.rx.pdu_type,
p_evt->params.rx.p_data,
p_evt->params.rx.length);

to file "network .c", inside

uint32_t network_packet_in(const uint8_t * p_packet, uint32_t net_packet_len, const nrf_mesh_rx_metadata_t * p_rx_metadata)

I put :


#if GATT_PROXY
if(p_rx_metadata->source==NRF_MESH_RX_SOURCE_GATT)
{
__LOG(LOG_SRC_BEARER, LOG_LEVEL_INFO, "RX2_Start\n");
memcpy(seat_belt_data.rx_data,&net_decrypted_packet,sizeof(net_decrypted_packet));
}

try to memcopy the pocket arrive from  mesh GATT.

Result. 

1. smartphone side:  when I try to write data, the connection terminated immediately,.

2. in debug process,  I can not see any reaction , even log info.

Please help how to move at this point.

Thanks a lot.

Brent

  • Hi Brent,

    We clearly have a misunderstanding here. I was not clear enough in explaining myself. If you want to use the smartphone to monitor a mesh network, you will need to create your own app that you can base off of the nrf mesh app for example.

    To facilitate the communication between the smartphone & the mesh, you can create a new model that I mentioned in the last comment. Just create a new model based on the simple on off server model. Instead of then communicating to the simple on off server model, change the app to communicate with the new "generic message model" you create.

    Kind Regards,

    Bjørn

  • Hi, Bjørn

    Thanks a lot! 

    I will go New_Model plan,  see if I can go through.  

    Let you know soon.

    Regards

    Brent 

  • Hi, Bjørn

    Still a question to ask.

    In mesh profile , page 141, there is a " GATT Proxy State" defined , this state decides Proxy enable,  Proxy disable or Proxy unsupported.

    I think , this state tell us why  smart phone connection is rejected when trying sending data to mesh network.

    When I trace back to code, this state is controlled by " Config_Server":

    static void handle_config_gatt_proxy_get(access_model_handle_t handle, const access_message_rx_t * p_message, void * p_args);

    static void handle_config_gatt_proxy_set(access_model_handle_t handle, const access_message_rx_t * p_message, void * p_args)

    it is reasonable. and we know "Config_Server" will  only be set by "Config_client" through opcode command.

    In " Config_client.c"

    uint32_t config_client_gatt_proxy_set(bool state)
    {
    return NRF_ERROR_NOT_SUPPORTED;
    }

    uint32_t config_client_node_identity_get(uint16_t netkey_index)
    {
    return NRF_ERROR_NOT_SUPPORTED;
    }

    uint32_t config_client_node_identity_set(uint16_t netkey_index, config_identity_state_t state)
    {
    return NRF_ERROR_NOT_SUPPORTED;
    }

    .

    Is that means we can not set GATT_PROXY_STATE on app level ?  or is there any other way to set this state? 

    I mean , if this sate can be set on app level , we can easily work with samrt phone via MESH_GATT.

    Sorry for trouble you again.

    Regards

    Brent 

  • Hi, Bjørn

    Forget about this question.

    Without nrf_mesh, we can not get through encryption_decryption process, I realized why the data received on smart phone is totally not what I sent.

    Regards

    Brent

  • Hi Brent,

    Thanks for the update. Let me know if you have any more questions regarding this subject.

    Kind Regards,

    Bjørn

Related