Dealing with the NS sending MAC command through FPort 0

I am new to programming an end node device. Recently, my device needs to deal with a Chirpstack server that does not allow me to do configuration. It will send the downlink encrypted MAC command in the payload through FPort 0.

I was used to sending mac commands responses through the FOpts field in the old days, but it is not working for this situation. Am I must send an uplink encrypted MAC response through FPort 0 too? Can I send my payload and the MAC command simultaneously in this situation?

Besides, I set up my own Chirpstack network server, and how can I set the server to send encrypted MAC command through Frame Port 0? I want to use it for self-testing.

By the LoRaWAN specification, MAC commands are normally not dealt by the application. Thus the are not revealed to the application server, and beyond and neither can the application normally send MAC commands as downlinks.

It looks like it is possible to send MAC commands, using the Network Server’s gRPC API. Have you tried this yet? Sending MAC commands with the Application Server REST API

Please note that this was once implemented for testing purposes, but it probably does not what you expect it to do. ChirpStack sends mac-commands to the device if it detects a difference between the device-state vs the ChirpStack configuration. If you send your own mac-commands (e.g. to change the RX1 delay timing), then this change is not captured by ChirpStack, and your device will no longer be reachable as it will continue to use the RX1 delay from the device-state.

For this reason, the next ChirpSack release (v4) will drop support for sending your own mac-commands.