element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Experimenting with Vibration Sensors
  • Challenges & Projects
  • Design Challenges
  • Experimenting with Vibration Sensors
  • More
  • Cancel
Experimenting with Vibration Sensors
Forum L2CAP with BLE and STM32
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 4 replies
  • Subscribers 3 subscribers
  • Views 1953 views
  • Users 0 members are here
  • ble
  • l2cap
  • stm32
  • bluenrg
Related

L2CAP with BLE and STM32

yosoufe
yosoufe over 4 years ago

Hi

 

It has been few weeks that I am trying to learn about Bluetooth low energy (BLE). This is the first time I code for bluetooth and I spent a lot on learning the basics. I managed to get my python script to communicate with the Nucleo board via the BLE expansion board. It seems the BLE is not designed for relatively large data. Every packet is like around 20 bytes of data. I read about L2CAP which seems it can increase the throughput. But I do not find an example or any code to use the BLE and L2CAP. L2CAP is marked as supported in the BLE exansion board but I do not know how to activate it and how it works.

 

My purpose is to be able to send the ADC measurements over BLE to the PC and do the rest of calculation on PC. It has been impossible to have a good speed of data transfer for this purpose. For example when I send 250 bytes from nucleo board to PC without L2CAP, it takes more than 1 seconds. The alternative is to do calculations on the nucleo board and use the BLE just as a notification.

 

If you know about the L2CAP and BLE please help me. I do not find anyway to send data using L2CAP with the bluenrg library as a server. bluenrg library has few functions to receive L2CAP stuff or sending as a client, but I could not find anything to initiate the communication over the L2CAP as server.

 

Thanks

Yousof

  • Sign in to reply
  • Cancel
  • shabaz
    0 shabaz over 4 years ago

    Hi Yousof,

     

    I have not used the particular hardware or software that you mention, however generally it is not expected to be necessary to code at the L2CAP level. The software stack for BLE for your processor/environment, or firmware inside the RF function inside the chip, will do all that. You normally only have access at a higher level API, which will interact at GAP and GATT level, if not an even higher level friendlier abstraction.

    When you make the API calls that will cause interaction at these higher levels, and the BLE software stack will automatically convert the high level instructions into the low level L2CAP layer.

    It is easiest to imagine it like I2C communication where you normally send bytes to your i2c_write function call, and do not need to toggle the SDA/SCL lines individually.

    The high level API will translate down internally in the stack to the low layer, and will then be handled accordingly over the air.

     

    If you're actually not interested in using the supplied BLE stack and just want to transmit raw bytes and handle your own error detection, retransmits, your own channel selection etc., then the chip may have a 'raw' mode, but then that is not BLE, the stack is too complex to code, and such a raw mode will not work with a PC expecting BLE communications.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 4 years ago

    By the way, here is a very simplistic diagram.

    If you're experiencing 1-second delays to send information, it could be that the higher-level API calls you're using, are causing advertisements and characteristics discovery procedures each time (which all filter down the stack from the location where they are initiated in each state machine in the stack), prior to sending your desired application data. All of those procedures take the times specified in the BLE spec.

    You may need to change what API calls you are using, or pass particular handles for subsequent requests to send your application data, or some other parameter. But you'll still have to work at the high level API, it's normally not possible to take a short-cut and try to send function calls mid-way in the stack directly to the L2CAP layer, that will break things.

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • yosoufe
    0 yosoufe over 4 years ago in reply to shabaz

    Hi @shabaz, Thanks

     

    Correrct. The bluenrg library that is provided by ST does not seem to have L2CAP-suppported high level APIs (or I could not find). Maybe because cortex M7 is not powerful enough? Or it is not provided yet? I am not sure.

     

    I was not also thinking that I could write them myself image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • yosoufe
    0 yosoufe over 4 years ago in reply to shabaz

    As I understood, the BLE sends in packets of 20 bytes, So the 250 bytes will be sent in 13 packets.

     

    Do you think I have something wrong or inefficient that takes so much ling? I will double check that then, Thanks.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube