Operation sequence process of “Low Power Temperatures Sensor and Collector” of “KW36 SDK”

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Operation sequence process of “Low Power Temperatures Sensor and Collector” of “KW36 SDK”

1,079 Views
SeokJin
Contributor II

Hello.

I am learning the operation of the "Low Power Temperatures Sensor and Collector" of the "KW36 SDK" with two FREM-KW36 boards.

I studied the "BLE Application Developer's Guide" and the "BLE Demo Applications User's Guide", and also looked through the "KW38 Custom Profile".

After studying various documents, I came to understand a little about the action sequence of the example.

In the "Low Power Temperatures Sensor and Collector" example of 'KW36 SDK', I understood that the "Temp Sensor device" plays the role of Server and the "Temp Collector device" plays the role of Client.

At this time, it was understood that the “Server (Temp Sensor) device” receives requests or commands from the “Client (Temp Collector) device” and measures the temperature accordingly and transmits it to the Client device.

I have a question for you in this process.

 

- Questions -

When running the example, the "Client (Temp Collector) device" sends commands to the "Server (Temp Sensor) device", and the "Server" measures the temperature and sends it to the "Client". During this process, it seems that information containing 'cccd' and 'uuid' is being sent.

["BleApp_ConfigureNotifications(void)" function in 'BLE_temperature_collector.c']

SeokJin_0-1708684722935.png

 

After the 'Client (Temp Collector) device" sends a command, the 'Server (Temp Sensor) device" recognizes the command, measures the temperature, and transmits it to the 'Client'.

["BleApp_GattServerCallback (deviceId_t deviceId, gattServerEvent_t* pServerEvent)" function in 'BLE_temperature_sensor.c']

SeokJin_1-1708685236114.png

 

I understood that the value of "pServerEvent->eventType" should be set to 'gEvtCharacteristicCccdWritten_c' so that the "Server(Temp Sensor) device" can recognize the command from the "Client(Temp Collector)" and send the temperature through the Switch() function.

However, I am currently unable to find the process (code) to set the value of "pServerEvent->eventType" to 'gEvtCharacteristicCccdWritten_c' in the 'BLE_temperature_sensor.c' code.

Where can I find the process (code) for setting the value of "pServerEvent->eventType" to 'gEvtCharacteristicCccdWritten_c' in the 'BLE_temperature_sensor' code?

 

We are waiting for a detailed and detailed answer!
I am not yet familiar with the KW36 SDK and MCUX, so I would be very grateful if you could attach a picture of the code description or the location of the code I am looking for.

 

Best Regards,

SeokJin.

Labels (1)
0 Kudos
Reply
5 Replies

1,063 Views
EduardoZamora
NXP TechSupport
NXP TechSupport

Hello @SeokJin,

Those Events may be generated by the Stack.

gEvtCharacteristicCccdWritten_c is a member of enum gattServerEventType that indicates that a Client Characteristic Configuration Descriptor was written. CCCD is used by the Client to allow Server notifications and/or indications; notifications and indications are initiated by the Server.

For more information on GATT Server Event type enumeration, please consult the BLE Host Stack API Reference Manual from KW36 SDK documentation > docs > wireless > Bluetooth, Section 6.9 Enumeration Type Documentation.

Regards,
Eduardo.

0 Kudos
Reply

1,051 Views
SeokJin
Contributor II

hello.

Thank you for answer. Let me tell you what I understand.

I understand that the “client (temp collector) device” sends a command/request to the “server (temp sensor) device” and the “server” recognizes the command/request and operates.

Therefore, I think a process (code) is needed for the “server (temp sensor) device” to recognize the commands/requests from the “client (temp collector) device.”

If you look at the 'BLE_temperature_sensor.c' code, you can see the 'BleApp_SendTemperature();' code, which sends the temperature from the "server (temp sensor) device" to the "client (temp collector) device."

SeokJin_0-1708778002523.png

 

In order to transmit the temperature, you can see that "pServerEvent->eventType" of 'BleApp_GattServerCallback (deviceId_t deviceId, gattServerEvent_t* pServerEvent)' must be "gEvtCharacteristicCccdWritten_c".

SeokJin_1-1708778056141.png

 

So, I looked up 'gEvtCharacteristicCccdWritten_c' and saw that it was defined as "gEvtCharacteristicCccdWritten_c = 0x03" in 'gatt_server_interface.h'.

SeokJin_2-1708778274112.png

 

1. As soon as the 'cccd' received from the "client (temp collector) device" is written, does it automatically become "gEvtCharacteristicCccdWritten_c = 0x03"?

2. Or is there a process (code) that sets "gEvtCharacteristicCccdWritten_c = 0x03" in the "server (temp sensor) device" when a command/request is received from the "client (temp collector) device"?

 

I think number 2 is correct, so I'm looking for the process (code) to set "gEvtCharacteristicCccdWritten_c = 0x03" in 'BLE_temperature_sensor.c'.

In which part of 'BLE_temperature_sensor.c' does the process (code) of setting "gEvtCharacteristicCccdWritten_c = 0x03" take place?

 

Additionally, please let me know whether the example is run as 1 or 2.

I will be waiting for your kind and detailed answer again this time. thank you!

 

Best Regard,

SeokJin

0 Kudos
Reply

1,005 Views
EduardoZamora
NXP TechSupport
NXP TechSupport

Hi,

As you mentioned, bleResult_t BleApp_ConfigureNotifications(void) from source/temperature_collector.c is used to enable temperature notifications by writing peer's CCCD of the Temperature characteristic.

This function calls GattClient_WriteCharacteristicDescriptor API which initializes the Characteristic Descriptor Write procedure for a given Characteristic Descriptor. This API may be handled by the Stack library and it is described in the Host Stack API Reference Manual, Section 5.10.19.

Regards,
Eduardo.

0 Kudos
Reply

997 Views
SeokJin
Contributor II

Hello,

Based on your answer, I checked the Host Stack API Reference Manual and understood the operation of the "Client(temp collector) device".

Now, if I understand the operation of the "Server(temp sensor) device", I think the part I was curious about will be answered.

 

When the "Client (temp collector) device" calls the 'GattClient_WriteCharacteristicDescriptor' API and sends a CCCD to the "Server (temp sensor) device", how does the Server accept it?

1. As soon as CCCD is written from a "Client(temp collector) device", is the constant 'gEvtCharacteristicCccdWritten_c' in "temperature_sensor.c" automatically set to 0x03?

2. Or is there a process to set the 'gEvtCharactoristicCccdWritten_c' constant in "temperature_sensor.c" to 0x03 when the CCCD is written from the "Client (temp collector) device"?

 

Best Regards,

SeokJin

0 Kudos
Reply

963 Views
EduardoZamora
NXP TechSupport
NXP TechSupport

Hi,

According to the Bluetooth Core Spec 5.0, a client may write this configuration descriptor to control the configuration of this characteristic on the server for the client, so, the server is allowed to send indications or notifications.

Once the CCCD has been written, the event gEvtCharacteristicCccdWritten_c is generated by the Stack on the Server side so the Server can send the value to the Client.

Perhaps you can refer to the Core Specification 5.0 | Bluetooth® Technology Website for more information. Vol 3, Part G, Section 3.3.3.3 describes the Client Characteristic Configuration descriptor.

Regards,
Eduardo.

0 Kudos
Reply