Here is my raw project:
Link Removed
@Huydep_1 - Thanks for being so transparent and posting your code. I tried accessing the link but it prompted me to sign in. Iâve taken down this link to prevent users from logging into this site. I have no way of ensuring the login information is used correctly and I donât want others to have compromised login credentials.
My BLE library uses HAL API for all applications like BLUETOOTH communication and sensor reading, my function is to use PSoC 063 BLE to read DHT11 sensor and soil moisture sensor values and send The data is read over the mobile via Bluetooth LE connection. I use Modus Toolboxâs HAL API to do all of the above.
And thanks for this description! Sounds like youâre off to a great start
Iâll let you get to it. If you have further questions feel free to comment on this post or create a new post.
Thank you for helping me!
I followed your instructions and I referenced some similar examples on Github, I was able to connect to my Bluetooth. However, my event reading function still doesnât work
Here is all my code involved.
What are the priority of these tasks? How is cyhal_system_delay
implemented? Try changing it to vTaskDelay(pdMS_TO_TICKS(200));
.
I tried to change but why my program still doesnât read the condition but it still executes the program while checking the condition is not true?
The led at pin P7_1 stays on while the condition I set is 80 and what I read is 75?
I have checked the ADCâs condition but the DHT11âs condition I still canât execute it!
I donât understand why the uart_task
and the ble_task
both access the sensors concurrently. Thatâs probably a problem and also seems to make no sense.
Whatâs the purpose of the uart_task ?
Where are the ânotificationâ flags set/reset ?
Did you define configASSERT
and enabled stack checking ?
Whatâs the size of the task stacks ?
As @aggarg already recommended get rid of cyhal_system_delay
and use vTaskDelay
.
Because uart_task is a function that sends read notifications, processes data from the kit to the mobile application.
ble_task is a task to handle Bluetooth connection and consider conditions to perform data sending function.
Notification flags? What do you mean?
I just configure and call it I havenât found out through enabling stack inspection.
The sizes of my stacks are:
#define BLE_TASK_STACK_SIZE ((configMINIMAL_STACK_SIZE * 4 ))
#define BLE_TASK_PRIORITY ((configMAX_PRIORITIES - 1 ))
#define UART_TASK_STACK_SIZE ((configMINIMAL_STACK_SIZE * 4 ))
#define UART_TASK_PRIORITY ((configMAX_PRIORITIES - 2 ))
#define DK_TASK_STACK_SIZE ((configMINIMAL_STACK_SIZE * 4))
#define DK_TASK_PRIORITY ((configMAX_PRIORITIES - 3 ))
I used vTaskDelay instead of cyhal_system_delay.
Thank you.
It seems odd to me that ble and uart_task run the same sensor related code.
char_notification_enabled, etc.
Sorry - I donât understand this sentence.
But why not simply using the debugger and step through the code to see whatâs going on ?
I also just created the task ble_task as instructed above, in fact, there was only uart_task at first
/* Notifications enabled */
uint8_t char_notification_enabled = 0;
uint8_t humidity_notification_enabled = 0;
uint8_t temperature_notification_enabled = 0;
void uart_task(void *arg)
{
for (;;)
{
if(char_notification_enabled == true)
{
/* Sample input voltage at channel 0 */
adc_single_channel_process();
xTaskNotifyGive(ble_task_handle);
xTaskNotifyGive(dk_task_handle);
adc_send_notification();
}
if(humidity_notification_enabled == true)
{
humidity_send_notification();
printf("\r\nHumidity = %.2f\r\n",DHT_read.humidity);
}
if(temperature_notification_enabled == true)
{
temperature_send_notification();
printf("\r\nTemperature = %.2f\r\n",DHT_read.temperature);
}
/* 200ms delay between scans */
vTaskDelay(pdMS_TO_TICKS(200));
}
}
I havenât found out about the stack checking feature yet
I tried using the debugger but it doesnât detect the error!
Are you aware that uint8_t char_notification_enabled = 0;
means DISABLED because
this and the other similar conditions if(char_notification_enabled == true)
are never true ?
Did you ever used a debugger ? It allows to set breakpoints and step through single lines of code to verify the code and correct program behavior.
I tried debugging it however, no problem at all!
You are probably right about this
(Did you know that uint8_t char_notification_enabled = 0; means STARTED)
However, I understand it in a different way so for you that is when char_notification_enabled =0; means its value is equal to false;
And when if(char_notification_enabled == 1) value of it by true;
I may have misunderstood, please help me on this!
Thank you!
No - how should one know this secret meaning
I think itâs time to get your hands dirty and solve your programming problems yourself.
Take the chance to learn and maybe re-read the valuable hints the experts already provided to help you.
Good luck !
The OP shared the complete code here - PSoC 6 BLE ¡ Issue #1 ¡ quochuy12345/huydep_1 ¡ GitHub
There are following tasks -
- DHT task - This task runs every 2 seconds and reads some sensors and updates some globals.
- BLE task - This task send the sensors values updated by DHT task over BLE.
- DK task - This task tuns on LED based on sensor values updated by DHT task.
- Print task - This task prints sensor values updated by DHT task.
- UART task - As @hs2 suggested, this task is duplicate of BLE task and is not needed.
I changed the priority of DHT task to the highest. BLE and DK tasks wait for notification from DHT task. I do not have the hardware and therefore, did not test these changes.
Thank you because information
I am so grateful for this!