Also the argument about defending intellectual property doesn't make sense: the software will probably do trivial things and be very simple, that is what you are selling is the hardware itself, and that is already covered by patents.
So making the code public will allow people to find a replacement in the eventuality that the manufacturer stops supporting the product.
This should be imposed by the governments, in my opinion, also for another reason: when the company that makes the hardware device stops supporting it, in countries with a public healthcare system it's the state itself that has to support the patient. How can the healthcare system provide assistance to something that doesn't know internally how it works? How can it go to another company to ask to fix the device?