Forums - How can i use pingModel?

3 posts / 0 new
Last post
How can i use pingModel?
sunpil
Join Date: 6 Jun 16
Posts: 7
Posted: Tue, 2016-07-12 06:01

Hi^ ^

Dear My friends.

 

i have little problem...

please help me.

 

i hope use ping model.

First, i programmed Android application.

i sent this code used button.

(Android App code / (Test device : Samsung Galuxy Note 3))

byte [] data = {0x11, 0x22, 0x33, 0x44};

PingModel.request(mDeviceId,data,(byte)0x55);
 
 
 
 
Second,  i programmed Firmware(i used ver 2.0.1 Lighting)
 
[next code include in AppInit()]
/*Initialize the ping model*/
PingModelInit(0, NULL, MAX_MODEL_GROUPS, AppPingEventHandler);
 
 
 
 
 
Last, i programmed next code in "app_mesh_event_handler.c"
 
CSRmeshResult AppPingEventHandler(CSRMESH_MODEL_EVENT_T event_code,
                                       CSRMESH_EVENT_DATA_T* data,
                                       CsrUint16 length,
                                       void **state_data)
{
 
CSRMESH_PING_RESPONSE_T ping_response;
    switch(event_code)
    {
case CSRMESH_PING_REQUEST:
 
 
DEBUG_U16(p_request->arbitrarydata_len);
ping_response.arbitrarydata
ping_response.arbitrarydata[0] = (CsrUint8)0x11;
ping_response.arbitrarydata[1] = (CsrUint8)0x22;
ping_response.arbitrarydata[2] = (CsrUint8)0x33;
ping_response.arbitrarydata[3] = (CsrUint8)0x44;
 
ping_response.arbitrarydata_len =4;
ping_response.ttlatrx = (CsrUint8)0x55;
ping_response.rssiatrx = 1;
 
PingResponse(data->nw_id, data->dst_id, &ping_response);
 
//state_data = NULL;
//*state_data = (void *)&ping_response;
 
break;
 
default:
break;
    }
return CSR_MESH_RESULT_SUCCESS;
}
 
 
 
 
Compile is no problemed. 
because i attached libraries for ping_server.
 
but...
I can't response.
 
how can i do?
what is problem?
 
help me please.
 
i will waitting your reply.
 
Cheers~!
 
 
  • Up0
  • Down0
Jesse Tsai Moderator
Join Date: 5 Apr 16
Posts: 12
Posted: Thu, 2016-07-21 20:57

Hi,

To send reply from ping request, please refer to sample below:

        case CSRMESH_PING_REQUEST:
        {
            CSRMESH_PING_REQUEST_T *p_event = (CSRMESH_PING_REQUEST_T *)data->data;
 
            for (i = 0; i < 4; i++)
            {
                g_lightapp_data.ping_response.arbitrarydata[i] = p_event->arbitrarydata[i];
            }
 
            g_lightapp_data.ping_response.arbitrarydata_len = 4;
            g_lightapp_data.ping_response.ttlatrx = p_event->rspttl;
            g_lightapp_data.ping_response.rssiatrx = 0;
 
            if (state_data != NULL)
            {
                *state_data = (void *)&g_lightapp_data.ping_response;
            }
        }
        break;
 
Thanks.
  • Up0
  • Down0
sunpil
Join Date: 6 Jun 16
Posts: 7
Posted: Mon, 2016-07-25 02:37

oh~!

Thank you~!!

i can use Ping~!!

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.