You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mynewt.apache.org by Lm Chew <lm...@free2move.se> on 2017/01/16 11:33:23 UTC

stopping scan & adv in bleprph example

Hi,

How do I stop the scan &  adv in the bleprph example.

I tried calling the ble_ll_scan_sm_stop(1) and  ble_ll_adv_stop in my app, but I am still able to see the device on my phone when I perform a scan.

I am trying to switch between my custom rf stack  and nimble bt stack. So I need to disable nimble  operation before running my custom RF Stack.
And once I am done what I need using the custom RF Stack, I will switch back nimble.

Another question, how do you put the MCU to deep sleep while using nimble stack? In the example the MCU does not goes to deep sleep.

Best Regards,
Chew


Re: stopping scan & adv in bleprph example

Posted by Christopher Collins <cc...@apache.org>.
Hi, sorry for the late response.  Somehow I missed this.

On Mon, Jan 16, 2017 at 08:22:27PM -0800, will sanfilippo wrote:
> Yes, Mynewt works the same way as FreeRTOS in this respect. Well, at least in the way you are describing FreeRTOS. We have a tickless OS and when we decide to go to sleep we are waiting for an interrupt to wake us up.
> 
> Regarding the radio: there are some registers that are only programmed once, so if you switch to your own custom RF stack and you want to switch back to bluetooth, you would either have to write some custom code or reset the link layer. There is an API to do this but I am not sure if it is accessible to the application developer.

It's not a part of the published host API, but the following function
should cause the host to reset the controller:

    void ble_hs_sched_reset(int reason)

The reason code doesn't matter; it is just something the host uses when
reporting terminated connections.  You can just specify 1.

Since this function isn't part of the API, you'll need to declare a
prototype by hand:

    void ble_hs_sched_reset(int reason);

Thanks,
Chris

Re: stopping scan & adv in bleprph example

Posted by will sanfilippo <wi...@runtime.io>.
Yes, Mynewt works the same way as FreeRTOS in this respect. Well, at least in the way you are describing FreeRTOS. We have a tickless OS and when we decide to go to sleep we are waiting for an interrupt to wake us up.

Regarding the radio: there are some registers that are only programmed once, so if you switch to your own custom RF stack and you want to switch back to bluetooth, you would either have to write some custom code or reset the link layer. There is an API to do this but I am not sure if it is accessible to the application developer.


