Well, you are not including the halSleep.c or whatever it is called in your project by the looks of it, you need to add that file.
Well, normal HAL_Sleep(2000) will sleep for 2 seconds, then wake up and send the data, then go back to sleep. This is EXACTLY what WSNDemo does. Why not start with that application?