Example #1
0
def run_hologram_receive_sms(args):

    global hologram
    hologram = HologramCloud(None,
                             enable_inbound=False,
                             network='cellular-iota')

    hologram.event.subscribe('sms.received', popReceivedSMS)
    hologram.enableSMS()

    handle_timeout(args['timeout'])

    hologram.disableSMS()
Example #2
0
from json import loads, dumps
from base64 import b64decode

import paho.mqtt.client as mqtt

from rsa import verify
from config import get_config
from time import sleep
from key_tools import get_pub_key

cfg = get_config()

credentials = {'devicekey': cfg['nova-device-key']}

hologram = HologramCloud(credentials, network='cellular')
hologram.enableSMS()

public_key = get_pub_key()

if not public_key:
    print('Unable to load public key')
    exit(1)


def handle_message():

    sms_obj = hologram.popReceivedSMS()

    if sms_obj:
        try:
            m = loads(sms_obj.message)
Example #3
0
            raise

        return result


credentials = PrivateData.settings['credentials']
phonehome = PrivateData.settings['mothership']

while 1:

    try:

        hg = HologramCloud(credentials,
                           network='cellular',
                           authentication_type='csrpsk')
        hg.enableSMS()

        print 'Starting Pentest Bot v1.0! ...\nMessaging mothership'
        smsSend = hg.sendSMS(phonehome, "Pentest Bot v1.0 reporting on Duty!")
        print hg.getResultString(smsSend)

        # Let us wait for command to act on

        print "Waiting for Mothership's message ..."

        while 1:
            recvCommand = hg.popReceivedSMS()

            command = ''
            if recvCommand is not None:
                print recvCommand
Example #4
0

credentials = {"devicekey":"xxxxxxxxx"} #Replace with your unique SIM device key
#Instantiating a hologram instance
hologram = HologramCloud(credentials, network='cellular', authentication_type="csrpsk")

result = hologram.network.connect()
print 'CONNECTION STATUS: ' + str(hologram.network.getConnectionStatus())

if result == False:
    print ' Failed to connect to cell network'
else:
    print "Connection successful!"
    print "Hologram online!"
    #Enables Hologram to listen for incoming SMS messages
    recv = hologram.enableSMS()

def update():
    #Log temperature
    humidity, temperature = Adafruit_DHT.read_retry(sensor, dhtpin)
    temperature = float('{0:0.1f}'.format(temperature))

    #Determine if stove is on or off
    if temperature <= mintemp:
        #hologram.sendMessage(json.dumps("Your stove is off." + "Temperature: " + temperature + "C"))
        print "Your stove is off. " + "Temperature: " + str(temperature) + "C"
        reply = hologram.sendSMS(phone, "Your stove is off. " + "Temperature: " + str(temperature) + "C")

    else:
        #hologram.sendMessage(json.dumps("Your stove is on. Your home is at risk, Call authorities " + "Temperature: " + temperature + "C"))
        print "Your stove is on. Your home is at risk, Call authorities " + "Temperature: " + str(temperature) + "C"
Example #5
0
class HologramDemo(object):
    def __init__(self):
        credsfile = os.path.dirname(os.path.realpath(__file__)) +\
            '/credentials.json'
        #credfile = '/home/pi/demo-touchscreen/credentials.json'
        with open(credsfile, 'r') as f:
            self.credentials = json.load(f)
            self.init_hologram()

    def init_hologram(self):
        self.hologram = HologramCloud(self.credentials,
                                      network='cellular',
                                      authentication_type='csrpsk')
        self.hologram.enableSMS()

    # FUNCTIONS
    def convert_location_into_json(location_obj):
        location_list = [
            'date', 'time', 'latitude', 'longitude', 'altitude', 'uncertainty'
        ]
        response_list = [
            location_obj.date, location_obj.time, location_obj.latitude,
            location_obj.longitude, location_obj.altitude,
            location_obj.uncertainty
        ]
        location_data = dict(zip(location_list, response_list))
        return json.dumps(location_data)

    def run_modem_location(self):
        location_obj = hologram.network.location
        if location_obj is None:
            return 'NA'
        else:
            return convert_location_into_json(location_obj)

    def checkForSMS(self):
        sms_obj = self.hologram.popReceivedSMS()

        if sms_obj is not None:
            print u"Got SMS: ", sms_obj.message

    def start(self):
        print 'PYTHON STARTED'

    def sendData(self):
        print('Sending data to cloud')
        self.hologram.network.connect()
        self.hologram.sendMessage('Hello Nova')
        self.hologram.network.disconnect()
        print('Done')

    def sendSMS(self, destination_number):
        print('Sending SMS to %s' % destination_number)
        self.hologram.network.connect()
        self.hologram.sendSMS(destination_number, "Hello Nova")
        self.hologram.network.disconnect()
        print('Done')

    def sendSensor(self):
        print 'PYTHON SENSOR'
        ##hologram.disableSMS()
        exit()

    def demoLoop(self):
        print("Starting Demo")
        try:
            while True:
                rd, wr, er = select.select([sys.stdin], [], [], 5)
                if rd:
                    line = sys.stdin.readline()
                    if line == "sendData\n":
                        self.sendData()
                    elif line == "sendSMS\n":
                        secondLine = sys.stdin.readline()
                        print secondLine
                        self.sendSMS(secondLine.rstrip())
                    elif line == "sendSensor\n":
                        self.sendSensor()
                    else:
                        print 'dunno'
                self.checkForSMS()
        except Exception:
            print(traceback.format_exc())
            self.hologram.network.disconnect()
Example #6
0
    returnlist = []
    with open(filename) as f:
        returnlist = f.readlines()
    return returnlist


print("Getting API key...")
key = ""
with open("key.json") as f:
    raw = loads(f.read())
    key = raw["key"]

creds = {'devicekey': key}

print("Logging into Hologram Cloud Network....")
cloud = HologramCloud(creds, network='cellular')

cloud.enableSMS()

while True:
    sms = cloud.popRecievedSMS()
    print("Waiting for SMS message...")
    while sms == None:
        pass
    print("Message {} from {}".format(sms.message, sms.sender))
    if sms.sender + "\n" in getNumbers():
        if "garage" in sms.message.lower():
            requests.get("http://localhost:55555/garageDoor/toggleGarage")
        elif "lamp" in sms.message.lower():
            requests.get("http://localhost:55555/chandlerLamp/lampSwitch")