コード例 #1
0
    def test_invalid_sms_length(self):

        hologram = HologramCloud(credentials, enable_inbound = False)

        temp = '111111111234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'
        with pytest.raises(Exception, message = 'SMS cannot be more than 160 characters long!'):
            hologram.sendSMS('+1234567890', temp)
コード例 #2
0
class HologramAPI:
    def __init__(self):
        self.client = HologramCloud(dict(),
                                    network='cellular',
                                    authentication_type='csrpsk')

    def send_sms(self, to_num, msg):
        try:
            response = self.client.sendSMS(to_num, msg)
            print(response)
        except:
            print(
                "FAIL: Unable to send SMS via Hologram. (Modem disconnected?)")
コード例 #3
0
ファイル: prueba.py プロジェクト: clementearraez/sensors
    letters = string.ascii_lowercase
    return ''.join(random.choice(letters) for i in range(stringLength))


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"
コード例 #4
0
sys.path.append(".")
sys.path.append("..")
sys.path.append("../..")

from Hologram.HologramCloud import HologramCloud

if __name__ == "__main__":
    print ""
    print ""
    print "Testing Hologram Cloud class..."
    print ""
    print "* Note: You can obtain device keys from the Devices page"
    print "* at https://dashboard.hologram.io"
    print ""

    device_key = raw_input("What is your device key? ")
    destination_number = raw_input("What is your destination number? ")

    credentials = {'devicekey': device_key}
    hologram = HologramCloud(credentials, enable_inbound=False)

    print ''
    recv = hologram.sendSMS(destination_number,
                            "Hello, Python!")  # Send SMS to destination number
    print "RESPONSE CODE RECEIVED: " + str(recv)

    print ''
    print 'Testing complete.'
    print ''
コード例 #5
0
from Hologram.HologramCloud import HologramCloud

credentials = {'devicekey': '^hD8&#%H'}

if __name__ == "__main__":
    print ""
    print ""
    print "Testing Hologram Cloud class..."
    print ""
    print "* Note: You can obtain device keys from the Devices page"
    print "* at https://dashboard.hologram.io"
    print ""

    hologram = HologramCloud(credentials,
                             network='cellular',
                             authentication_type='csrpsk'
                             )  #HologramCloud(dict(), network='cellular')

    print 'Cloud type: ' + str(hologram)
    startMsg = hologram.sendSMS(
        "+34693608737",
        "Hello!! If you know Clemente, send him a Whatsapp! ;)")
    # enter your mobile number in the space above, area code required
    #sleep(60) # lets allow a little time for the cellular interface to restart
    print 'RESPONSE MESSAGE: ' + hologram.getResultString(startMsg)
    #recv = hologram.sendMessage('one two three!',
    #                           topics = ['TOPIC1','TOPIC2'],
    #                          timeout = 3)

    #print 'RESPONSE MESSAGE: ' + hologram.getResultString(recv)
コード例 #6
0

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
                command = recvCommand.message

                hg.sendSMS(phonehome, 'On it Boss! please be patient...')
コード例 #7
0
try:

    #  if not cloud.network.is_connected():
    #    result = cloud.network.connect()
    #    if result == False:
    #      print 'Failed to connect to cell network'
    #    else:
    #      print 'Connected to cell network'
    #response= 'Bienvenido al programa de seguridad. El sistema esta activado por defecto\n'
    #recv = cloud.sendMessage(response, topics = ['TRIGGER_SEGURIDAD'], timeout = 3)
    #print cloud.getResultString(recv)
    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)

    dueno.activar_sistema(cloud)

    while True:
        sms = dueno.a_d_sms(cloud)
        #print sms
        if sms == 'D':
            activo = 'D'
            alerta = False
            ciclo = 2
            gpio.output(13, False)
            response = 'Sistema de seguridad desactivado'
            recv = cloud.sendMessage(response,
                                     topics=['TRIGGER_DESACTIVAR'],
                                     timeout=3)
コード例 #8
0
#!/usr/bin/python

from Hologram.HologramCloud import HologramCloud
import PrivateData

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

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

