Provision a LaMetric TIME from Linux when the mobile app cannot connect.
The useful path is Wi-Fi setup mode: the clock broadcasts a temporary AP, exposes a local HTTP setup API, accepts the account binding and target Wi-Fi settings, then joins the configured network.
USB showed up as a gadget/mass-storage device, and Bluetooth was discoverable, but neither was needed for provisioning.
Moving parts:
- Linux scripts: join the setup AP, call the setup API, and restore Wi-Fi afterward.
- LaMetric cloud: turns account login into an account API key and reports device IPs.
- Clock setup AP:
172.18.17.1, accepts/api/v1/setup/*calls while in setup mode. - Target LAN: where the clock appears after successful provisioning.
- Local device API:
http://DEVICE_IP:8080orhttps://DEVICE_IP:4343. - Android APK: source for hidden setup endpoints, payload fields, and status codes.
- Login to
developer.lametric.comor provideLAMETRIC_ACCOUNT_API_KEY. - Join the clock setup AP from the configured Wi-Fi interface.
PUT /api/v1/setup/accountPUT /api/v1/setup/wifi- Poll
GET /api/v1/setup/statusuntil status2,3, or an error code. PUT /api/v1/setup/confirm- Query the cloud device list for the clock IP.
- Use the local API at
http://DEVICE_IP:8080/api/v2/deviceor HTTPS on:4343.
- Linux with NetworkManager
curl,jq,nmcli,rg,ip,python3- A working internet route while the Wi-Fi interface is temporarily connected to the clock AP
Start from the example env file:
cd ~/src/lametric-time
cp .env.example .env
chmod 600 .env
$EDITOR .env
set -a
. ./.env
set +aMinimum values:
LAMETRIC_SETUP_AP='LM1234'
LAMETRIC_WIFI_SSID='YOUR_WIFI_SSID'
LAMETRIC_WIFI_PASSWORD='YOUR_WIFI_PASSWORD'
LAMETRIC_ACCOUNT_EMAIL='you@example.com'
LAMETRIC_ACCOUNT_PASSWORD='YOUR_LAMETRIC_PASSWORD'Use command hooks if values should come from another tool:
LAMETRIC_ACCOUNT_EMAIL_CMD='your-email-command'
LAMETRIC_ACCOUNT_PASSWORD_CMD='your-password-command'
LAMETRIC_WIFI_PASSWORD_CMD='your-wifi-password-command'You can also bypass account login:
LAMETRIC_ACCOUNT_API_KEY='ACCOUNT_API_KEY'
LAMETRIC_ACCOUNT_API_KEY_CMD='your-account-api-key-command'Common optional settings:
LAMETRIC_IFACE='wlan0'
LAMETRIC_RESTORE_WIFI_CONNECTION='Your Normal Wi-Fi'
LAMETRIC_TZ='Europe/Paris'
LAMETRIC_LOCALE='en_US'With .env loaded:
./scripts/provision.shOr inline:
LAMETRIC_ACCOUNT_EMAIL_CMD='your-email-command' \
LAMETRIC_ACCOUNT_PASSWORD_CMD='your-password-command' \
LAMETRIC_WIFI_PASSWORD_CMD='your-wifi-password-command' \
./scripts/provision.sh \
--setup-ap LM1234 \
--ssid YOUR_WIFI_SSID \
--restore-wifi 'Your Normal Wi-Fi'Useful flags:
--setup-ap NAME setup AP broadcast by the clock, for example LM1234
--ssid SSID target Wi-Fi SSID
--restore-wifi NAME NetworkManager connection to restore after setup
--iface IFACE Wi-Fi interface to move onto the setup AP
--timezone TZ time zone sent to the clock
--locale LOCALE locale sent to the clock
--no-restore leave Wi-Fi as-is after the script exits
Read setup status:
./scripts/setup-status.sh --connect --setup-ap LM1234Scan Wi-Fi networks visible to the clock:
./scripts/wifi-list.sh --connect --setup-ap LM1234Read local device info after registration:
./scripts/device-info.sh --serial DEVICE_SERIALIf you already know the clock IP:
./scripts/device-info.sh --ip DEVICE_IPIf you already have the device API key:
LAMETRIC_DEVICE_API_KEY='DEVICE_API_KEY' ./scripts/device-info.sh --ip DEVICE_IPCloud login email/password -> account API key
Setup API Basic user:<account API key>
Cloud device list Basic user:<account API key>
Local device API Basic dev:<device API key>
Setup API base:
http://172.18.17.1/api/v1
Provisioning endpoints:
PUT /setup/account
PUT /setup/wifi
GET /setup/status
PUT /setup/confirmOther useful setup endpoints:
POST /setup/ping
PUT /setup/cancel
GET /wifi
GET /wifi/listThe account endpoint is /setup/account, not /setup/user.
Local device API bases observed:
http://DEVICE_IP:8080
https://DEVICE_IP:4343
0 not connecting
1 connecting
2 connected
3 registered
10 invalid Wi-Fi credentials
11 failed to obtain IP
12 unknown Wi-Fi error
20 no internet
30 server error
31 auth server error
32 SSL error
The APK was useful because the public docs do not describe the setup AP API. Inspecting it gave us the endpoint names, request payload fields, auth behavior, and status meanings used by the mobile app.
APK inspected:
LaMetric-Time-2.10.4-com.smartatoms.lametric.apk
SHA256: 0f11dd80c1c8fe0b1e97646530e58429d7feee1d12d8242320945604d8810679
Source: https://lametric-time.en.aptoide.com/app
Relevant classes:
Lcom/smartatoms/lametric/client/LaMetric$i; setup client
Lcom/smartatoms/lametric/client/LaMetricWeb$Device; cloud device client
Lcom/smartatoms/lametric/client/c; Basic auth helper
Lcom/smartatoms/lametric/model/device/DeviceInfoWifi; Wi-Fi payload model
Lcom/smartatoms/lametric/model/device/DeviceAccount; setup account payload model
Lcom/smartatoms/lametric/model/device/SetupStatus; setup status model
Useful findings:
- setup account endpoint:
/api/v1/setup/account - setup Wi-Fi endpoint:
/api/v1/setup/wifi - setup status endpoint:
/api/v1/setup/status - setup confirm endpoint:
/api/v1/setup/confirm - setup auth:
user:<account API key> - local API auth:
dev:<device API key> - Wi-Fi payload fields:
mode,essid,hidden,encryption,password - account payload fields:
api_key,time,locale,time_zone_id,time_zone_offset - status code meanings listed above
- correction:
/setup/account, not/setup/user
Inspect DEX:
python3 tools/dex_scan.py extracted/classes3.dex --pattern 'setup|wifi|api/v1'
python3 tools/dex_fields.py extracted/classes3.dex 'Lcom/smartatoms/lametric/model/device/SetupStatus;'
python3 tools/dex_dump_method.py extracted/classes3.dex 'Lcom/smartatoms/lametric/client/LaMetric$i;' '*'