Sumair's Embedded Engineering
Sumair's Embedded Engineering
  • 74
  • 641 279
nRF5 SDK - Tutorial for Beginners Pt 46 B - Introduction to Services in BLE
This tutorial is also a part of my on going tutorial series for nordic microcontrollers nrf52832 & nrf52840 and in this tutorial we will continue to explore the BLE and learn about the services. I have tried to explain the services in the easiest possible way. After understanding the Profiles & Services we will understand the concepts of data transfer. Please watch carefully.
Download all mentioned files directly from this link:
drive.google.com/file/d/1a2c2g_nmARo0xbLkj4jbbBjpBLM23ADC/view?usp=sharing
Notice: i don't own these docs, they are the property of SIG group, i just put them together so that you can get them easily.
* My Patrons already have the access to 4 tutorials in advance, join my Patreon and get the exclusive access along with the code.
* Many thanks to the people who have donated on PayPal, really appreciate it. I will keep it up. Thanks for your love & support. :p
* Special thanks to my Patreon for their continuous support. Without your support i wasn't getting the motivation to keep on working on youtube after my work hours. Really appreciate it. ;p
If you like my work & want me to keep on making more tutorials on these devices, please do support me. You can make a one time donation or buy me a coffee :p on my PayPal Account:
PAYPAL: www.paypal.com/paypalme/Sembeddedengr
just click on this link to proceed, thanks :)
You can also support me through my Patron:
PATRON: www.patreon.com/sumairsembeddedengineering
just click this link to proceed. Your donations will keep me motivated, as I spend hours & hours to make a good quality content free of cost for everybody. Thanks in Advance... ;p
If you want to support me and want to learn the full course including all the code and tutorials then you can buy the full course on my official website, after this course you will be able to transfer data between BLE devices as well as create your own custom services and send custom types of data, so what are you waiting for, hurry up and buy our course, first 50 customers will get it at a discounted price:
👉🏼 courses.sumairsembedded.com/courses/nrf5-sdk-ble-development-for-starters/
Переглядів: 4 482

Відео

