Is your Core connected to the WIFI ?
By this I mean do you have the SSID and password blocks in your code?
I cant tell from this snippet what your code is doing and need to see the full code in order to help.