def showinfo(): info = "" yournum = sim800.getmynumber() if (yournum): info += yournum + "\n" yourop = sim800.currentoperator(0) if (yourop): info += "Operator : " + yourop + "\n" imei = sim800.imei() if (imei): info += "IMEI : " + imei + "\n" imsi = sim800.imsi() if (imsi): info += "IMSI : " + imsi + "\n" rssi = sim800.rssi() if (rssi): info += "RSSI : " + str(rssi) + "\n" ber = sim800.ber() if (ber): info += "BER : " + str(ber) + "\n" cellid = sim800.cellid() if (cellid): info += "Cell ID : " + cellid + "\n" yourbat = sim800.batterycharge() if (yourbat > 0): info += "Battery : " + str(yourbat) + "%\r\n" notice(info, title="TiLDA Phone")
def create_thread(): title = dialogs.prompt_text("Whats the title of the new thread?:") request = { "who": sim800.imei(), "title": title, } request_json = ujson.dumps(request) try: http.post(api_url + '/threads', json=request_json).raise_for_status().close() except: ugfx.clear() ugfx.text(5, 100, "Error. Try again later. :(", ugfx.BLACK) return False
def create_comment(thread): title = dialogs.prompt_text("Whats your comment?:") request = { "who": sim800.imei(), "comment": title, } request_json = ujson.dumps(request) try: http.post(api_url + "/threads/" + thread.threadID, json=request_json).raise_for_status().close() except: ugfx.clear() ugfx.text(5, 100, "Error. Try again later. :(", ugfx.BLACK) return False
def screen(state): if state['profile'] is None: state['profile'] = { 'unique_identifier': "", 'username': "", 'age': "", 'tag_line': "", 'looking_for': "", 'contact': "" } ds = [ ["username", "What's your name?"], ["age", "What's your age?"], ["tag_line", "Tell us your tagline"], ["looking_for", "And what you're looking for"], ["contact", "And your twitter username"], ] i = 0 while i < len(ds): res = dialogs.prompt_text(ds[i][1], init_text=state['profile'][ds[i][0]]) if res is None: i -= 1 if i < 0: state['next'] = "SPLASH" return elif res != "": state['profile'][ds[i][0]] = res i += 1 state['profile']['unique_identifier'] = sim800.imei() if not create_profile(state): state['next'] = "ERROR" return state['next'] = "NEXT_PERSON"
def create_profile(my_profile): ugfx.clear(ugfx.html_color(0x000000)) name, age = "", "" while name == "": name = dialogs.prompt_text("What's your name?") while age == "": age = dialogs.prompt_text("What's your age?") tag_line = dialogs.prompt_text("Tell us your tagline:") looking_for = dialogs.prompt_text("And what you're looking for:") contact = dialogs.prompt_text("And your twitter username?") imei = sim800.imei() top_left_logo() ugfx.text(5, 100, "Working...", ugfx.BLACK) profile = { 'unique_identifier': imei, 'username': name, 'age': age, 'tag_line': tag_line, 'looking_for': looking_for, 'contact': contact } profile_json = ujson.dumps(profile) try: http.post(api_url+'/create_user', json=profile).raise_for_status().close() except: ugfx.clear() ugfx.text(5, 100, "Error. Try again later. :(", ugfx.BLACK) return False database.set("tildr_profile", profile_json) return True