When you fail to get an IP address from DHCP, it will automatically assign you a random address in the 169.254.x.x range. So if you have an IP address like this, it means you're connected to a network, and set to use DHCP to get an address, but it is unable to obtain an IP address from DHCP.
There doesn't appear to be any way to simply detect if wifi is enabled and not connected to a network, so I think you're out of luck there. The best you can do is detect if you're connected to a wifi network, but often if you're out and about, you won't be connected to a wifi network even though it is enabled.