Skip to main content

Simple multithreading with DA14531

DA14531

1 year ago

Posted byjoachimkr65 points 8 replies
0 upvotes

Hello,

I have written an application with Keil IDE, transferring RFID reader results by notification of a subscribing node. The reader is part of my hardware system. Hardware handling is started, after a client requested to be notified by value change on his reader.
That is working, but it blocks any other activity.
Now, I need a hint / simple example, how I can accomplish the following:

Another, identical node may be instructed, to use this one as relay. This is a substitute for mesh and needs to fit into the small RAM, too. So I want to build a tree, where nodes near the root have somehow priority, but allow to forward the source and read result information. The DA14531 has no support for MESH and this is totally OK with me. I just need to serve more than one GATT service channel using the same connection. And, I need to support 3 or more connections, where I supervise the network with a node, which uses GATT services to instruct connections. No automatism, I want control about connections and accept a resulting priority.
I guess, I need to be able, to use another GATT channel/service, to place my parameters and start activity there, while my main activity continues.
What I already observed is, that after my main loop for detecting the RFIDs is started, no other GATT service is working anymore.
I tried it with an LED switch on or off. It is working fine, until I start my notification abonnement. When it is started, the LED switching GATT service is not reachable anymore.
I noticed, the advertising of services also stops - which is fine in principal. But I see it as an indication, that any other activity is impossible. My number of connections is set to 1. But is this the showstopper, or are there more?
The same connection is used to both services, but my RFID loop consumes anything. How can I suspend it, to serve further GATT services?
为什么我的第一通知服务occupying the entire system? (The code has polling nature, interrupt from the RFID frontend is currently not available)
As a first step, I want to be able, to use my LED switching service, while the RFID reader is running.

Thanks for help and hints!
Joachim

P.S. A backgrounder: Any node like PC or Raspberry seems to limit the number of connections. Some people have figured out, this is in the range of 7 connections, simultanously. I need to connect around 100 devices. The traffic will be small enough, to pass notifications from the mates.

1 year ago

PM_Dialog

Hi Joachimm,

Thanks for your question online and for your interest in our BLE products.

Let me check it, and I’ll get back to you.

Des the DA14531 act as a Central or as a Peripheral?

In the meanwhile, please take a look atDA14585/DA14586 - DA14531 Multiperipheral ExampleSW example.

This example demonstrates how a single peripheral can be connected to more than one centrals. DA14531 is able to support up to 3. Additionally it also demonstrates how one could keep different characteristic values depending on different connections.

Thanks, PM_Dialog

1 year ago

joachimkr 65 points

Hello,
That is in fact an interesting example, and it shows the expected difficulty with the SDKs ROM functions overloaded. My first answer is:
My device could act in a peripheral role, advertising all services and one (fully capable) device, like a Raspberry PI, can then write the connection parameters for the entire orchestra to all devices, so any will build and keep up to 3 connections. One upwards, 2 downwards. Data received from downwards are forwarded to upwards.
Does that explain my idea? The two downward devices connect to the upward device.

Did you see my difficulty with the single-thread behaviour for my device? I need a way to return control to the library code, so it will serve more than one GATT service, my somehow polling code, which currently runs forever and exclusive.

Thanks a lot,
Joachim

1 year ago

PM_Dialog

Hi Joachim,

>>can then write the connection parameters for the entire orchestra to all devices, so any will build and keep up to 3 connections.

Regarding this statement, could you please clarify it? So, a single peripheral will be connected to 3 Centrals at the same time. So, the peripheral should update the connection parameters to all of the 3 connected Central?

Thanks, PM_Dialog

Hi Joachim,

>>can then write the connection parameters for the entire orchestra to all devices, so any will build and keep up to 3 connections.

Regarding this statement, could you please clarify it? So, a single peripheral will be connected to 3 Centrals at the same time. So, the peripheral should update the connection parameters to all of the 3 connected Central?

Thanks, PM_Dialog

1 year ago

joachimkr 65 points

Hello,

你误解了,我的目的是,3 concurrent connections at each device. 2 as central, in order to forward information from below ordered peripherals and 1 in the role of a peripheral to the next upper level. Result is a tree structure, where I have the basic functionality of a 'mesh' - where the higher levels send their messages faster to the final central.
As I found out, the limit seems near 7 concurrent connections at the most upper level. That means, I can build a binary tree.
The setup of this tree structure needs a mastering device, which just organizes the network.

Any DA14531 would need to support two peripherals and an upper central node.
Configuration (in terms of Bluetooth MAC addresses) would be set by a dedicated application and would be kept in nonvolatile memory.

Is this a bit more clear?
Thanks for your support,
Joachim

1 year ago

PM_Dialog

Hi joachimkr,

Would it be possible to share a high level block diagram of your application, so that we can understand it better?

Thanks, PM_Dialog

1 year ago

joachimkr 65 points

Hello,
Yes, of course. The DA14531 doesn't support mesh, so I search for a circumvent. I can live with a tree of devices, where some are near central, some are leafs. Leafs send their events, value changes to upper next level. There, it is forwarded, to next and so on. Finally, the device next to the consuming (non-DA14531) device sends anything coming from lower levels - and it's own value changes. My circumventing implementation needs a configuration, at the network setup. A managing device sends the connection data and role in this setup to any of the devices. They store this in nonvolatile memory. That is acceptable, because it is usually done just once. Does this make sense ?

Greetings,
Joachim

1 year ago

PM_Dialog

Hi joachimkr,

Apologies for the delay. The DA14531 is able to support up to 3 connections. However, it’s not possible to act both as Peripheral and as Central at the same time. You could perform role switching.

Thanks, PM_Dialog

1 year ago

joachimkr 65 points

Hi,
Thanks for your advice for role switch. I might find out, what that implies.

At the moment, my plan is, to provide GATT services, which allow the leaf nodes, to deliver events/values to two services, left and right, where values are accepted and another service, where a parent node (both have the same roles) can register to be notified.
The result is a binary tree, where the root nodes send notifications for /in permission for/ all subtree units.

Each unit acts as forwarder and may generate own values by notification.
Bandwith is not a problem. I can also compress data to 20 bytes per notification.

The setup of this tree might need switching, but I assume (tell me, if I am wrong) that all tree units can stay in Peripheral mode, except for connection establishment. I would like a solution, to distribute the MACs of the tree units in a setup phase and trigger the tree units to store these permanent. I have a flash device attached.

btw. TI had an application note, with similar ideas. But I didn't understand the setup phase and want my own detailed, somehow manual setup.

Best regards,
Joachim