How to get either a substring or a text value using awk and if?

I can’t figure out how to write a simple ping log. I only need either the ms value or the words “no connection”.

I have myping=$(ping -c 1 10.0.10.1). I only need the value between “time=” and “ ms“, like 3.151 from “time=3.151 ms“.

I could use awk, but then I get a lot of blank lines and I don’t know how to get rid of them:

$ awk -F 'time=| ms' '{print $2}' <<< "$myping"

3.151

And then, how can I insert “no connection”, when the ping result doesn’t contain a ms value?

Thanks a lot!