print 'Starting Pentest Bot v1.0! ...\nMessaging mothership'

smsSend = hg.sendSMS(phonehome, "Pentest Bot v1.0 reporting on Duty!")

print hg.getResultString(smsSend)
コード例 #9
0
#

import sys

sys.path.append(".")
sys.path.append("..")
sys.path.append("../..")

from Hologram.HologramCloud import HologramCloud

if __name__ == "__main__":
    print("")
    print("")
    print("Testing Hologram Cloud class...")
    print("")
    print("* Note: You can obtain device keys from the Devices page")
    print("* at https://dashboard.hologram.io")
    print("")

    device_key = input("What is your device key? ")
    destination_number = input("What is your destination number? ")

    credentials = {'devicekey': device_key}

    hologram = HologramCloud(credentials,
                             network='cellular',
                             authentication_type='csrpsk')

    recv = hologram.sendSMS(destination_number, 'Hi, SMS!')

    print('RESPONSE MESSAGE: ' + hologram.getResultString(recv))
コード例 #10
0
def alarm(pin,value):
	current_date = datetime.datetime.now()
	credentials = {'devicekey': 'LMaCQ?]G'}
	hologram = HologramCloud(credentials, network='cellular', authentication_type='csrpsk')


	if int(value[0]) == 1:
		blynk.virtual_write(13, current_date.strftime("%Y-%m-%d %H:%M:%S"))

		### gather/write GPS vehicle data ###
		gps_data = gather_gps_data()
		vehicle_lat = gps_data[0]
		vehicle_lon = gps_data[1]
		vehicle_alt = gps_data[2]
		blynk.virtual_write(25, round(vehicle_lat,5))
		blynk.virtual_write(26, round(vehicle_lon,5))
		blynk.virtual_write(35, vehicle_alt)

		### send activation SMS ###
		recv = hologram.sendSMS('+12069725002', 'AutoMOC Alarm Enabled. System has confirmed network connectivity')
		print('RESPONSE MESSAGE: ' + hologram.getResultString(recv))
		print ('Sending text')

		### geofence alarm ###
		vehicle_location = (vehicle_lat, vehicle_lon)
		print (vehicle_location)
		time.sleep(5)
		while True:
			print('Checking Alarm Status and Geofence alarm')
			if int(value[0]) == 1:
				alarm_gps_data = gather_gps_data()
				alarm_lat = alarm_gps_data[0]
				alarm_lon = alarm_gps_data[1]
				current_location = (alarm_lat, alarm_lon)
				print (current_location)
				displacement = distance.distance(vehicle_location, current_location).km
				print (displacement)
				alarm_trigger = 30

				### trigger alarm ###
				if int(value[0]) ==1  and displacement > alarm_trigger:

					print('Geofence Alarm TRIPPED')
					alarm_recv = hologram.sendSMS('+12069725002', 'AutoMOC Geofence Alarm TRIPPED. Go to InitialState.com for real-time tracking updates.')
					print('RESPONSE MESSAGE: ' + hologram.getResultString(alarm_recv))
					streamer = Streamer(bucket_name="GPS_Tracker", bucket_key="GPS_Tracker", access_key="ist_xWKrfgU6MntKcQukAg0ohqZ0Dh7FFQYb")

					while True:
						print ('Streaming data to InitialState.com')
						print ( 'CPU time->' + datetime.now().time())
						streamer.log("Location", "{lat},{lon}".format(lat=gather_gps_data()[0],lon=gather_gps_data()[1]))
						streamer.log("speed",gather_gps_data()[3])
						time.sleep(10)
					continue
				### alarm not triggered but armed ###
				elif int(value[0]) == 1 and displacement < alarm_trigger:
					print('Alarm not tripped, continuing period checks')
					time.sleep(5)
					continue

				### alarm toggled off ###
				elif int(value[0]) == 0:
					print('Alarm toggled off-1')
					break
				continue

				time.sleep(5)
			else:
				break


	else:
		print('Alarm toggled off')
コード例 #11
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()