I am stuck it seems....
Getting Advertising to go from one state to another doesn't seem to be an issue using:
//ON
en=1;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, 1, &en ); // 1=on
or
//OFF
en=0;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, 1, &en ); // 0=off
Where I am getting issues is that when I place function within SimpleBLEPeripheral_performPeriodicTask(); it leads to just allowing me to turn off the radio if when I connect it runs the clock for this task. Never on again....
So in the other state if I setup a function to be called from anywhere else .... say a task that is not waiting for a semaphore and is just sleeping and running continuously. If the uint8_t initialAdvertEnable = FALSE; this function will turn on the advertising. Yet the OFF function will not work now within the PerodicTask(); even if I just call the task once to turn on the radio it will only turn it on from a false state from the initial setup not really toggling the radio.....
//Example for turning on the Advertising after 10 seconds if the Advertising was FALSE during setup
while(1){
Task_sleep(10000);
en=1;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, 1, &en ); // 1=on }
Basically what I am getting at is for some reason when I place conditions on the advertisement in starting up == false and then I enable the advertising...
It will stay on even if I have the off statement within the PeriodicTask();
The inverse issue is that if I have the starting up advertising set too == true and I call the statement to turn off the advertising... this will happen but I can no longer turn the advertising back on....
Ideally I would like to accomplish this if possible through whatever means necessary
1) Start-off without advertising (Setting uint8_t initialAdvertEnable = FALSE; does this for me)
2) After some condition setup advertising to start (ON referenced above can do this within the SimpleBLEPeripheral.c as a function not within PeriodicTask(); due to this not being enabled yet without a connection)
3) The ability to terminate a connection and turn off advertising || just turn off advertising even if a connection has not been made... ** This is the step I am having issues with-> It seems that no matter what I do I cannot get both the ability to turn on or the ability to turn off the advertising at the same time...
Thanks in advance I will provide some more reference code if needed
Here is reference to the two previous posts that I have been using to try solve my problem with thus far:

