Adaptive and smart software solution to improve battery packs efficiency, safety, performance and life