I sleep, but my heart is awake: This describes a dream well; she was asleep, but her emotions and mind were active.
My beloved is knocking: “Open to me": In the ancient Near East, opening doors symbolized sexual activity (see also Song of Solomon 8:9). The man knocking and asking to enter suggests he seeks a sexual union. He waits for permission and does not assume.