> On Jan 16, 2017, at 5:08 PM, Lm Chew <lm...@free2move.se> wrote:
> 
> Hi Chris,
> 
> Thanks for the reply.
> 
> So calling ble_gap_adv_stop and ble_gap_disc_cancel will stop all radio activity is that correct?
> 
> Is it safe to modify the Radio setting(on the physical just like in ble_phy) after just calling these functions?
> 
> Hi Will,
> 
> Not exactly a "system off" I am looking for.
> Previously I am using FreeRTOS tickless mode where the MCU will remain in sleep mode most of the tire unless there is a task to perform.
> 
> I am asking this because in the bleprph example I don't see any function being called to put the MCU to sleep.
> 
> Does mynewt OS work the same way as FreeRTOS?
> 
> Best Regards,
> Chew
> 
> 
> 
> 
> 
> On Tue, Jan 17, 2017 at 1:57am, will sanfilippo <wi...@runtime.io>> wrote:
> 
> If by deep sleep you mean "system off" mode requiring some form of wakeup, it is curently not implemented. You would have to hook that in yourself.
> 
>> On Jan 16, 2017, at 9:22 AM, Christopher Collins <cc...@apache.org> wrote:
>> 
>> Hi Chew,
>> 
>> On Mon, Jan 16, 2017 at 11:33:23AM +0000, Lm Chew wrote:
>>> Hi,
>>> 
>>> How do I stop the scan &  adv in the bleprph example.
>>> 
>>> I tried calling the ble_ll_scan_sm_stop(1) and  ble_ll_adv_stop in my app, but I am still able to see the device on my phone when I perform a scan.
>> 
>> To stop advertising, call: ble_gap_adv_stop()
>> (http://mynewt.apache.org/latest/network/ble/ble_hs/ble_gap/functions/ble_gap_adv_stop/)
>> 
>> For BLE operations, an application should only use the host interface.
>> Functions with the "ble_ll" prefix are defined by the controller, not
>> the host, so your application should not call them.
>> 
>> Regarding scanning- the bleprph app doesn't perform any scanning, so
>> there is no need to stop scanning.  This application only implements the
>> peripheral role, so operations like scanning and initiating a connection
>> are not compiled in.  However, if you have a different app which does
>> support scanning, you would stop the scan procedure by calling
>> ble_gap_disc_cancel()
>> (http://mynewt.apache.org/latest/network/ble/ble_hs/ble_gap/functions/ble_gap_disc_cancel/)
>> 
>>> I am trying to switch between my custom rf stack  and nimble bt stack. So I need to disable nimble  operation before running my custom RF Stack.
>>> And once I am done what I need using the custom RF Stack, I will switch back nimble.
>>> 
>>> Another question, how do you put the MCU to deep sleep while using nimble stack? In the example the MCU does not goes to deep sleep.
>> 
>> Sorry, I am not sure about this one.  I am not sure this is actually
>> supported yet, but I'll let someone more knowledgable chime in.
>> 
>> Chris
> 


Re: stopping scan & adv in bleprph example

Posted by Christopher Collins <cc...@apache.org>.
Hi Chew,

On Tue, Jan 17, 2017 at 01:08:16AM +0000, Lm Chew wrote:
> So calling ble_gap_adv_stop and ble_gap_disc_cancel will stop all radio activity is that correct?

It depends on what your application has told the stack to do.  If you
have initiated a connection, you will also need to cancel that:

    ble_gap_adv_stop()
    ble_gap_disc_cancel()
    ble_gap_conn_cancel()

If any connections have already been established, then they will also
cause radio activity.  You can terminate connections with
ble_gap_terminate().

Chris

> Is it safe to modify the Radio setting(on the physical just like in ble_phy) after just calling these functions?
> 
> Hi Will,
> 
> Not exactly a "system off" I am looking for.
> Previously I am using FreeRTOS tickless mode where the MCU will remain in sleep mode most of the tire unless there is a task to perform.
> 
> I am asking this because in the bleprph example I don't see any function being called to put the MCU to sleep.
> 
> Does mynewt OS work the same way as FreeRTOS?
> 
> Best Regards,
> Chew
> 
> 
> 
> 
> 
> On Tue, Jan 17, 2017 at 1:57am, will sanfilippo <wi...@runtime.io>> wrote:
> 
> If by deep sleep you mean "system off" mode requiring some form of wakeup, it is curently not implemented. You would have to hook that in yourself.
> 
> > On Jan 16, 2017, at 9:22 AM, Christopher Collins <cc...@apache.org> wrote:
> >
> > Hi Chew,
> >
> > On Mon, Jan 16, 2017 at 11:33:23AM +0000, Lm Chew wrote:
> >> Hi,
> >>
> >> How do I stop the scan &  adv in the bleprph example.
> >>
> >> I tried calling the ble_ll_scan_sm_stop(1) and  ble_ll_adv_stop in my app, but I am still able to see the device on my phone when I perform a scan.
> >
> > To stop advertising, call: ble_gap_adv_stop()
> > (http://mynewt.apache.org/latest/network/ble/ble_hs/ble_gap/functions/ble_gap_adv_stop/)
> >
> > For BLE operations, an application should only use the host interface.
> > Functions with the "ble_ll" prefix are defined by the controller, not
> > the host, so your application should not call them.
> >
> > Regarding scanning- the bleprph app doesn't perform any scanning, so
> > there is no need to stop scanning.  This application only implements the
> > peripheral role, so operations like scanning and initiating a connection
> > are not compiled in.  However, if you have a different app which does
> > support scanning, you would stop the scan procedure by calling
> > ble_gap_disc_cancel()
> > (http://mynewt.apache.org/latest/network/ble/ble_hs/ble_gap/functions/ble_gap_disc_cancel/)
> >
> >> I am trying to switch between my custom rf stack  and nimble bt stack. So I need to disable nimble  operation before running my custom RF Stack.
> >> And once I am done what I need using the custom RF Stack, I will switch back nimble.
> >>
> >> Another question, how do you put the MCU to deep sleep while using nimble stack? In the example the MCU does not goes to deep sleep.
> >
> > Sorry, I am not sure about this one.  I am not sure this is actually
> > supported yet, but I'll let someone more knowledgable chime in.
> >
> > Chris
> 

Re: stopping scan & adv in bleprph example

Posted by Lm Chew <lm...@free2move.se>.
Hi Chris,

Thanks for the reply.

So calling ble_gap_adv_stop and ble_gap_disc_cancel will stop all radio activity is that correct?

Is it safe to modify the Radio setting(on the physical just like in ble_phy) after just calling these functions?

Hi Will,

Not exactly a "system off" I am looking for.
Previously I am using FreeRTOS tickless mode where the MCU will remain in sleep mode most of the tire unless there is a task to perform.

I am asking this because in the bleprph example I don't see any function being called to put the MCU to sleep.

Does mynewt OS work the same way as FreeRTOS?

Best Regards,
Chew





On Tue, Jan 17, 2017 at 1:57am, will sanfilippo <wi...@runtime.io>> wrote:

If by deep sleep you mean "system off" mode requiring some form of wakeup, it is curently not implemented. You would have to hook that in yourself.

> On Jan 16, 2017, at 9:22 AM, Christopher Collins <cc...@apache.org> wrote:
>
> Hi Chew,
>
> On Mon, Jan 16, 2017 at 11:33:23AM +0000, Lm Chew wrote:
>> Hi,
>>
>> How do I stop the scan &  adv in the bleprph example.
>>
>> I tried calling the ble_ll_scan_sm_stop(1) and  ble_ll_adv_stop in my app, but I am still able to see the device on my phone when I perform a scan.
>
> To stop advertising, call: ble_gap_adv_stop()
> (http://mynewt.apache.org/latest/network/ble/ble_hs/ble_gap/functions/ble_gap_adv_stop/)
>
> For BLE operations, an application should only use the host interface.
> Functions with the "ble_ll" prefix are defined by the controller, not
> the host, so your application should not call them.
>
> Regarding scanning- the bleprph app doesn't perform any scanning, so
> there is no need to stop scanning.  This application only implements the
> peripheral role, so operations like scanning and initiating a connection
> are not compiled in.  However, if you have a different app which does
> support scanning, you would stop the scan procedure by calling
> ble_gap_disc_cancel()
> (http://mynewt.apache.org/latest/network/ble/ble_hs/ble_gap/functions/ble_gap_disc_cancel/)
>
>> I am trying to switch between my custom rf stack  and nimble bt stack. So I need to disable nimble  operation before running my custom RF Stack.
>> And once I am done what I need using the custom RF Stack, I will switch back nimble.
>>
>> Another question, how do you put the MCU to deep sleep while using nimble stack? In the example the MCU does not goes to deep sleep.
>
> Sorry, I am not sure about this one.  I am not sure this is actually
> supported yet, but I'll let someone more knowledgable chime in.
>
> Chris


Re: stopping scan & adv in bleprph example

Posted by will sanfilippo <wi...@runtime.io>.
If by deep sleep you mean “system off” mode requiring some form of wakeup, it is curently not implemented. You would have to hook that in yourself.

> On Jan 16, 2017, at 9:22 AM, Christopher Collins <cc...@apache.org> wrote:
> 
> Hi Chew,
> 
> On Mon, Jan 16, 2017 at 11:33:23AM +0000, Lm Chew wrote:
>> Hi,
>> 
>> How do I stop the scan &  adv in the bleprph example.
>> 
>> I tried calling the ble_ll_scan_sm_stop(1) and  ble_ll_adv_stop in my app, but I am still able to see the device on my phone when I perform a scan.
> 
> To stop advertising, call: ble_gap_adv_stop()
> (http://mynewt.apache.org/latest/network/ble/ble_hs/ble_gap/functions/ble_gap_adv_stop/)
> 
> For BLE operations, an application should only use the host interface.
> Functions with the "ble_ll" prefix are defined by the controller, not
> the host, so your application should not call them.
> 
> Regarding scanning- the bleprph app doesn't perform any scanning, so
> there is no need to stop scanning.  This application only implements the
> peripheral role, so operations like scanning and initiating a connection
> are not compiled in.  However, if you have a different app which does
> support scanning, you would stop the scan procedure by calling
> ble_gap_disc_cancel()
> (http://mynewt.apache.org/latest/network/ble/ble_hs/ble_gap/functions/ble_gap_disc_cancel/)
> 
>> I am trying to switch between my custom rf stack  and nimble bt stack. So I need to disable nimble  operation before running my custom RF Stack.
>> And once I am done what I need using the custom RF Stack, I will switch back nimble.
>> 
>> Another question, how do you put the MCU to deep sleep while using nimble stack? In the example the MCU does not goes to deep sleep.
> 
> Sorry, I am not sure about this one.  I am not sure this is actually
> supported yet, but I'll let someone more knowledgable chime in.
> 
> Chris


Re: stopping scan & adv in bleprph example

Posted by Christopher Collins <cc...@apache.org>.
Hi Chew,

On Mon, Jan 16, 2017 at 11:33:23AM +0000, Lm Chew wrote:
> Hi,
> 
> How do I stop the scan &  adv in the bleprph example.
> 
> I tried calling the ble_ll_scan_sm_stop(1) and  ble_ll_adv_stop in my app, but I am still able to see the device on my phone when I perform a scan.

To stop advertising, call: ble_gap_adv_stop()
(http://mynewt.apache.org/latest/network/ble/ble_hs/ble_gap/functions/ble_gap_adv_stop/)

For BLE operations, an application should only use the host interface.
Functions with the "ble_ll" prefix are defined by the controller, not
the host, so your application should not call them.

Regarding scanning- the bleprph app doesn't perform any scanning, so
there is no need to stop scanning.  This application only implements the
peripheral role, so operations like scanning and initiating a connection
are not compiled in.  However, if you have a different app which does
support scanning, you would stop the scan procedure by calling
ble_gap_disc_cancel()
(http://mynewt.apache.org/latest/network/ble/ble_hs/ble_gap/functions/ble_gap_disc_cancel/)

> I am trying to switch between my custom rf stack  and nimble bt stack. So I need to disable nimble  operation before running my custom RF Stack.
> And once I am done what I need using the custom RF Stack, I will switch back nimble.
> 
> Another question, how do you put the MCU to deep sleep while using nimble stack? In the example the MCU does not goes to deep sleep.

Sorry, I am not sure about this one.  I am not sure this is actually
supported yet, but I'll let someone more knowledgable chime in.

Chris