nRF5 SDK - Tutorial for Beginners Pt 46 A - Introduction to Profiles in BLE
Переглядів 2,7 тис.2 роки тому
This video is the part of my beginner tutorial series based on nrf52832 & nrf52840 and in this video we will continue to learn the basics of ble. We will learn about the profiles, we will understand why was this concept adopted for the BLE. We will learn how they help us make an application logic. The link to get the profiles & services documentation: www.bluetooth.com/specifications/specs/ * M...
nRF5 SDK - Tutorial for Beginners Pt 45 m - Vendor Specific Data in Advertisement Packets
Переглядів 2,2 тис.2 роки тому
This tutorial is also a part of my online tutorial series for beginners and based on nrf52832 & nrf52840 microcontrollers and in this tutorial we will continue to work on the advertisement and learn the final aspect of advertisement which is related to custom data. We can also transmit custom data which is also known as Manufacturer specific data in advertisement packets or Vendor Specific data...
nRF5 SDK - Tutorial for Beginners Pt 45 L - Adding Connection Interval data in BLE advertisement
Переглядів 2,1 тис.2 роки тому
This tutorial is also a part of my on going tutorial series for beginners based on nrf52832 & nrf52840 microcontrollers and in this tutorial we will continue to work with the advertisement in BLE. We will learn how to add the connection interval data into the BLE advertisement packets and then we will observe these packets on the scanner(master or receiving device). Link to download the code is...
nRF5 SDK - Tutorial for Beginners Pt 45 K - Including Service Data in Advertisement Packet
Переглядів 2,3 тис.2 роки тому
This tutorial is also a part of my on going tutorial series for beginners based on nrf52832 & nrf52840 microcontrollers and in this tutorial we will continue to learn more about advertisement. We will see how we can include some data from service in the advertisement packet, we can send this data as it can be useful in some cases, like sending battery percentage in advertisement packets. Link t...
nRF5 SDK - Tutorial for Beginners Pt 43 J - Services Initialization
Переглядів 2,6 тис.2 роки тому
This tutorial is also a part of my on going tutorial series for nrf52832 & nrf52840 microcontrollers and in this tutorial we will continue to work with the basic code for BLE and we will work on the services initialization code, right now we will just keep it to minimum and later in the series we will have a proper introduction to services and characteristic, at that point we will learn in dept...
nRF5 SDK - Tutorial for Beginners Pt 45 J - Including Service UUIDs in BLE advertisement packet
Переглядів 5 тис.2 роки тому
This tutorial is also a part of my on going tutorial series for nrf sdk5 based on nrf52832 and nrf52840 microcontrollers and in this tutorial we will continue to work with the advertisement and we will see how to send the UUID of the services which are included in the Peripheral Application. We will See how we can send this in advertisement packet so that the master device knows what services o...
nRF5 SDK - Tutorial for Beginners Pt 45 I - Tx Power Level in Advertisement Packet
Переглядів 2,5 тис.2 роки тому
This video is also a part of my on going tutorial series for beginners based on nrf52832 & nrf52840 and in this tutorial we will continue to learn about the advertisement in BLE. We will learn on how to send the tx power level in the advertisement packet so that the master devices can see the devices transmission power level. Link to download the code: drive.google.com/file/d/1AdnlLwBzNpvPs8E6y...
nRF5 SDK - Tutorial for Beginners Pt 45 H - Setting Device Flags in Advertisement Packet
Переглядів 1,8 тис.2 роки тому
This video is also a part of my on going tutorial series for beginners based on nrf52832 & nrf52840 and in this tutorial we will continue to learn more about advertisement in BLE and we will work with the device flags. We will learn about the Flags and their importance and their use in the advertisement will show what type of communication does the device support along with the other details of...
nRF5 SDK - Tutorial for Beginners Pt 45 G - Setting BLE Device Appearance
Переглядів 2,3 тис.2 роки тому
This tutorial is also a part of my on going tutorial series for beginners based on nrf52832 and nrf52840 microcontrollers. In this tutorial we will learn about the appearance of the device as its important to understand the concept of appearance of the device. The BLE device should have an appearance which can show the overall features of the device. We will learn that there are standard appear...
nRF5 SDK - Tutorial for Beginners Pt 45 F - Setting BLE Device Name
Переглядів 2,6 тис.2 роки тому
This tutorial is also a part of my on going tutorial series for beginners based on nrf52832 & nrf52840 microcontrollers and in this tutorial we will see how to program and set the device name in the BLE. The link to download the main code is here: drive.google.com/file/d/1tYGmlzIMKPY1WkkVWxfFZ_M2kZI4xr4f/view?usp=sharing * Many thanks to the people who have donated on PayPal, really appreciate ...
nRF5 SDK - Tutorial for Beginners Pt 45 E - Random Resolvable Private Address
Переглядів 1,7 тис.2 роки тому
This tutorial is also a part of my on going tutorial series for beginners based on nrf52832 & nrf52840 microcontrollers and in this tutorial we are going to learn further about the advertisement and we will see what is random resolvable private address. We will just go through it to understand it. * Many thanks to the people who have donated on PayPal, really appreciate it. I will keep it up. T...
nRF5 SDK - Tutorial for Beginners Pt 45 D - Non-Resolvable Private Address
Переглядів 2,1 тис.3 роки тому
This tutorial is also a part of my on going tutorial series for beginners based on nrf52832 & nrf52840 microcontrollers and in this tutorial we will continue to study the device advertisement and we will see how can we program the non resolvable private address for the slave device and we will see our device's address on the console as well as the master device which will be our mobile phone in...
nRF5 SDK - Tutorial for Beginners Pt 45 C - Random Static Address
Переглядів 2,8 тис.3 роки тому
This tutorial is also a part of my on going tutorial series based on nrf52832 & nrf52840 microcontrollers and in this tutorial we will continue studying the advertisement in BLE and we will see how the Random Static address works. We will learn the basic theory about it and then we will program it and see how it works. Link to Download the Code: drive.google.com/file/d/111i7dyazvKU9edChyU28-ScN...
nRF5 SDK - Tutorial for Beginners Pt 45 B - BLE Device Address Types
Переглядів 3,4 тис.3 роки тому
This tutorial is also a part of my ongoing tutorial series for beginners based on nrf52832 & nrf52840 & in this tutorial we will continue to learn more about the advertisement. In this tutorial we will learn about the device address types and how they are discovered by the scanning devices. The slave devices advertise the data & Master devices scan this data and then initialize the connection p...
nRF5 SDK - Tutorial for Beginners Pt 45 A -Advertisement Basics
Переглядів 7 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 45 A -Advertisement Basics
nRF5 SDK - Tutorial for Beginners Pt 44 -Installing WireShark & Packet Sniffer
Переглядів 13 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 44 -Installing WireShark & Packet Sniffer
nRF5 SDK - Tutorial for Beginners Pt 43 L - Final Basic BLE Application
Переглядів 4,9 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 L - Final Basic BLE Application
nRF5 SDK - Tutorial for Beginners Pt 43 K - Connection parameters initialization
Переглядів 3,7 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 K - Connection parameters initialization
nRF5 SDK - Tutorial for Beginners Pt 43 J - Services Initialization
Переглядів 1,6 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 J - Services Initialization
nRF5 SDK - Tutorial for Beginners Pt 43 I - Advertisement Programming Basics
Переглядів 5 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 I - Advertisement Programming Basics
nRF5 SDK - Tutorial for Beginners Pt 43 H - GATT Programming basics
Переглядів 4 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 H - GATT Programming basics
nRF5 SDK - Tutorial for Beginners Pt 43 G - GAP Programming Basics
Переглядів 6 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 G - GAP Programming Basics
nRF5 SDK - Tutorial for Beginners Pt 43 F - Enabling Softdevice for BLE App
Переглядів 7 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 F - Enabling Softdevice for BLE App
nRF5 SDK - Tutorial for Beginners Pt 43 E - Power Management Programming Basics
Переглядів 5 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 E - Power Management Programming Basics
nRF5 SDK - Tutorial for Beginners Pt 43 D - Programming BSP
Переглядів 4,3 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 D - Programming BSP
nRF5 SDK - Tutorial for Beginners Pt 43 C - Programming Application Timers
Переглядів 5 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 C - Programming Application Timers
nRF5 SDK - Tutorial for Beginners Pt 43 B - Setting nRF Logger for BLE app
Переглядів 6 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 B - Setting nRF Logger for BLE app
nRF5 SDK - Tutorial for Beginners Pt 43 A - Create a Base Project
Переглядів 8 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 43 A - Create a Base Project
nRF5 SDK - Tutorial for Beginners Pt 42 B - Testing first BLE Project
Переглядів 9 тис.3 роки тому
nRF5 SDK - Tutorial for Beginners Pt 42 B - Testing first BLE Project

