credentials = { 'devicekey': '^hD8&#%H' } # replace with your unique Sim device key cloud = HologramCloud(credentials, network='cellular', authentication_type='csrpsk') clave = randomString(5) mensaje_instruccion = "Bienvenido al programa de seguridad. Para activar el programa, envie primero la clave aleatoria. Su clave es: " + str( clave) print mensaje_instruccion recv = cloud.sendSMS("+14439044822", mensaje_instruccion) while True: sms_obj = cloud.popReceivedSMS() if sms_obj == None: print 'U' else: if sms_obj.message == clave: print "Great!" recv = cloud.sendSMS( "+14439044822", "Sistema de seguridad: ACTIVADO\n Para desactivar el programa, envie D. Para activar el programa, envie A." ) break else: print "Fail" recv = cloud.sendSMS("+14439044822", "Clave Incorrecta") sleep(2)
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 command = recvCommand.message hg.sendSMS(phonehome, 'On it Boss! please be patient...') time.sleep(3) commandResult = ProcessCommand(command) smsSend = hg.sendSMS(phonehome, commandResult.replace('\n', ' ')[:155]) print hg.getResultString(smsSend) time.sleep(10)
#hologram.sendMessage(json.dumps("Please take necesary action, your home is at risk")) print "Please take necesary action, your home is at risk" reply = hologram.sendSMS(phone, "Please take necesary action, your home is at risk") break elif message: #hologram.sendMessage(json.dumps("Please enter a valid response. (ok or ignore)")) print "Please enter a valid response. (ok or ignore)" hologram.sendSMS(phone, "Please enter a valid response. (ok or ignore)") count = 0 elif count >= 30: #hologram.sendMessage(json.dumps("No response recieved within 30 minutes, Alert Ignored. Reverting to standby mode.")) print "No response recieved within 30 seconds, Alert Ignored. Reverting to standby mode." reply = hologram.sendSMS(phone, "No response recieved within 30 seconds, Alert Ignored. Reverting to standby mode.") break count += 1 time.sleep(1) #Hologram waits for user input (standby mode) while True: sms_obj = hologram.popReceivedSMS() if sms_obj is not None: #If user sends something: message = sms_obj.message phone = "+" + sms_obj.sender if message.lower() in "status update": #If user enters keyword update() time.sleep(1) hologram.network.disconnect()
sendSMS("Currently I'm thinking about " + str(numProcesses) + " things right now. I'm a genius!") elif "body" in sms.message: # If I'm asked anything about my body sendSMS("Sniffle :( I do not have a body, will you make one for me?") else: # default answer if I have no idea what was asked sendSMS("Sorry, I do not have an answer for that question.") # Connect to the Hologram Global Network hologram.network.connect() try: print "Listening for incoming SMS..." while True: # Start listening for incoming SMS questions hologram.enableSMS() time.sleep(5) hologram.disableSMS() # check if we recieved a new question sms = hologram.popReceivedSMS() if sms is not None: print "GOT MESSAGE" print sms answerQuestion(sms) # try to answer the question and send a response finally: print "Closing cell connection" hologram.network.disconnect()
LED_STATE = True return True try: while True: ## Button pressed if GPIO.input(BTN_PIN) == False: ## toggle LED result = toggleLed(LED_PIN) ## send event message to the cloud hologram.sendMessage("light turned " + result, [TOPIC]) ## Check inbound SMS messages recv = hologram.popReceivedSMS() if recv is True: if recv == 'on': ledOn(LED_PIN) elif recv == 'off': ledOff(LED_PIN) elif recv == 'blink': blink(LED_PIN) finally: hologram.disableSMS() GPIO.output(LED_PIN,False) ## Switch off LED GPIO.cleanup() ## reset all pins
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()