Hi Albert,
1. The code for the control of the switches is located inside the wireless_uart.c file.
a) When you switch to GAP Peripheral (by pressing SW2) you define the variable mGapRole to "gGapPeripheral_c" at the funciton called "BleApp_HandleKeys":
case gKBD_EventPressPB2_c:
{
if( mGapRole == gGapCentral_c )
{
Serial_Print(gAppSerMgrIf, "\n\rSwitched role to GAP Peripheral.\n\r", gAllowToBlock_d);
mAppUartNewLine = TRUE;
mGapRole = gGapPeripheral_c;
}
.
.
.
}
b) After switching to Peripheral, you start advertising by pressing SW1 and the case redirects you to the "BleApp_Start" function, where you wait for the connection:
case gGapPeripheral_c:
{
Serial_Print(gAppSerMgrIf, "\n\rAdvertising...\n\r", gAllowToBlock_d);
mAppUartNewLine = TRUE;
gPairingParameters.localIoCapabilities = gIoDisplayOnly_c;
BleApp_Advertise();
break;
}
2. Regarding your problem with the connections, the issue is caused by the fact that the iPhone looses connection while the board still thinks that there is one. This problem is caused by the phone and not by the board; in order to fix this you would have to develop a new app which would allow the iPhone to reconnect properly.
3. I'm not sure if you are allowed to use the IoT Toolbox for your customers; I'm still checking if you are able to do it (I will let you know as soon as I get any information). However, I do not recommend using it in that way due to the fact that the app is only for testing, and does not have the support for a commercial use.
I hope this information can help you.
Best Regards,
Ricardo Delsordo