Hello,
Sorry for the inconveniences this might cause you, but the libraries can't be shared, also I believe the way you are implementing the changes might be intrusive to the framework as you are not following the recommendations in the documentation we provide.
Why aren't you using the PWR_ChangeDeepSleepMode API? And, are you using the PWR_AllowDeviceToSleep? I did not see any of those in your code, have you added those? If you did, how are you using them? Is your issue during the IDLE state? Is it in the advertisement? Or is in the connection?
Have you tried using our recommended APIs and process?
Regards,
Estephania