Here $(echo "$ssid" | md5sum | head -c 4)
How is the value different?
One possible reason is bigendian/littleendian byte order difference meaning 1234 vs. 3412. (Is it seen as a string or hexadecimal number where byte order depends on CPU?)
You might manually set it into a byte-symmetric value like 3737 or 6868 in all devices.