КОМЕНТАРІ

  • @SumitAdep
    @SumitAdep 4 дні тому

    i am using minicom and says the serial i device that i want to use is locked

  • @WhatsHotThisWeek
    @WhatsHotThisWeek 11 днів тому

    Thanks for this wonderful video. I am using Nordic DVK. How i can print or see data from sensor on serial port? I connected the custom board with DVK using JTAG pins(Same as for programming). Can you help me with it plz? Thanks

  • @sofiapoletto5203
    @sofiapoletto5203 11 днів тому

    Hi! Can you tell me how to change the nRF channel to change the frequency? Thank you! :)

  • @nehapandey6613
    @nehapandey6613 18 днів тому

    hey, after installing segger, I'm not getting license for non-commercial use

  • @iprogramplus
    @iprogramplus 29 днів тому

    hello, sir. I love your tutorials. I wondered if the tWI should have a timeout since it keeps waiting forever. Thanks, Ephraim

  • @mikeselectricstuff
    @mikeselectricstuff Місяць тому

    You missed the part about installing pip...

  • @muhammadaqib614
    @muhammadaqib614 Місяць тому

    Hi, how can we add new components in the CMSIS configuration like i want to add UART or PWM in the blinky example of PCA-10040e, because other examples don't have the PCA-10040e example.

  • @SumitAdep
    @SumitAdep Місяць тому

    nice work buddy.

  • @elmira-s7d
    @elmira-s7d Місяць тому

    Why can't I see the output in PuTTY? I think it might need some specific settings. Can you help me?

  • @elmira-s7d
    @elmira-s7d Місяць тому

    Why can't I see the output in PuTTY? I think it might need some specific settings. Can you help me?

  • @maikhanhduong82
    @maikhanhduong82 Місяць тому

    Are you using external JLink or the on board Jlink for the nrf52532 DK? Can you show us how to set it up?

  • @maikhanhduong82
    @maikhanhduong82 Місяць тому

    Can we use VScode as IDE for this entire nrf52 SDK development series?

  • @shuaibalghazali3405
    @shuaibalghazali3405 2 місяці тому

    Thanks sumair i have been following your tutorial for some time now and thanks have been able to develop my BLE project. Please can i program the nrf52 dk with an external jlink. Somethings wrong with my onboard jlink now

  • @christianb5564
    @christianb5564 2 місяці тому

    Great work.!Thank you very much.

  • @SalemManar-o9h
    @SalemManar-o9h 2 місяці тому

    #include <stdbool.h> #include <stdint.h> #include <string.h> #include <nrf_log.h> #include <nrf_log_ctrl.h> #include <nrf_log_default_backends.h> #include "app_timer.h" #include <bsp_btn_ble.h> #include "nrf_pwr_mgmt.h" //include nrf softdevices library then we enable the soft devices in CMSIS #include "nrf_sdh.h" #include "nrf_sdh_ble.h" #include "nrf_sdh_soc.h" #include "nrf_ble_qwr.h" #include "nrf_ble_gatt.h" #include "ble_advdata.h" #include "ble_advertising.h" #include "ble_conn_params.h" #define APP_BLE_CONN_CFG_TAG 1 #define APP_BLE_OBSERVER_PRIO 3 #define DEVICE_NAME "Sam_BT" #define MIN_CONN_INTERVAL MSEC_TO_UNITS(100, UNIT_1_25_MS) #define MAX_CONN_INTERVAL MSEC_TO_UNITS(200, UNIT_1_25_MS) #define SLAVE_LATENCY 0 #define CONN_SUP_TIMEOUT MSEC_TO_UNITS(2000, UNIT_10_MS) #define FIRST_CONN_PARMS_UPDATE_DELAY APP_TIMER_TICKS(5000) #define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(30000) #define MAX_CONN_PARAMS_UPDATE_COUNT 3 #define APP_ADV_INTERVAL 300 #define APP_ADV_DURATION 0 NRF_BLE_QWR_DEF(m_qwr); NRF_BLE_GATT_DEF(m_gatt); BLE_ADVERTISING_DEF(m_advertising); static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /*9.1 error handler for queue writer */ static void nrf_qwr_error_handler(uint32_t nrf_error) { APP_ERROR_HANDLER(nrf_error); } /*9. SERVICES initialisation*/ static void services_init(void) { ret_code_t err_code; nrf_ble_qwr_init_t qwr_init = {0}; qwr_init.error_handler = nrf_qwr_error_handler; err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init); APP_ERROR_CHECK(err_code); } /* 10.2 create an error handler for conn params update */ static void on_conn_params_error_handler(uint32_t nrf_error) { APP_ERROR_HANDLER(nrf_error); } /*10.1 creat an event handler for connection parameters update */ static void on_conn_params_evt(ble_conn_params_evt_t * p_evt) { ret_code_t err_code; if (p_evt->evt_type == BLE_CONN_PARAMS_EVT_FAILED); { err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE); APP_ERROR_CHECK(err_code); } if(p_evt->evt_type == BLE_CONN_PARAMS_EVT_SUCCEEDED) { } } /*10. create a function for setting up the connection parameters*/ static void conn_params_init(void) { ret_code_t err_code; ble_conn_params_init_t cp_init; memset(&cp_init, 0, sizeof(cp_init)); cp_init.p_conn_params = NULL; cp_init.first_conn_params_update_delay = FIRST_CONN_PARMS_UPDATE_DELAY; cp_init.next_conn_params_update_delay = NEXT_CONN_PARAMS_UPDATE_DELAY; cp_init.max_conn_params_update_count = MAX_CONN_PARAMS_UPDATE_COUNT; cp_init.start_on_notify_cccd_handle = BLE_GATT_HANDLE_INVALID; cp_init.disconnect_on_fail = false; cp_init.error_handler = on_conn_params_error_handler; cp_init.evt_handler = on_conn_params_evt; err_code = ble_conn_params_init(&cp_init); APP_ERROR_CHECK(err_code); } /*8.1. create Advertising event handler */ static void on_adv_evt(ble_adv_evt_t ble_adv_evt) { ret_code_t err_code; switch (ble_adv_evt) { case BLE_ADV_EVT_FAST : NRF_LOG_INFO("FAST ADVERTISING"); err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING); APP_ERROR_CHECK(err_code); break; case BLE_ADV_EVT_IDLE: err_code = bsp_indication_set(BSP_INDICATE_IDLE); APP_ERROR_CHECK(err_code); break; default: break; } } /*8. Advertising initialisation*/ static void advertising_init(void) { ret_code_t err_code; ble_advertising_init_t init; memset(&init, 0, sizeof(init)); init.advdata.name_type = BLE_ADVDATA_FULL_NAME; init.advdata.include_appearance = true; init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; init.config.ble_adv_fast_interval = APP_ADV_INTERVAL; init.config.ble_adv_fast_timeout = APP_ADV_DURATION; init.evt_handler = on_adv_evt; err_code = ble_advertising_init(&m_advertising, &init); APP_ERROR_CHECK(err_code); ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG); } /*6. gap initialisation*/ static void gap_params_init(void) { ret_code_t err_code; ble_gap_conn_params_t gap_conn_params; ble_gap_conn_sec_mode_t sec_mode; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *)DEVICE_NAME, strlen(DEVICE_NAME)); APP_ERROR_CHECK(err_code); memset(&gap_conn_params, 0, sizeof(gap_conn_params)); gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL; gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL; gap_conn_params.slave_latency = SLAVE_LATENCY; gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT; err_code = sd_ble_gap_ppcp_set(&gap_conn_params); APP_ERROR_CHECK(err_code); } /*7. GATT initialisation*/ static void gatt_init(void) { ret_code_t err_code = nrf_ble_gatt_init(&m_gatt, NULL); APP_ERROR_CHECK(err_code); } /* 5.1 BLE EVENT HANDLEr */ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) { ret_code_t err_code = NRF_SUCCESS; switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_DISCONNECTED: NRF_LOG_INFO("device is disconnected!!"); break; case BLE_GAP_EVT_CONNECTED: NRF_LOG_INFO("device is connected !!"); err_code = bsp_indication_set(BSP_INDICATE_CONNECTED); APP_ERROR_CHECK(err_code); m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle); APP_ERROR_CHECK(err_code); break; case BLE_GAP_EVT_PHY_UPDATE_REQUEST: NRF_LOG_DEBUG("phy update request"); ble_gap_phys_t const phys = { .rx_phys = BLE_GAP_PHY_AUTO, .tx_phys = BLE_GAP_PHY_AUTO, }; err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys); APP_ERROR_CHECK(err_code); break; } } /* 5. Init BLE STACK softdevices*/ static void ble_stack_init() { ret_code_t err_code; err_code = nrf_sdh_enable_request(); APP_ERROR_CHECK(err_code); uint32_t ram_start = 0; //store the starting address of RAM required by the SoftDevice to manage memory err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start); APP_ERROR_CHECK(err_code); err_code = nrf_sdh_ble_enable(&ram_start); APP_ERROR_CHECK(err_code); } /* 4. Init Power Management */ static void power_management_init(void) { ret_code_t err_code = nrf_pwr_mgmt_init(); APP_ERROR_CHECK(err_code); } /*3. Init BSP(leds)*/ static void leds_init(void) { ret_code_t err_code = bsp_init(BSP_INIT_LEDS, NULL); APP_ERROR_CHECK(err_code); } /*2. Init timer app*/ static void timers_init(void) { ret_code_t err_code = app_timer_init(); APP_ERROR_CHECK(err_code); } /*1.initialize the logger*/ static void log_init() { ret_code_t err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); NRF_LOG_DEFAULT_BACKENDS_INIT(); } /* step 4.1: idle state handle (sleep mode after sending the data ) */ static void idle_state_handle(void) { if(NRF_LOG_PROCESS() == false) { nrf_pwr_mgmt_run(); } } /* 11 creat a function which will start the advertisement */ static void advertising_start(void) { ret_code_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_EVT_FAST); APP_ERROR_CHECK(err_code); } int main(void) { // Initialize. log_init(); timers_init(); leds_init(); power_management_init(); ble_stack_init(); gap_params_init(); gatt_init(); advertising_init(); services_init(); conn_params_init(); // Start execution. NRF_LOG_INFO("ble base application started ..."); advertising_start(); // Enter main loop. for (;;) { idle_state_handle(); } }

  • @SalemManar-o9h
    @SalemManar-o9h 2 місяці тому

    #include <stdbool.h> #include <stdint.h> #include <string.h> #include <nrf_log.h> #include <nrf_log_ctrl.h> #include <nrf_log_default_backends.h> #include "app_timer.h" #include <bsp_btn_ble.h> #include "nrf_pwr_mgmt.h" //include nrf softdevices library then we enable the soft devices in CMSIS #include "nrf_sdh.h" #include "nrf_sdh_ble.h" #include "nrf_sdh_soc.h" #include "nrf_ble_qwr.h" #include "nrf_ble_gatt.h" #include "ble_advdata.h" #include "ble_advertising.h" #include "ble_conn_params.h" #define APP_BLE_CONN_CFG_TAG 1 #define APP_BLE_OBSERVER_PRIO 3 #define DEVICE_NAME "Sam_BT" #define MIN_CONN_INTERVAL MSEC_TO_UNITS(100, UNIT_1_25_MS) #define MAX_CONN_INTERVAL MSEC_TO_UNITS(200, UNIT_1_25_MS) #define SLAVE_LATENCY 0 #define CONN_SUP_TIMEOUT MSEC_TO_UNITS(2000, UNIT_10_MS) #define FIRST_CONN_PARMS_UPDATE_DELAY APP_TIMER_TICKS(5000) #define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(30000) #define MAX_CONN_PARAMS_UPDATE_COUNT 3 #define APP_ADV_INTERVAL 300 #define APP_ADV_DURATION 0 NRF_BLE_QWR_DEF(m_qwr); NRF_BLE_GATT_DEF(m_gatt); BLE_ADVERTISING_DEF(m_advertising); static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /*9.1 error handler for queue writer */ static void nrf_qwr_error_handler(uint32_t nrf_error) { APP_ERROR_HANDLER(nrf_error); } /*9. SERVICES initialisation*/ static void services_init(void) { ret_code_t err_code; nrf_ble_qwr_init_t qwr_init = {0}; qwr_init.error_handler = nrf_qwr_error_handler; err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init); APP_ERROR_CHECK(err_code); } /* 10.2 create an error handler for conn params update */ static void on_conn_params_error_handler(uint32_t nrf_error) { APP_ERROR_HANDLER(nrf_error); } /*10.1 creat an event handler for connection parameters update */ static void on_conn_params_evt(ble_conn_params_evt_t * p_evt) { ret_code_t err_code; if (p_evt->evt_type == BLE_CONN_PARAMS_EVT_FAILED); { err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE); APP_ERROR_CHECK(err_code); } if(p_evt->evt_type == BLE_CONN_PARAMS_EVT_SUCCEEDED) { } } /*10. create a function for setting up the connection parameters*/ static void conn_params_init(void) { ret_code_t err_code; ble_conn_params_init_t cp_init; memset(&cp_init, 0, sizeof(cp_init)); cp_init.p_conn_params = NULL; cp_init.first_conn_params_update_delay = FIRST_CONN_PARMS_UPDATE_DELAY; cp_init.next_conn_params_update_delay = NEXT_CONN_PARAMS_UPDATE_DELAY; cp_init.max_conn_params_update_count = MAX_CONN_PARAMS_UPDATE_COUNT; cp_init.start_on_notify_cccd_handle = BLE_GATT_HANDLE_INVALID; cp_init.disconnect_on_fail = false; cp_init.error_handler = on_conn_params_error_handler; cp_init.evt_handler = on_conn_params_evt; err_code = ble_conn_params_init(&cp_init); APP_ERROR_CHECK(err_code); } /*8.1. create Advertising event handler */ static void on_adv_evt(ble_adv_evt_t ble_adv_evt) { ret_code_t err_code; switch (ble_adv_evt) { case BLE_ADV_EVT_FAST : NRF_LOG_INFO("FAST ADVERTISING"); err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING); APP_ERROR_CHECK(err_code); break; case BLE_ADV_EVT_IDLE: err_code = bsp_indication_set(BSP_INDICATE_IDLE); APP_ERROR_CHECK(err_code); break; default: break; } } /*8. Advertising initialisation*/ static void advertising_init(void) { ret_code_t err_code; ble_advertising_init_t init; memset(&init, 0, sizeof(init)); init.advdata.name_type = BLE_ADVDATA_FULL_NAME; init.advdata.include_appearance = true; init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; init.config.ble_adv_fast_interval = APP_ADV_INTERVAL; init.config.ble_adv_fast_timeout = APP_ADV_DURATION; init.evt_handler = on_adv_evt; err_code = ble_advertising_init(&m_advertising, &init); APP_ERROR_CHECK(err_code); ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG); } /*6. gap initialisation*/ static void gap_params_init(void) { ret_code_t err_code; ble_gap_conn_params_t gap_conn_params; ble_gap_conn_sec_mode_t sec_mode; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *)DEVICE_NAME, strlen(DEVICE_NAME)); APP_ERROR_CHECK(err_code); memset(&gap_conn_params, 0, sizeof(gap_conn_params)); gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL; gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL; gap_conn_params.slave_latency = SLAVE_LATENCY; gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT; err_code = sd_ble_gap_ppcp_set(&gap_conn_params); APP_ERROR_CHECK(err_code); } /*7. GATT initialisation*/ static void gatt_init(void) { ret_code_t err_code = nrf_ble_gatt_init(&m_gatt, NULL); APP_ERROR_CHECK(err_code); } /* 5.1 BLE EVENT HANDLEr */ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) { ret_code_t err_code = NRF_SUCCESS; switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_DISCONNECTED: NRF_LOG_INFO("device is disconnected!!"); break; case BLE_GAP_EVT_CONNECTED: NRF_LOG_INFO("device is connected !!"); err_code = bsp_indication_set(BSP_INDICATE_CONNECTED); APP_ERROR_CHECK(err_code); m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle); APP_ERROR_CHECK(err_code); break; case BLE_GAP_EVT_PHY_UPDATE_REQUEST: NRF_LOG_DEBUG("phy update request"); ble_gap_phys_t const phys = { .rx_phys = BLE_GAP_PHY_AUTO, .tx_phys = BLE_GAP_PHY_AUTO, }; err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys); APP_ERROR_CHECK(err_code); break; } } /* 5. Init BLE STACK softdevices*/ static void ble_stack_init() { ret_code_t err_code; err_code = nrf_sdh_enable_request(); APP_ERROR_CHECK(err_code); uint32_t ram_start = 0; //store the starting address of RAM required by the SoftDevice to manage memory err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start); APP_ERROR_CHECK(err_code); err_code = nrf_sdh_ble_enable(&ram_start); APP_ERROR_CHECK(err_code); } /* 4. Init Power Management */ static void power_management_init(void) { ret_code_t err_code = nrf_pwr_mgmt_init(); APP_ERROR_CHECK(err_code); } /*3. Init BSP(leds)*/ static void leds_init(void) { ret_code_t err_code = bsp_init(BSP_INIT_LEDS, NULL); APP_ERROR_CHECK(err_code); } /*2. Init timer app*/ static void timers_init(void) { ret_code_t err_code = app_timer_init(); APP_ERROR_CHECK(err_code); } /*1.initialize the logger*/ static void log_init() { ret_code_t err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); NRF_LOG_DEFAULT_BACKENDS_INIT(); } /* step 4.1: idle state handle (sleep mode after sending the data ) */ static void idle_state_handle(void) { if(NRF_LOG_PROCESS() == false) { nrf_pwr_mgmt_run(); } } /* 11 creat a function which will start the advertisement */ static void advertising_start(void) { ret_code_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_EVT_FAST); APP_ERROR_CHECK(err_code); } int main(void) { // Initialize. log_init(); timers_init(); leds_init(); power_management_init(); ble_stack_init(); gap_params_init(); gatt_init(); advertising_init(); services_init(); conn_params_init(); // Start execution. NRF_LOG_INFO("ble base application started ..."); advertising_start(); // Enter main loop. for (;;) { idle_state_handle(); } }

  • @yuliwong9200
    @yuliwong9200 2 місяці тому

    Very good and detailed explanation. but do we need Queued Writer of for broadcasting and peripheral that does not allow write function ?

  • @yuliwong9200
    @yuliwong9200 3 місяці тому

    why do i get NRF_ERROR_DATA_SIZE ?

  • @yuliwong9200
    @yuliwong9200 3 місяці тому

    I have issue with nrf52840, when I connect with my mobile Nrf Connect, the nrf console on desktop shows "connected" but the phone is still trying until it get disconnected. I even tried your code but same result

  • @yuliwong9200
    @yuliwong9200 3 місяці тому

    in your tutorial you keep mentioning about interrupt. Does the event trigger interrupt?. If it does this means it still uses cpu time.

  • @frankbuss
    @frankbuss 3 місяці тому

    Thanks, good video. But at 16:24 you write that the link to the official spes to BLE 5.1 is in the video description. But it is not in the description.

  • @smidani8132
    @smidani8132 4 місяці тому

    Hello friend, I noticed that the timer in this tutorial is faster compared to the program without using ppi and gpioe. What could be the reason?

  • @stevejordi6980
    @stevejordi6980 5 місяців тому

    Actually, what's the point to use an interrupt instead of a variable? Is there any event_handler triggered at some point? Does it compare its counter to a channel value like, say, NRF_TIMER_CC_CHANNEL0 and then reset to 0 and calls the event? Can we manually trigger the event function passed as the handler? Sorry, but I don't really get the interest of such a thing. Is it just a counter and doesn't do anything else? Thanks for any clarification.

  • @littlenewton6
    @littlenewton6 5 місяців тому

    Good job!

  • @littlenewton6
    @littlenewton6 5 місяців тому

    I am glad to see this video.

  • @alialdulaimi2259
    @alialdulaimi2259 6 місяців тому

    Can I get the presentation file ?

  • @aminollahzakizadeh5888
    @aminollahzakizadeh5888 6 місяців тому

    Well after 4 years I am here, because I could not download sdk toolchain in vscode [ which crashes while cloning from github] so that made me to use legacy nrf5 sdk v17, I encountered many problems. I opened twi_sensor example and saw that the sdk_config.h of that example have configurations which was not available in config/nrf52832/sdk_config.h , seems that Nordic Semi have many shortcomings in providing software tools.

  • @rhksgh3235
    @rhksgh3235 6 місяців тому

    Finally... I am here.

  • @DAECKarthikN
    @DAECKarthikN 7 місяців тому

    hello when build the program i am getting error as Building ‘ble_app_blinky_pca10056_s140’ from solution ‘ble_app_blinky_pca10056_s140’ in configuration ‘Debug’ 3> Linking ble_app_blinky_pca10056_s140.elf 3> C:/Program Files/SEGGER/SEGGER Embedded Studio 8.10b/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_blinky_pca10056_s140/ses_startup_nrf_common.o: in function `InitializeUserMemorySections': please guide me to solve this bug thank you

  • @karthic4404
    @karthic4404 7 місяців тому

    Can you make the video tutorials using nrf connect sdk

  • @rhksgh3235
    @rhksgh3235 7 місяців тому

    In my case, printf() always does not work. I don't see anything in the PUTTY. But when you used NRF_LOG_INFO, I could see the output. Do you know how I can fix to see printf()?

  • @zDoubleE23
    @zDoubleE23 7 місяців тому

    Love the functions where you don’t have to configure the tedious stuff like direction, pull-up resistors, and enables. Very Arduino like with that.

  • @rhksgh3235
    @rhksgh3235 7 місяців тому

    If I do a right click on the sdk_config.h, I cannot see the CMSIS_Configurator. Do you know a solution for this? Thanks

  • @gvkvacus
    @gvkvacus 7 місяців тому

    😊❤❤

  • @aokerem
    @aokerem 7 місяців тому

    Thank you so much. At first, It didn't work in my special board. the reason is that I connected the tx rx pins to different gpio legs. I understood it when I saw the pin configuration from boards.h in your other videos. I wish you're going to heaven if you believe in :)

  • @syousufimam
    @syousufimam 7 місяців тому

    Which J Link are you using ? Can you share the link of the same ?

  • @danigeorge959
    @danigeorge959 8 місяців тому

    thank you for this!

  • @RicardoOliveiraRGB
    @RicardoOliveiraRGB 8 місяців тому

    Great videos. Too bad you stop posting them, cuz the full course is expensive

  • @zynq_training2876
    @zynq_training2876 8 місяців тому

    Hi, There is something wrong and misleading in your slides. Standard services have 16-bits UUIDs. You say: they have 4 bytes, it is wrong. 16-bit = 2bytes. Thank you for your sharing.

  • @BavanMendon
    @BavanMendon 8 місяців тому

    Great series! Really wanted to know how to get BLE Central Mode to work on nRF52 though

  • @kavindushehan8984
    @kavindushehan8984 8 місяців тому

    too much complex for a beginner to understand

  • @see_ai_0
    @see_ai_0 8 місяців тому

    will this tutorial be suitable for nRF7002 ??? pl Guide

  • @MightyScharp
    @MightyScharp 8 місяців тому

    This is amazing. I will support you on patreon once I get my paycheck in a few days. With a guide like this I can work on my bachelor's thesis on capturing BLE signals in test center in my university. I absolutely love your videos.

  • @swapnilvhatkar
    @swapnilvhatkar 8 місяців тому

    what does it mean by cheat shit? How do i try it? I am only a beginner. please help.

  • @daniel.dosaru
    @daniel.dosaru 8 місяців тому

    How can this battery level be updated at runtime ?

  • @aokerem
    @aokerem 9 місяців тому

    Thank you very much for what you told. I have a question. I dont use any nRF SDK but I have nRF52832 chip in my card. I try to program it from SWD port with J-link but I couldn't. Im open to your advice.

  • @falrus
    @falrus 9 місяців тому

    Did you use any button debouncing?

  • @r0stikslav
    @r0stikslav 9 місяців тому

    if you got an error like ".text is larger than specified size" and ".rodata is larger than specified size" then navigate to ./pca10040/blank/ses/ inside of your project directory, open flash_placement.xml file, find folowing lines: <ProgramSection alignment="4" load="Yes" name=".text" sizeof="0x4"/> <ProgramSection alignment="4" load="Yes" name=".rodata" sizeof="0x4" /> and remove sizeof="0x4" in both cases. this error occures in newer versions of ses but the solution above fixed it in my case

    • @cjh8344
      @cjh8344 7 місяців тому

      Hey thank you for this comment, saved me major time.

    • @alvaro1734
      @alvaro1734 Місяць тому

      thanks that solve the problem, Im using the nRF52840 DK

  • @jonathanvfr
    @jonathanvfr 9 місяців тому

    This is the best tutorial on how to install the nRF sniffer plugin for Wireshark - thank you!

  • @victorruiz3318
    @victorruiz3318 9 місяців тому

    Hi, i have a doubt. I am programming two nrf52840 devices. One of them acts as advertiser and the others one acts as scanner. But my question is: Could I send a message in form of advertisement from the scanner to the advertiser without connecting them? I mean, using a directed adv from scanner and them receive It in the advertiser? But, with this approach, I would enable the advertiser and the scanner simultanously, and I do note think this is possible...