add setlat/setlon support for

https://github.com/meshtastic/Meshtastic-device/issues/536

meshtastic --setlat 32.7767 --setlon -96.7970 --setalt 1337
This commit is contained in:
Kevin Hester
2020-12-09 11:43:06 +08:00
parent 3645cff97e
commit 9e25fbc670
6 changed files with 84 additions and 42 deletions

View File

@@ -13,6 +13,8 @@ echo setting time
bin/run.sh --settime
echo setting owner
bin/run.sh --setowner "Test Build"
echo setting position
bin/run.sh --setlat 32.7767 --setlon -96.7970 --setalt 1337
echo dumping info
bin/run.sh --info
echo sending closing message

View File

@@ -128,11 +128,33 @@ def onConnected(interface):
print("Connected to radio")
closeNow = False # Should we drop the connection after we finish?
try:
if args.settime:
prefs = interface.radioConfig.preferences
if args.settime or args.setlat or args.setlon or args.setalt:
closeNow = True
print("Setting device RTC time")
alt = 0
lat = 0.0
lon = 0.0
time = 0
if args.settime:
time = int(args.settime)
if args.setalt:
alt = int(args.setalt)
prefs.fixed_position = True
print(f"Fixing altitude at {alt} meters")
if args.setlat:
lat = float(args.setlat)
prefs.fixed_position = True
print(f"Fixing latitude at {lat} degrees")
if args.setlon:
lon = float(args.setlon)
prefs.fixed_position = True
print(f"Fixing longitude at {lon} degrees")
print("Setting device time/position")
# can include lat/long/alt etc: latitude = 37.5, longitude = -122.1
interface.sendPosition()
interface.sendPosition(lat, lon, alt, time)
if args.setowner:
closeNow = True
@@ -187,11 +209,11 @@ def onConnected(interface):
# Handle the int/float/bool arguments
for pref in (args.set or []):
setPref(
interface.radioConfig.preferences, pref[0], fromStr(pref[1]))
prefs, pref[0], fromStr(pref[1]))
# Handle the string arguments
for pref in (args.setstr or []):
setPref(interface.radioConfig.preferences, pref[0], pref[1])
setPref(prefs, pref[0], pref[1])
# Handle the channel settings
for pref in (args.setchan or []):
@@ -298,6 +320,15 @@ def main():
parser.add_argument(
"--settime", help="Set the real time clock on the device", action="store_true")
parser.add_argument(
"--setalt", help="Set device altitude (allows use without GPS)")
parser.add_argument(
"--setlat", help="Set device latitude (allows use without GPS)")
parser.add_argument(
"--setlon", help="Set device longitude (allows use without GPS)")
parser.add_argument("--debug", help="Show API library debug log messages",
action="store_true")
@@ -327,7 +358,7 @@ def main():
args.destOrAll = "^all"
if not args.seriallog:
if args.info or args.set or args.seturl or args.setowner or args.settime or args.setstr or args.setchan or args.sendtext or args.router != None or args.qr:
if args.info or args.set or args.seturl or args.setowner or args.setlat or args.setlon or args.settime or args.setstr or args.setchan or args.sendtext or args.router != None or args.qr:
args.seriallog = "none" # assume no debug output in this case
else:
args.seriallog = "stdout" # default to stdout

View File

File diff suppressed because one or more lines are too long

View File

@@ -18,9 +18,9 @@ DESCRIPTOR = _descriptor.FileDescriptor(
name='portnums.proto',
package='',
syntax='proto3',
serialized_options=None,
serialized_options=b'\n\023com.geeksville.meshB\010PortnumsH\003',
create_key=_descriptor._internal_create_key,
serialized_pb=b'\n\x0eportnums.proto*\x93\x01\n\x07PortNum\x12\x0f\n\x0bUNKNOWN_APP\x10\x00\x12\x14\n\x10TEXT_MESSAGE_APP\x10\x01\x12\x17\n\x13REMOTE_HARDWARE_APP\x10\x02\x12\x10\n\x0cPOSITION_APP\x10\x03\x12\x10\n\x0cNODEINFO_APP\x10\x04\x12\x10\n\x0bPRIVATE_APP\x10\x80\x02\x12\x12\n\rIP_TUNNEL_APP\x10\x80\x08\x62\x06proto3'
serialized_pb=b'\n\x0eportnums.proto*\x93\x01\n\x07PortNum\x12\x0f\n\x0bUNKNOWN_APP\x10\x00\x12\x14\n\x10TEXT_MESSAGE_APP\x10\x01\x12\x17\n\x13REMOTE_HARDWARE_APP\x10\x02\x12\x10\n\x0cPOSITION_APP\x10\x03\x12\x10\n\x0cNODEINFO_APP\x10\x04\x12\x10\n\x0bPRIVATE_APP\x10\x80\x02\x12\x12\n\rIP_TUNNEL_APP\x10\x80\x08\x42!\n\x13\x63om.geeksville.meshB\x08PortnumsH\x03\x62\x06proto3'
)
_PORTNUM = _descriptor.EnumDescriptor(
@@ -87,4 +87,5 @@ DESCRIPTOR.enum_types_by_name['PortNum'] = _PORTNUM
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
DESCRIPTOR._options = None
# @@protoc_insertion_point(module_scope)

View File

@@ -17,9 +17,9 @@ DESCRIPTOR = _descriptor.FileDescriptor(
name='remote_hardware.proto',
package='',
syntax='proto3',
serialized_options=None,
serialized_options=b'\n\023com.geeksville.meshB\016RemoteHardwareH\003',
create_key=_descriptor._internal_create_key,
serialized_pb=b'\n\x15remote_hardware.proto\"\xca\x01\n\x0fHardwareMessage\x12\"\n\x03typ\x18\x01 \x01(\x0e\x32\x15.HardwareMessage.Type\x12\x11\n\tgpio_mask\x18\x02 \x01(\x04\x12\x12\n\ngpio_value\x18\x03 \x01(\x04\"l\n\x04Type\x12\t\n\x05UNSET\x10\x00\x12\x0f\n\x0bWRITE_GPIOS\x10\x01\x12\x0f\n\x0bWATCH_GPIOS\x10\x02\x12\x11\n\rGPIOS_CHANGED\x10\x03\x12\x0e\n\nREAD_GPIOS\x10\x04\x12\x14\n\x10READ_GPIOS_REPLY\x10\x05\x62\x06proto3'
serialized_pb=b'\n\x15remote_hardware.proto\"\xca\x01\n\x0fHardwareMessage\x12\"\n\x03typ\x18\x01 \x01(\x0e\x32\x15.HardwareMessage.Type\x12\x11\n\tgpio_mask\x18\x02 \x01(\x04\x12\x12\n\ngpio_value\x18\x03 \x01(\x04\"l\n\x04Type\x12\t\n\x05UNSET\x10\x00\x12\x0f\n\x0bWRITE_GPIOS\x10\x01\x12\x0f\n\x0bWATCH_GPIOS\x10\x02\x12\x11\n\rGPIOS_CHANGED\x10\x03\x12\x0e\n\nREAD_GPIOS\x10\x04\x12\x14\n\x10READ_GPIOS_REPLY\x10\x05\x42\'\n\x13\x63om.geeksville.meshB\x0eRemoteHardwareH\x03\x62\x06proto3'
)
@@ -129,4 +129,5 @@ HardwareMessage = _reflection.GeneratedProtocolMessageType('HardwareMessage', (_
_sym_db.RegisterMessage(HardwareMessage)
DESCRIPTOR._options = None
# @@protoc_insertion_point(module_scope)

2
proto

Submodule proto updated: aac0044b2d...1ec2369ae4