I have not given this a ton of thought but the basic idea would be to modify
the LL task. The LL task is in ble_ll.c and is initialized through a call to
ble_ll_init(). Once the task has started you will be in the following loop:
while(1) {
os_eventq_run(&g_ble_ll_data.ll_evq);
}
So, you will have to figure out when you want to stop the BLE stack and run
your stack. A simple example is you set/clear a global variable when you want
to run your proprietary stack or the BLE stack. I presume you can run your
stack using a single task. Well, it can use multiple tasks but I figured you
would want to save memory.
while (1) {
if (run_ble_stack) {
os_eventq_run(&g_ble_ll_data.ll_evq);
} else {
os_eventq_run(&proprietary_stack_evq);
}
}
You might want to do this through function pointers as well; this is just an
example.
Here are other things to consider:
1) When you switch between the BLE stack and RF stack you will need to
re-configure the RF transceiver.
2) You will have to be cautious when you stop the BLE stack. You have to make
sure the transceiver is disabled and that no interrupts are running.
3) You will probably want to change interrupt vectors for some interrupts; I
suspect the nrf radio interrupt at the least.
4) Another interesting issue is the state of the memory when you switch between
the two stacks. If you need to re-use memory between the two stacks that is
going to be tricky; hopefully there is enough memory to keep these independent.
I am not sure what you will need to do about the host portion of the BLE stack.
What I have outlined are the basic steps to make sure the controller does not
run. You dont want the host running and sending commands to the LL controller.
While this wont necessarily “break” things it will not be optimal.
There are probably some better ways to do what you want, but without having a
better understanding of your stack it is a bit difficult to come up with a good
design.
> On Nov 16, 2016, at 3:09 PM, L.M Chew <[email protected]> wrote:
>
> Hi Will,
>
> At the moment, we want to keep it simple.
>
> So the flow is as you mentioned below:
> run the bluetooth stack, finish up with
> any connections or other advertising/scanning events only then run our
> proprietary RF Stack.
>
> Best Regards
> Chew
>
> _____________
>
>
>
> Chew:
>
> It really depends on how you want your stack to operate alongside the
> bluetooth stack (in
> the time domain). This is a bit hard to put into words, but an example might
> help. Consider
> a bluetooth connection. If you are connected to a bluetooth device do you
> want your RF stack
> to run in between the connection events? Or do you run the bluetooth stack,
> finish up with any connections or other advertising/scanning events, then run
> your RF stack?
>
>
>
>
>> On Nov 15, 2016, at 10:46 PM, L.M Chew <[email protected]> wrote:
>>
>> Hi Aditi,
>>
>> Thanks for the welcome. :-)
>>
>> Currently we have a proprietary RF Stack firmware (it uses proprietary air
>> protocol)
> running on a nRF52 chip, we are using Nordic's SDK + FreeRTOS to build this.
>>
>> Now we want to port part of the RF Stack firmware into Mynewt so that our
>> nRF52 device
> can switch between NimBLE stack and our own RF stack to communicate BLE
> device and our own
> proprietary RF device.
>>
>> So we like to know what is the best way to do this.
>>
>> Best Regards,
>> Chew
>>
>>> Hi Chew,
>>>
>>> Welcome to the Mynewt community! Could you provide a little more detail
>>> about what
> you’d
>>> like to do? Do you have a radio with a proprietary implementation of the
>>> controller
> that you
>>> want to integrate with the host portion of the NimBLE stack? The HCI API
>>> will come
> in handy
>>> there. If you want to take our NimBLE stack and tweak it, you can do that
>>> in a fork
> of the
>>> repo. If you tell us a little more we can respond better.
>>>
>>> thanks,
>>> aditi
>>>
>>>> On Nov 15, 2016, at 12:18 AM, L.M Chew <[email protected]> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I like to get some pointer on how to implement my company own proprietary
>>>> Custom
> RF Stack
>>> aside the Nimble BLE Stack.
>>>>
>>>> Best Regards,
>>>> Chew
>>