I was able to achieve non-connectable advertisements while in connection in hello_sensor by patching some mybeacon code into the connection_up function. Take a close look at mybeacon to really understand what's going on and you should be able to easily apply it to your code.
To get it to work, I went into the connection_up function, removed "bleprofile_Discoverable(NO_DISCOVERABLE, NULL);" and patched it with:
HCIULP_ADV_NONCONNECTABLE_EVENT, // non-connectable undirected advertisement
160, // adv interval 100 msec
HCIULP_ADV_CHANNEL_MAP_MASK, // all channels
HCIULP_PUBLIC_ADDRESS, // int advAdrType,
HCIULP_ADV_FILTER_POLICY_WHITE_LIST_NOT_USED, // int advFilterPolicy,
HCIULP_PUBLIC_ADDRESS, // int initiatorAdrType,
NULL); // UINT8* initiatorAdr
While defining at the top:
#define HCIULP_ADV_NONCONNECTABLE_EVENT 0x03
#define HCIULP_ADV_CHANNEL_37 0x01
#define HCIULP_ADV_CHANNEL_38 0x02
#define HCIULP_ADV_CHANNEL_39 0x04
#define HCIULP_ADV_CHANNEL_MAP_MASK (HCIULP_ADV_CHANNEL_37 | HCIULP_ADV_CHANNEL_38 | HCIULP_ADV_CHANNEL_39)
#define HCIULP_PUBLIC_ADDRESS 0x00
#define HCIULP_ADV_FILTER_POLICY_WHITE_LIST_NOT_USED 0x00 // white list not used
Yes, this works, thanks!
There is a post regarding the use of the blecm_startAdv() function:
In this post, ArvindS_76 says something about not using blecm_startAdv with the bleprofile_Discoverable(), and it left me confused enough to not try it:
" The other thing to keep in mind is that bleprofile_Discoverable() uses this in its state machine. So if you use blecm_startAdv(), don't use bleprofile_Discoverable() ."
However, in my code, and I suspect in your modified hello_sensor too, both these functions are being used in different places. So I'm not sure what is meant by the comment above. I wonder if I should just use blecm_startAdv() exclusively in my code to prevent any odd behavior later?
I will be great if someone in the know can clarify the dependencies between the blecm_* functions and the bleprofile_* functions. It will be good to document this API properly.
Anyway, thanks again!