kopia lustrzana https://github.com/meshtastic/firmware
				
				
				
			
						commit
						890511615f
					
				|  | @ -155,3 +155,5 @@ This project is run by volunteers. Past contributors include: | |||
| # IMPORTANT DISCLAIMERS AND FAQ | ||||
| 
 | ||||
| For a listing of currently missing features and a FAQ click [here](docs/faq.md). | ||||
| 
 | ||||
| Copyright 2019 Geeksville Industries, LLC. GPL V3 Licensed. | ||||
|  |  | |||
|  | @ -14,6 +14,8 @@ ARCHIVEDIR=release/archive | |||
| 
 | ||||
| rm -f $OUTDIR/firmware* | ||||
| 
 | ||||
| mkdir -p $OUTDIR/bins $OUTDIR/elfs | ||||
| 
 | ||||
| # build the named environment and copy the bins to the release directory | ||||
| function do_build { | ||||
|     ENV_NAME=$1 | ||||
|  | @ -22,8 +24,8 @@ function do_build { | |||
|     SRCELF=.pio/build/$ENV_NAME/firmware.elf | ||||
|     rm -f $SRCBIN  | ||||
|     pio run --environment $ENV_NAME # -v | ||||
|     cp $SRCBIN $OUTDIR/firmware-$ENV_NAME-$COUNTRY-$VERSION.bin | ||||
|     cp $SRCELF $OUTDIR/firmware-$ENV_NAME-$COUNTRY-$VERSION.elf | ||||
|     cp $SRCBIN $OUTDIR/bins/firmware-$ENV_NAME-$COUNTRY-$VERSION.bin | ||||
|     cp $SRCELF $OUTDIR/elfs/firmware-$ENV_NAME-$COUNTRY-$VERSION.elf | ||||
| } | ||||
| 
 | ||||
| for COUNTRY in $COUNTRIES; do  | ||||
|  | @ -56,6 +58,6 @@ Generated by bin/buildall.sh --> | |||
| XML | ||||
| 
 | ||||
| rm -f $ARCHIVEDIR/firmware-$VERSION.zip | ||||
| zip --junk-paths $ARCHIVEDIR/firmware-$VERSION.zip $OUTDIR/firmware-*-$VERSION.* images/system-info.bin bin/device-install.sh | ||||
| zip --junk-paths $ARCHIVEDIR/firmware-$VERSION.zip $OUTDIR/bins/firmware-*-$VERSION.* images/system-info.bin bin/device-install.sh | ||||
| 
 | ||||
| echo BUILT ALL | ||||
|  | @ -34,13 +34,15 @@ build_flags = -Wall -Wextra -Wno-missing-field-initializers -Isrc -Os -Wl,-Map,. | |||
| 
 | ||||
| ; -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG | ||||
| 
 | ||||
| ; leave this commented out to avoid breaking Windows | ||||
| ;upload_port = /dev/ttyUSB0 | ||||
| ;monitor_port = /dev/ttyUSB0 | ||||
| 
 | ||||
| upload_speed = 921600 | ||||
| upload_port = /dev/ttyUSB0 | ||||
| 
 | ||||
| ; the default is esptool | ||||
| ; upload_protocol = esp-prog | ||||
| 
 | ||||
| monitor_port = /dev/ttyUSB0 | ||||
| monitor_speed = 115200 | ||||
| 
 | ||||
| # debug_tool = esp-prog | ||||
|  |  | |||
							
								
								
									
										2
									
								
								proto
								
								
								
								
							
							
								
								
								
								
								
								
							
						
						
									
										2
									
								
								proto
								
								
								
								
							|  | @ -1 +1 @@ | |||
| Subproject commit 1b2449b50d11f66d90511559e94cdf40f525fafb | ||||
| Subproject commit d13d741a985f75b953a9b7f8df6c8c61fcc4730d | ||||
|  | @ -106,12 +106,13 @@ class RadioCharacteristic : public ProtobufCharacteristic | |||
| 
 | ||||
|     void onRead(BLECharacteristic *c) | ||||
|     { | ||||
|         DEBUG_MSG("Reading radio config\n"); | ||||
|         DEBUG_MSG("Reading radio config, sdsecs %u\n", radioConfig.preferences.sds_secs); | ||||
|         ProtobufCharacteristic::onRead(c); | ||||
|     } | ||||
| 
 | ||||
|     void onWrite(BLECharacteristic *c) | ||||
|     { | ||||
|         DEBUG_MSG("Writing radio config\n"); | ||||
|         ProtobufCharacteristic::onWrite(c); | ||||
|         service.reloadConfig(); | ||||
|     } | ||||
|  | @ -263,7 +264,7 @@ See bluetooth-api.md for documentation. | |||
| BLEService *createMeshBluetoothService(BLEServer *server) | ||||
| { | ||||
|     // Create the BLE Service, we need more than the default of 15 handles
 | ||||
|     BLEService *service = server->createService(BLEUUID("6ba1b218-15a8-461f-9fa8-5dcae273eafd"), 25, 0); | ||||
|     BLEService *service = server->createService(BLEUUID("6ba1b218-15a8-461f-9fa8-5dcae273eafd"), 30, 0); | ||||
| 
 | ||||
|     assert(!meshFromNumCharacteristic); | ||||
|     meshFromNumCharacteristic = new FromNumCharacteristic; | ||||
|  |  | |||
|  | @ -10,10 +10,6 @@ | |||
| #include <pb_decode.h> | ||||
| #include <pb_encode.h> | ||||
| 
 | ||||
| /// 16 bytes of random PSK for our _public_ default channel that all devices power up on
 | ||||
| static const uint8_t defaultpsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, | ||||
|                                      0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0xbf}; | ||||
| 
 | ||||
| /**
 | ||||
|  * ## LoRaWAN for North America | ||||
| 
 | ||||
|  | @ -32,14 +28,6 @@ MeshRadio::MeshRadio(MemoryPool<MeshPacket> &_pool, PointerQueue<MeshPacket> &_r | |||
| { | ||||
|     myNodeInfo.num_channels = NUM_CHANNELS; | ||||
| 
 | ||||
|     // radioConfig.modem_config = RadioConfig_ModemConfig_Bw125Cr45Sf128;  // medium range and fast
 | ||||
|     // channelSettings.modem_config = ChannelSettings_ModemConfig_Bw500Cr45Sf128;  // short range and fast, but wide bandwidth so
 | ||||
|     // incompatible radios can talk together
 | ||||
|     channelSettings.modem_config = ChannelSettings_ModemConfig_Bw125Cr48Sf4096; // slow and long range
 | ||||
| 
 | ||||
|     channelSettings.tx_power = 23; | ||||
|     memcpy(&channelSettings.psk, &defaultpsk, sizeof(channelSettings.psk)); | ||||
|     strcpy(channelSettings.name, "Default"); | ||||
|     // Can't print strings this early - serial not setup yet
 | ||||
|     // DEBUG_MSG("Set meshradio defaults name=%s\n", channelSettings.name);
 | ||||
| } | ||||
|  | @ -122,7 +110,7 @@ void MeshRadio::reloadConfig() | |||
|     // FIXME - can we do this?  It seems to be in the Heltec board.
 | ||||
|     rf95.setTxPower(channelSettings.tx_power, false); | ||||
| 
 | ||||
|     DEBUG_MSG("Set radio: name=%s. config=%u, ch=%d, txpower=%d\n", channelSettings.name, channelSettings.modem_config, | ||||
|     DEBUG_MSG("Set radio: name=%s, config=%u, ch=%d, txpower=%d\n", channelSettings.name, channelSettings.modem_config, | ||||
|               channel_num, channelSettings.tx_power); | ||||
| 
 | ||||
|     // Done with init tell radio to start receiving
 | ||||
|  |  | |||
|  | @ -217,6 +217,7 @@ void MeshService::loop() | |||
| void MeshService::reloadConfig() | ||||
| { | ||||
|     // If we can successfully set this radio to these settings, save them to disk
 | ||||
|     nodeDB.resetRadioConfig(); // Don't let the phone send us fatally bad settings
 | ||||
|     radio.reloadConfig(); | ||||
|     nodeDB.saveToDisk(); | ||||
| } | ||||
|  |  | |||
|  | @ -44,9 +44,39 @@ static uint8_t ourMacAddr[6]; | |||
| 
 | ||||
| NodeDB::NodeDB() : nodes(devicestate.node_db), numNodes(&devicestate.node_db_count) {} | ||||
| 
 | ||||
| void NodeDB::resetRadioConfig() | ||||
| { | ||||
|     /// 16 bytes of random PSK for our _public_ default channel that all devices power up on
 | ||||
|     static const uint8_t defaultpsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, | ||||
|                                          0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0xbf}; | ||||
| 
 | ||||
|     if (radioConfig.preferences.sds_secs == 0) { | ||||
|         DEBUG_MSG("RadioConfig reset!\n"); | ||||
|         radioConfig.preferences.send_owner_interval = 4; // per sw-design.md
 | ||||
|         radioConfig.preferences.position_broadcast_secs = 15 * 60; | ||||
|         radioConfig.preferences.wait_bluetooth_secs = 120; | ||||
|         radioConfig.preferences.screen_on_secs = 30; | ||||
|         radioConfig.preferences.mesh_sds_timeout_secs = 2 * 60 * 60; | ||||
|         radioConfig.preferences.phone_sds_timeout_sec = 2 * 60 * 60; | ||||
|         radioConfig.preferences.sds_secs = 365 * 24 * 60 * 60; // one year
 | ||||
|         radioConfig.preferences.ls_secs = 60 * 60; | ||||
|         radioConfig.preferences.phone_timeout_secs = 15 * 60; | ||||
|         radioConfig.has_channel_settings = true; | ||||
|         radioConfig.has_preferences = true; | ||||
| 
 | ||||
|         // radioConfig.modem_config = RadioConfig_ModemConfig_Bw125Cr45Sf128;  // medium range and fast
 | ||||
|         // channelSettings.modem_config = ChannelSettings_ModemConfig_Bw500Cr45Sf128;  // short range and fast, but wide bandwidth
 | ||||
|         // so incompatible radios can talk together
 | ||||
|         channelSettings.modem_config = ChannelSettings_ModemConfig_Bw125Cr48Sf4096; // slow and long range
 | ||||
| 
 | ||||
|         channelSettings.tx_power = 23; | ||||
|         memcpy(&channelSettings.psk, &defaultpsk, sizeof(channelSettings.psk)); | ||||
|         strcpy(channelSettings.name, "Default"); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void NodeDB::init() | ||||
| { | ||||
| 
 | ||||
|     // init our devicestate with valid flags so protobuf writing/reading will work
 | ||||
|     devicestate.has_my_node = true; | ||||
|     devicestate.has_radio = true; | ||||
|  | @ -57,15 +87,7 @@ void NodeDB::init() | |||
|     devicestate.node_db_count = 0; | ||||
|     devicestate.receive_queue_count = 0; | ||||
| 
 | ||||
|     radioConfig.preferences.send_owner_interval = 4; // per sw-design.md
 | ||||
|     radioConfig.preferences.position_broadcast_secs = 15 * 60; | ||||
|     radioConfig.preferences.wait_bluetooth_secs = 120; | ||||
|     radioConfig.preferences.screen_on_secs = 30; | ||||
|     radioConfig.preferences.mesh_sds_timeout_secs = 2 * 60 * 60; | ||||
|     radioConfig.preferences.phone_sds_timeout_sec = 2 * 60 * 60; | ||||
|     radioConfig.preferences.sds_secs = 365 * 24 * 60 * 60; // one year
 | ||||
|     radioConfig.preferences.ls_secs = 60 * 60; | ||||
|     radioConfig.preferences.phone_timeout_secs = 15 * 60; | ||||
|     resetRadioConfig(); | ||||
| 
 | ||||
|     // default to no GPS, until one has been found by probing
 | ||||
|     myNodeInfo.has_gps = false; | ||||
|  | @ -102,6 +124,7 @@ void NodeDB::init() | |||
| 
 | ||||
|     // saveToDisk();
 | ||||
|     loadFromDisk(); | ||||
|     resetRadioConfig(); // If bogus settings got saved, then fix them
 | ||||
| 
 | ||||
|     DEBUG_MSG("NODENUM=0x%x, dbsize=%d\n", myNodeInfo.my_node_num, *numNodes); | ||||
| } | ||||
|  |  | |||
|  | @ -43,6 +43,9 @@ class NodeDB | |||
|     /// write to flash
 | ||||
|     void saveToDisk(); | ||||
| 
 | ||||
|     // Reinit radio config if needed, because sometimes a buggy android app might send us bogus settings
 | ||||
|     void resetRadioConfig(); | ||||
| 
 | ||||
|     /// given a subpacket sniffed from the network, update our DB state
 | ||||
|     /// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw
 | ||||
|     void updateFrom(const MeshPacket &p); | ||||
|  |  | |||
|  | @ -50,7 +50,7 @@ typedef struct _MyNodeInfo { | |||
|     bool has_gps; | ||||
|     int32_t num_channels; | ||||
|     char region[12]; | ||||
|     char hw_model[12]; | ||||
|     char hw_model[16]; | ||||
|     char firmware_version[12]; | ||||
|     uint32_t error_code; | ||||
|     uint32_t error_address; | ||||
|  | @ -431,8 +431,8 @@ extern const pb_msgdesc_t ToRadio_msg; | |||
| #define RadioConfig_size                         120 | ||||
| #define RadioConfig_UserPreferences_size         72 | ||||
| #define NodeInfo_size                            155 | ||||
| #define MyNodeInfo_size                          81 | ||||
| #define DeviceState_size                         15076 | ||||
| #define MyNodeInfo_size                          85 | ||||
| #define DeviceState_size                         15080 | ||||
| #define FromRadio_size                           301 | ||||
| #define ToRadio_size                             295 | ||||
| 
 | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Kevin Hester
						Kevin Hester