How to use the hologram.port function in hologram

To help you get started, we’ve selected a few hologram examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HologramEducation / AT-Workshop / workshop / final-code / main.py View on Github external
def sendMessage(message):
    # format message string
    fullMessage = formatMsg(message, DEVICEKEY)

    # C8 - Start hologram TCP connection
    if not sendCommand("AT+CIPSTART=1,\"TCP\",\"" + ip() + "\",\"" + port() + "\"\r\n", 75, "OK", "FAIL"):
        return False

    # C9 - Set message length
    msgLength = len(fullMessage)
    if not sendCommand("AT+CIPSEND=1," + str(msgLength) + "\r\n", 5, ">"):
        return False

    # C10 - Send string to server
    if not sendCommand(fullMessage, 60, "OK", "FAIL"):
        return False

    return True