Пример #1
0
def main_iteration():
    global led
    global sms_requested

    led.value(1)
    machine.watchdog_reset()

    try:
        if sms_requested is not None:
            send_coords_by_sms(sms_requested)
            sms_requested = None

        gprs.wait_gprs()
        machine.set_min_freq(machine.PM_SYS_FREQ_39M)
        send_rtt_coordinates()
    except Exception as err:
        print("OS error: {0}".format(err))
        try:
            admins = get_property("admin_numbers")

            if len(admins) > 0:
                cellular.SMS(admins[0], "OS error: {0}".format(err)).send(0)

        except Exception as e:
            pass
    finally:
        machine.watchdog_reset()
        led.value(0)
Пример #2
0
def send_coords_by_sms(number):
    try:
        print("Sending coords")
        coords = location.get_coordinates()
        text = get_property('sms_template').format(lat=coords[0],
                                                   lng=coords[1])
        print("Sending " + text)
        cellular.SMS(number, text).send(0)
    except Exception as err:
        pass
Пример #3
0
def sms_handler(sms):
    cellular.on_new_sms(sms_handler)
    msg = sms.message

    if usb_connected():
        s.writeRegister("sms effect")

    print("sms_handler")
    result = run_cmd(sms.phone_number, [word.lower() for word in msg.split()])

    remove_all_sms()
    if result is not None:
        cellular.SMS(sms.phone_number, result).send(0)
Пример #4
0
# Micropython a9g example
# Source: https://github.com/pulkin/micropython
# Author: pulkin
# Demonstrates how to send and receive SMS
import cellular
import time

global flag
flag = 1

def sms_handler(evt):
    global flag
    if evt == cellular.SMS_SENT:
        print("SMS sent")

    elif evt == cellular.SMS_RECEIVED:
        print("SMS received, attempting to read ...")
        ls = cellular.SMS.list()
        print(ls[-1])
        flag = 0

cellular.on_sms(sms_handler)
cellular.SMS("8800", "asd").send()

print("Doing something important ...")
while flag:
    time.sleep(1)

print("Done!")

Пример #5
0
    print("----------------")
    print("SMS")
    print("----------------")

    sms_received = cel.SMS.poll()
    print("SMS received count:", sms_received)

    sms_list = cel.SMS.list()
    print("SMS:", sms_list)
    assert len(sms_list) > 0
    for i in sms_list:
        assert isinstance(i, cel.SMS)

    if test_send_sms is not None:
        sms = cel.SMS(test_send_sms, "hello")
        sms.send()

    if test_gprs:
        print("----------------")
        print("GPRS")
        print("----------------")

        print("Waiting 5 secs ...")
        time.sleep(5)

        # LEBARA NL credentials
        assert cel.gprs("internet", "", "")

        cb = cel.network_status_changed()
        print("Status changed:", cb, "->", cel.get_network_status())
Пример #6
0
import cellular
import machine
import time

# Built-in blue LED on the pudding board
cellular.on()
led = machine.Pin(27, machine.Pin.OUT, 1)
time.sleep(1)
led.value(0)

cellular.SMS('+79169542241', "System started").send()