chanhash, minimal

This commit is contained in:
HTotoo
2026-06-17 22:32:11 +02:00
parent 88827a1b1c
commit 1129dafa55
2 changed files with 16 additions and 4 deletions
+6 -1
View File
@@ -263,6 +263,8 @@
</div>
<label for="radio-power">Output Power (dBm)</label>
<input type="number" id="radio-power" value="22" min="2" max="22">
<label for="radio-chanhash">Channel Hash</label>
<input type="number" id="radio-chanhash" value="8" min="0" max="255">
<button id="apply-config-btn">Apply Configuration</button>
</div>
@@ -274,6 +276,7 @@
<input type="number" id="attack-interval" min="10" max="7200" value="10" title="The delay between attacks.">
<label for="attack-mqtt">Ok to MQTT</label>
<input type="checkbox" id="attack-mqtt" title="Allow attacks to be sent via MQTT.">
<select id="attack-selector">
<option value="none">-- Select Attack --</option>
<option value="node_flood">Flood with Nodes</option>
@@ -501,6 +504,7 @@
loraBw.value = data.config.bandwidth || 250.0;
loraSf.value = data.config.spreading_factor || 11;
loraCr.value = data.config.coding_rate || 5;
document.getElementById('radio-chanhash').value = data.config.chanhash || 8;
document.getElementById('radio-power').value = data.config.power || 20;
break;
}
@@ -650,7 +654,8 @@
bandwidth: parseFloat(loraBw.value),
spreading_factor: parseInt(loraSf.value),
coding_rate: parseInt(loraCr.value),
power: parseInt(document.getElementById('radio-power').value)
power: parseInt(document.getElementById('radio-power').value),
chanhash: parseInt(document.getElementById('radio-chanhash').value)
}
};
logToDebug(`⚙️ Applying new radio configuration...`);
+10 -3
View File
@@ -40,8 +40,8 @@ LoraConfig lora_config = {
/*.tcxo_voltage = */ 1.8,
/*.use_regulator_ldo = */ false,
}; // default LoRa configuration for EU LONGFAST 433
uint8_t default_chanhash = 8;
MtCompact mtCompact;
uint16_t default_chan_hash = 31; // 8 = long_fast, 31 = medium fast
void sendDebugMessage(const std::string& message) {
std::string safe_text = message;
@@ -132,7 +132,7 @@ void app_main(void) {
mtCompact.setOnTraceroute([](MCT_Header& header, MCT_RouteDiscovery& route, bool for_me, bool is_reply, bool need_reply) {
sendDebugMessage("Traceroute from 0x" + std::to_string(header.srcnode) + ": route_count=" + std::to_string(route.route_count) + ", for_me=" + std::to_string(for_me) + ", is_reply=" + std::to_string(is_reply));
});
mtCompact.setPrimaryChanByHash(default_chan_hash);
mtCompact.setPrimaryChanByHash(default_chanhash); // should be a saved parameter
tmAttack.setRadio(&mtCompact);
@@ -176,6 +176,10 @@ void handle_start_attack(const char* attack_type, JSON_Object* params) {
int mqtt = (int)json_object_get_number(params, "mqtt");
mtCompact.setOkToMqtt(mqtt == 1);
ESP_LOGI("WEB", "Attack MQTT sending set to %s", mqtt == 1 ? "enabled" : "disabled");
uint8_t chanhash = (uint8_t)json_object_get_number(params, "chanhash");
mtCompact.setPrimaryChanByHash(chanhash);
ESP_LOGI("WEB", "Attack channel set to hash %d", chanhash);
}
if (strcmp(attack_type, "pos_poison") == 0 && params != NULL) {
double min_lat = json_object_get_number(params, "min_lat");
@@ -261,12 +265,15 @@ void handle_set_config(JSON_Object* params) {
double sf = json_object_get_number(params, "spreading_factor");
double cr = json_object_get_number(params, "coding_rate");
double power = json_object_get_number(params, "power");
uint8_t chanhash = (uint8_t)json_object_get_number(params, "chanhash");
ESP_LOGI("WEB", "Config: Freq=%.1f, BW=%.1f, SF=%.0f, CR=%.0f, Power=%.0f", frequency, bandwidth, sf, cr, power);
mtCompact.setRadioFrequency(frequency);
mtCompact.setRadioBandwidth(bandwidth);
mtCompact.setRadioSpreadingFactor(static_cast<uint8_t>(sf));
mtCompact.setRadioCodingRate(static_cast<uint8_t>(cr));
mtCompact.setRadioPower(static_cast<int8_t>(power));
mtCompact.setPrimaryChanByHash(chanhash);
default_chanhash = chanhash;
lora_config.frequency = frequency;
lora_config.bandwidth = bandwidth;
lora_config.spreading_factor = static_cast<uint8_t>(sf);
@@ -305,6 +312,6 @@ void handle_initme() {
ws_sendall((uint8_t*)attack_json.c_str(), attack_json.length(), true);
vTaskDelay(pdMS_TO_TICKS(20));
// send radio config
std::string config_json = "{ \"type\": \"radio_config\", \"config\": { \"frequency\": " + std::to_string(lora_config.frequency) + ", \"bandwidth\": " + std::to_string(lora_config.bandwidth) + ", \"spreading_factor\": " + std::to_string(lora_config.spreading_factor) + ", \"coding_rate\": " + std::to_string(lora_config.coding_rate) + ", \"power\": " + std::to_string(lora_config.output_power) + " } }";
std::string config_json = "{ \"type\": \"radio_config\", \"config\": { \"frequency\": " + std::to_string(lora_config.frequency) + ", \"bandwidth\": " + std::to_string(lora_config.bandwidth) + ", \"spreading_factor\": " + std::to_string(lora_config.spreading_factor) + ", \"coding_rate\": " + std::to_string(lora_config.coding_rate) + ", \"power\": " + std::to_string(lora_config.output_power) + ", \"chanhash\": " + std::to_string(default_chanhash) + " } }";
ws_sendall((uint8_t*)config_json.c_str(), config_json.length(), true);
}