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,

    From my understanding, the mesh provisioning service, along with the Mesh Provisioning Data In & Data Out characteristics are currently only useable via the nRF Mesh iOS/Android applications. As soon as you try writing a value to the Data In characteristic, the device disconnects (as you have noticed).

    Have you tried merging the mesh example with the ble_app_uart functionality from sdk 15 or 15.1?

    Kind Regards,

    Bjørn

  • Hi,Bjørn

    Thanks again.

    As for your mentioned link,  definitelly many Nordic Ble central  examples can talk with smartphone, but they are out of mesh.I could not add packet into mesh network,  unless I add another model , such as smartphone_data model to handle this. and I can not use current GATT observer,  i need a seperate one, and do not know what happens in next steps.

    I saw some talks in this Blog,  Proxy is aimed to enable mesh network to work with temperary connections such as smartphone, .mesh profile1.0 talks like this either. I think it is reasonable, otherwise , why Proxy is added here? Could you help to check with your team, definitely there is a way to work it out.

    Actually I downloaded nRF mesh , but I think it is not a good ideal.  Reliability level required  of Mesh network is much higher than samrtphone. now a days , people change smart phone just like party meeting. but mesh network is Iot, it is engineering, need to be rubust against circumstances. Provisioner keeps all metadata of the network, It is riscky  to provision from smartphone.

    And one information I mentioned before is not full.   Ater provision, the Proxy--Samrtphone connection becomes active. I defined an APP Timer to watch the connection,  from Proxy side, data in/out stable,  from smartphone side, data keep coming. but the data is not Tx data of Proxy.

    It is very strange,  I read all the Proxy code ,  it is not complicated,  but designed to work between GATT and mesh network, permit only one connection for all mesh nodes,  but have GATT packet relayable.

    I just do not understand everything is just designed perfect here,  why we can not make it work.

    Please help to find what is best way out.

    Best Regards

    Brent 

    2818608>, smartphone_connection.c, 112, ----- Smartphone_Trig Timer Started -----
    <t: 2818611>, smartphone_connection.c, 71, Rx_Buffer : 00000000000000000000000000000000000000000000000000000000000000FFFF
    <t: 2818616>, smartphone_connection.c, 72, Tx Buffer : 999999999999999999999999999999999999999999999999999999999999999999
    <t: 2887963>, network.c, 409, RX1_Start
    <t: 3051716>, network.c, 409, RX1_Start
    <t: 3146272>, server_model_application.c, 101, ----- Server_Trig Timer Started -----
    <t: 3146275>, et_sensor.c, 174, belt_sensor_status=0
    <t: 3146278>, et_sensor.c, 183, seat_sensor_status=0
    <t: 3146280>, et_sensor.c, 240, Battery_Value=0
    <t: 3146282>, et_sensor.c, 44, DeviceId = 6794
    <t: 3146288>, smartphone_connection.c, 112, ----- Smartphone_Trig Timer Started -----
    <t: 3146292>, smartphone_connection.c, 71, Rx_Buffer : 00000000000000000000000000000000000000000000000000000000000000FFFF
    <t: 3146297>, smartphone_connection.c, 72, Tx Buffer : 999999999999999999999999999999999999999999999999999999999999999999
    <t: 3473952>, server_model_application.c, 101, ----- Server_Trig Timer Started -----
    <t: 3473955>, et_sensor.c, 174, belt_sensor_status=0
    <t: 3473957>, et_sensor.c, 183, seat_sensor_status=0
    <t: 3473960>, et_sensor.c, 240, Battery_Value=0
    <t: 3473962>, et_sensor.c, 44, DeviceId = 6794
    <t: 3473968>, smartphone_connection.c, 112, ----- Smartphone_Trig Timer Started -----
    <t: 3473971>, smartphone_connection.c, 71, Rx_Buffer : 00000000000000000000000000000000000000000000000000000000000000FFFF
    <t: 3473976>, smartphone_connection.c, 72, Tx Buffer : 999999999999999999999999999999999999999999999999999999999999999999
    <t: 3706927>, network.c, 409, RX1_Start
    <t: 3801632>, server_model_application.c, 101, ----- Server_Trig Timer Started -----
    <t: 3801635>, et_sensor.c, 174, belt_sensor_status=0
    <t: 3801637>, et_sensor.c, 183, seat_sensor_status=0
    <t: 3801640>, et_sensor.c, 240, Battery_Value=0
    <t: 3801642>, et_sensor.c, 44, DeviceId = 6794
    <t: 3801648>, smartphone_connection.c, 112, ----- Smartphone_Trig Timer Started -----
    <t: 3801651>, smartphone_connection.c, 71, Rx_Buffer : 00000000000000000000000000000000000000000000000000000000000000FFFF
    <t: 3801656>, smartphone_connection.c, 72, Tx Buffer : 999999999999999999999999999999999999999999999999999999999999999999
    <t: 3871537>, network.c, 409, RX1_Start
    <t: 4034280>, network.c, 409, RX1_Start
    <t: 4129312>, server_model_application.c, 101, ----- Server_Trig Timer Started -----
    <t: 4129315>, et_sensor.c, 174, belt_sensor_status=0
    <t: 4129317>, et_sensor.c, 183, seat_sensor_status=0
    <t: 4129320>, et_sensor.c, 240, Battery_Value=0
    <t: 4129322>, et_sensor.c, 44, DeviceId = 6794
    <t: 4129325>, et_sensor.c, 99, batt_volts=57
    <t: 4129330>, smartphone_connection.c, 112, ----- Smartphone_Trig Timer Started -----
    <t: 4129333>, smartphone_connection.c, 71, Rx_Buffer : 00000000000000000000000000000000000000000000000000000000000000FFFF
    <t: 4129338>, smartphone_connection.c, 72, Tx Buffer : 999999999999999999999999999999999999999999999999999999999999999999
    <t: 4198997>, network.c, 409, RX1_Start
    <t: 4362521>, network.c, 409, RX1_Start
    <t: 4456992>, server_model_application.c, 101, ----- Server_Trig Timer Started -----
    <t: 4456996>, et_sensor.c, 174, belt_sensor_status=0
    <t: 4456998>, et_sensor.c, 183, seat_sensor_status=0
    <t: 4457002>, et_sensor.c, 240, Battery_Value=0
    <t: 4457004>, et_sensor.c, 44, DeviceId = 6794
    <t: 4457010>, smartphone_connection.c, 112, ----- Smartphone_Trig Timer Started -----
    <t: 4457013>, smartphone_connection.c, 71, Rx_Buffer : 00000000000000000000000000000000000000000000000000000000000000FFFF
    <t: 4457018>, smartphone_connection.c, 72, Tx Buffer : 999999999999999999999999999999999999999999999999999999999999999999
    <t: 4784672>, server_model_application.c, 101, ----- Server_Trig Timer Started -----
    <t: 4784675>, et_sensor.c, 174, belt_sensor_status=0
    <t: 4784678>, et_sensor.c, 183, seat_sensor_status=0
    <t: 4784680>, et_sensor.c, 240, Battery_Value=0
    <t: 4784682>, et_sensor.c, 44, DeviceId = 6794
    <t: 4784688>, smartphone_connection.c, 112, ----- Smartphone_Trig Timer Started -----
    <t: 4784691>, smartphone_connection.c, 71, Rx_Buffer : 00000000000000000000000000000000000000000000000000000000000000FFFF
    <t: 4784696>, smartphone_connection.c, 72, Tx Buffer : 999999999999999999999999999999999999999999999999999999999999999999
    <t: 5018187>, network.c, 409, RX1_Start
    <t: 5112352>, server_model_application.c, 101, ----- Server_Trig Timer Started -----
    <t: 5112355>, et_sensor.c, 174, belt_sensor_status=0
    <t: 5112357>, et_sensor.c, 183, seat_sensor_status=0
    <t: 5112360>, et_sensor.c, 240, Battery_Value=0
    <t: 5112362>, et_sensor.c, 44, DeviceId = 6794
    <t: 5112368>, smartphone_connection.c, 112, ----- Smartphone_Trig Timer Started -----
    <t: 5112371>, smartphone_connection.c, 71, Rx_Buffer : 00000000000000000000000000000000000000000000000000000000000000FFFF
    <t: 5112376>, smartphone_connection.c, 72, Tx Buffer : 999999999999999999999999999999999999999999999999999999999999999999
    <t: 5345625>, network.c, 409, RX1_Start
    <t: 5440032>, server_model_application.c, 101, ----- Server_Trig Timer Started ----

  • Hi Brent,

    Sorry for the delayed response. The reason nRF Connect disconnects from the provisioning service is that you are most likely not sending the correctly formatted data. I am not sure it is possible at the moment to send data via nRF Connect to the proxy node.

    What you could do is create a new model based on the simple on off model. Then, if you take a look at the handle_set_cb() function in  the simple_on_off_server.c code, you can see this line of code:

    bool value = (((simple_on_off_msg_set_t*) p_message->p_data)->on_off) > 0;

    p_message is an access_message_rx_t struct pointer. Inside this struct, you can see the const p_data pointer which points to the first byte of the message data. Instead of making that const, you can change this to be a byte stream instead. Make sure to change the length of the byte stream too (i.e. uint16_t length). It could also be useful to take a look at this documentation.

    Kind Regards,

    Bjørn

  • HI, Bjørn

    I guess we have misunderstanding here, let me make it clear:

    1. I do not have problem on adding models,  models work good. 

       SDK co_existance is fine too, I used MESH SDK and SDK 5_15.00 together .

    2. I do not want to use " nRF Mesh iOS/Android applications" example on  smartphone to work as provisioner, I just want to use smartphone to monitor mesh network and set parameters with my own Phone_APP.

    My understanding , nRF Mesh iOS/Android applications"  uses Mesh_GATT (PB_GATT)  to provision the device.  I want to use mesh_GATT to establish a packet exchange with mesh network after the nodes have been provisioned.. 

    In the previous message, I show you how I did to cut_in from Proxy.  but the data is not correct,  anypoint, where I am wrong?

    Best Regards

    Brent

Related