Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

37
LINES

< > BotCompany Repo | #1004082 // Show phone's battery level on PC

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (3856L/27K/88K).

!752

p {
  showBigText("Battery Level", "getLevelLogged", 5000);
  //hideConsole();
}

static S ip, level, answer;

static S[] getLevelLogged() {
  S[] s = getLevel();
  logQuoted("phone-log.txt", "[" + chatTime() + "] Gateway: " + ip + " " + (empty(level)
    ? "Phone not reactive [" + answer + "]"
    : "Phone reactive. Battery level: " + level + " %!"));
  ret s;
}

static S[] getLevel() {
  ip = gateway();
  if (empty(ip))
    ret new S[] { "?", "No gateway found" };
    
  try {
    answer = sendToPublicCommBot(ip, forward("Battery Bot", "battery level"));
  } catch e {
    answer = exceptionToStringShort(e);
  }
  L<S> tok = javaTok(answer);
  int i = jfind(tok, "<int>%");
  if (i == 1) {
    level = tok.get(1);
    ret new S[] { level + " pc", level + "% Phone Battery"};
  } else {
    level = null;
    ret new S[] { "?", "Unknown Phone Battery Level"};
  }
}

Author comment

Began life as a copy of #1001789

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004082
Snippet name: Show phone's battery level on PC
Eternal ID of this version: #1004082/1
Text MD5: a14e660296a13c6d8541e602cc2c7c05
Transpilation MD5: 9cb999152ae9cd1b3ed4e22d662523a6
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-18 15:19:05
Source code size: 917 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 569 / 1108
Referenced in: #1004089 - Show Both Battery Levels (PC + Phone). Start #1004078 on phone first!