@claude Can we add a new config item (MESHCORE_DEVICE_NAME) that if set (or not zero-length) sets the companion nodes "node name" on startup?
@claude Can we add a new config item (MESHCORE_DEVICE_NAME) that if set (or not zero-length) sets the companion nodes "node name" on startup?
<!-- github-comment-id:3620934884 -->
Modified _initialize_device() to accept and use device_name parameter (line 77-116)
Updated Receiver.__init__() to accept device_name (line 32-52)
Updated create_receiver() and run_receiver() to pass through device_name
Device name is set during initialization if provided
Sender (src/meshcore_hub/interface/sender.py): Updated signatures for consistency
CLI (src/meshcore_hub/interface/cli.py): Added --device-name option with MESHCORE_DEVICE_NAME env var support
Implementation Details
The device name is set during receiver initialization in this order:
Set device time (sync clock)
Set device name (if MESHCORE_DEVICE_NAME is configured)
Send flood advertisement (broadcasts the new name)
Start automatic message fetching
Fetch contact database
Usage
# Via environment variableexportMESHCORE_DEVICE_NAME="MyNode"
meshcore-hub interface receiver
# Via CLI option
meshcore-hub interface receiver --device-name "MyNode"# In Docker Compose
environment:
MESHCORE_DEVICE_NAME: "Gateway-01"
Note About Pre-commit Checks and Tests
I was unable to run pre-commit checks and pytest due to permission restrictions in the CI environment. The changes follow the existing code patterns and should pass all checks. The implementation:
Uses proper type hints (Optional[str])
Follows the existing device command pattern (similar to set_time())
Includes comprehensive docstrings
Maintains backward compatibility (device_name is optional)
**Claude finished @jinglemansweep's task** —— [View job](https://github.com/ipnet-mesh/meshcore-hub/actions/runs/19992840338) • [`claude/issue-37-20251206-1854`](https://github.com/ipnet-mesh/meshcore-hub/tree/claude/issue-37-20251206-1854) • [Create PR ➔](https://github.com/ipnet-mesh/meshcore-hub/compare/main...claude/issue-37-20251206-1854?quick_pull=1&title=feat%3A%20Add%20MESHCORE_DEVICE_NAME%20config%20to%20set%20node%20name%20on%20startup&body=Implements%20%2337%0A%0AAdds%20support%20for%20setting%20the%20MeshCore%20device%2Fnode%20name%20on%20startup%20via%20the%20MESHCORE_DEVICE_NAME%20configuration%20option.%0A%0A%23%23%20Changes%0A-%20Added%20%60meshcore_device_name%60%20config%20field%20to%20InterfaceSettings%0A-%20Implemented%20%60set_name()%60%20method%20in%20device%20interface%20%28real%20and%20mock%29%0A-%20Updated%20receiver%20to%20set%20device%20name%20during%20initialization%0A-%20Added%20%60--device-name%60%20CLI%20option%20with%20env%20var%20support%0A%0AThe%20device%20name%20is%20set%20after%20time%20synchronization%20and%20before%20sending%20the%20initial%20advertisement%2C%20ensuring%20the%20name%20is%20broadcast%20to%20the%20mesh%20network.%0A%0A%F0%9F%A4%96%20Generated%20with%20%5BClaude%20Code%5D%28https%3A%2F%2Fclaude.ai%2Fclaude-code%29)
---
### Working on Issue #37: Set receiver/node "name" on service startup ✅
Successfully implemented MESHCORE_DEVICE_NAME configuration to set the companion node's name on startup.
#### Tasks
- [x] Set up Python environment and install dependencies
- [x] Read project documentation and understand structure
- [x] Locate configuration system and interface startup code
- [x] Research meshcore library set_name command
- [x] Add MESHCORE_DEVICE_NAME to configuration
- [x] Implement node name setting on startup
- [x] Commit and push changes
#### Changes Made
1. **Config** (`src/meshcore_hub/common/config.py:74-76`): Added `meshcore_device_name` field to `InterfaceSettings`
2. **Device Interface** (`src/meshcore_hub/interface/device.py:167-177`): Added `set_name()` abstract method to `BaseMeshCoreDevice`
3. **Real Device** (`src/meshcore_hub/interface/device.py:533-549`): Implemented `set_name()` using `mc.commands.set_name()`
4. **Mock Device** (`src/meshcore_hub/interface/mock_device.py:274-283`): Implemented `set_name()` for testing
5. **Receiver** (`src/meshcore_hub/interface/receiver.py`):
- Modified `_initialize_device()` to accept and use `device_name` parameter (line 77-116)
- Updated `Receiver.__init__()` to accept `device_name` (line 32-52)
- Updated `create_receiver()` and `run_receiver()` to pass through `device_name`
- Device name is set during initialization if provided
6. **Sender** (`src/meshcore_hub/interface/sender.py`): Updated signatures for consistency
7. **CLI** (`src/meshcore_hub/interface/cli.py`): Added `--device-name` option with `MESHCORE_DEVICE_NAME` env var support
#### Implementation Details
The device name is set during receiver initialization in this order:
1. Set device time (sync clock)
2. **Set device name (if MESHCORE_DEVICE_NAME is configured)**
3. Send flood advertisement (broadcasts the new name)
4. Start automatic message fetching
5. Fetch contact database
#### Usage
```bash
# Via environment variable
export MESHCORE_DEVICE_NAME="MyNode"
meshcore-hub interface receiver
# Via CLI option
meshcore-hub interface receiver --device-name "MyNode"
# In Docker Compose
environment:
MESHCORE_DEVICE_NAME: "Gateway-01"
```
#### Note About Pre-commit Checks and Tests
I was unable to run pre-commit checks and pytest due to permission restrictions in the CI environment. The changes follow the existing code patterns and should pass all checks. The implementation:
- Uses proper type hints (Optional[str])
- Follows the existing device command pattern (similar to `set_time()`)
- Includes comprehensive docstrings
- Maintains backward compatibility (device_name is optional)
---
[Branch: claude/issue-37-20251206-1854](https://github.com/ipnet-mesh/meshcore-hub/tree/claude/issue-37-20251206-1854) |
<!-- github-comment-id:3620936009 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
When the "interface" service starts, it should set the Nodes name from a config item (e.g. MESHCORE_DEVICE_NAME)
@claude Can we add a new config item (MESHCORE_DEVICE_NAME) that if set (or not zero-length) sets the companion nodes "node name" on startup?
Claude finished @jinglemansweep's task —— View job •
claude/issue-37-20251206-1854• Create PR ➔Working on Issue #37: Set receiver/node "name" on service startup ✅
Successfully implemented MESHCORE_DEVICE_NAME configuration to set the companion node's name on startup.
Tasks
Changes Made
src/meshcore_hub/common/config.py:74-76): Addedmeshcore_device_namefield toInterfaceSettingssrc/meshcore_hub/interface/device.py:167-177): Addedset_name()abstract method toBaseMeshCoreDevicesrc/meshcore_hub/interface/device.py:533-549): Implementedset_name()usingmc.commands.set_name()src/meshcore_hub/interface/mock_device.py:274-283): Implementedset_name()for testingsrc/meshcore_hub/interface/receiver.py):_initialize_device()to accept and usedevice_nameparameter (line 77-116)Receiver.__init__()to acceptdevice_name(line 32-52)create_receiver()andrun_receiver()to pass throughdevice_namesrc/meshcore_hub/interface/sender.py): Updated signatures for consistencysrc/meshcore_hub/interface/cli.py): Added--device-nameoption withMESHCORE_DEVICE_NAMEenv var supportImplementation Details
The device name is set during receiver initialization in this order:
Usage
Note About Pre-commit Checks and Tests
I was unable to run pre-commit checks and pytest due to permission restrictions in the CI environment. The changes follow the existing code patterns and should pass all checks. The implementation:
set_time())Branch: claude/issue-37-20251206-1854 |