Reply
Posts: 5
Registered: ‎09-11-2017

NCP Client gecko_handle_command

Hi all,

 

I have log some message when NCP example HOST side worked. It does transmit & receive data from client side.

For example,

 

If I send "gecko_cmd_system_get_bt_address", TX will transmit "20 00 01 03"  & RX will receive "20 06 01 03 B7 EA 57 0B 00"

 


and here is the flow I get:

 

1. Command (set header & payload) (Host_gecko.h)

2. gecko_handle_command(Gecko_bglib.c)

3. bglib_output、bglib_input(Gecko_bglib.h)

4. on_message_send、uartRX(main.c)

But when I send gecko command at client side, just like "gecko_cmd_system_get_bt_addressor "gecko_cmd_system_reset", I can't log any message from TX & RX.

 

How does "gecko_handle_command" work at client side ?

 

Thank you.

Posts: 2,826
Registered: ‎08-25-2015

Re: NCP Client gecko_handle_command

Hi,

 

What do you mean "send gecko command at client side" exactly? Are you calling those commands from within the NCP firmware running in the EFR32?

 

Regards,

Tiago

Posts: 5
Registered: ‎09-11-2017

Re: NCP Client gecko_handle_command

Hi tmonte,

 

Just like the while loop in main.c of ncp empty target example

 

case gecko_evt_le_connection_closed_id:

 

gecko_cmd_system_reset

 

this function also implement with gecko_handle_command(without response)

 

so I think it should has same behavior as host side.

 

Thank for your reply!

 

Posts: 2,826
Registered: ‎08-25-2015

Re: NCP Client gecko_handle_command

Hi,

 

Still not understanding what you mean. Are you saying that when you call a function from within the EFR32 firmware you're expecting the response to that command to be sent out to the host via UART?


Regards,

Tiago

Posts: 5
Registered: ‎09-11-2017

Re: NCP Client gecko_handle_command

Hi Tiago,

 

as the NCP-empty example

 

 

		while (evt)
		{
			switch (BGLIB_MSG_ID(evt->header))
			{
			case gecko_evt_le_connection_closed_id:
				/* Check if need to boot to dfu mode */
				if (boot_to_dfu)
				{
					/* Enter to DFU OTA mode */
					gecko_cmd_system_reset(2);
				}
				break;

			case gecko_evt_gatt_server_user_write_request_id:
				/* Handle OTA */
				if (evt->data.evt_gatt_server_user_write_request.characteristic == gattdb_ota_control)
				{
					/* Set flag to enter to OTA mode */
					boot_to_dfu = 1;
					/* Send response to Write Request */
					gecko_cmd_gatt_server_send_user_write_response(
						evt->data.evt_gatt_server_user_write_request.connection,
						gattdb_ota_control,
						bg_err_success);
					/* Close connection to enter to DFU OTA mode */
					gecko_cmd_endpoint_close(evt->data.evt_gatt_server_user_write_request.connection);
				}
				break;

			default:
				break;
			}
			ncp_transmit_enqueue(evt);
			evt = gecko_peek_event();
		}


 

static inline void* gecko_cmd_system_reset(uint8 dfu)
{
    gecko_cmd_msg->data.cmd_system_reset.dfu=dfu;
    gecko_cmd_msg->header=gecko_cmd_system_reset_id+((1)<<8);
	gecko_handle_command_noresponse(gecko_cmd_msg->header,&gecko_cmd_msg->data.payload);
    return 0;
}

static inline struct gecko_msg_endpoint_close_rsp_t* gecko_cmd_endpoint_close(uint8 endpoint)
{
    gecko_cmd_msg->data.cmd_endpoint_close.endpoint=endpoint;
    gecko_cmd_msg->header=gecko_cmd_endpoint_close_id+((1)<<8);
    gecko_handle_command(gecko_cmd_msg->header,&gecko_cmd_msg->data.payload);
    return &gecko_rsp_msg->data.rsp_endpoint_close;
}

 

I can find them in host side

 

void gecko_handle_command(uint32_t hdr, void* data)
{
	//packet in gecko_cmd_msg is waiting for output
	bglib_output(BGLIB_MSG_HEADER_LEN + BGLIB_MSG_LEN(gecko_cmd_msg->header), (uint8_t*)gecko_cmd_msg);
	gecko_wait_response();
}
#define BGLIB_INITIALIZE_NONBLOCK(OFUNC, IFUNC, PFUNC) bglib_output = OFUNC; bglib_input = IFUNC; bglib_peek = PFUNC;

BGLIB_INITIALIZE_NONBLOCK(on_message_send, uartRx, uartRxPeek);
static void on_message_send(uint32_t msg_len, uint8_t* msg_data) { /** Variable for storing function return values. */ int32_t ret; ret = uartTx(msg_len, msg_data); if (ret < 0) { printf("Failed to write to serial port %s, ret: %d, errno: %d\n", uart_port, ret, errno); ... }

but I can't find something similar in client side.

 

How does gecko_handle_command ( & noresponse ) implement in client side ?

 

Thank you!

 

Regards,
CT_Lin.

 

Posts: 2,826
Registered: ‎08-25-2015

Re: NCP Client gecko_handle_command

Hi,

 

For the client side that doesn't apply, you need to implement your own handling as you're the one who knows how your application flow must go.

 

Regards,

Tiago