SerialModule to mesh encryption problem

Hi, I have successfully enabled the serialmodule in my meshtastic compile and hardcoded some of the settings in SerialModule.cpp --SerialModule::runOnce() as follows

 radioConfig.preferences.serial_module_enabled = 1;
 radioConfig.preferences.serial_module_rxd = RXD2;
 radioConfig.preferences.serial_module_txd = TXD2;
 radioConfig.preferences.serial_module_timeout = 1000;
 radioConfig.preferences.serial_module_baud =RadioConfig_UserPreferences_Serial_Baud_BAUD_38400;
 radioConfig.preferences.serial_module_mode = RadioConfig_UserPreferences_Serial_Mode_MODE_Default;
 radioConfig.preferences.serial_module_echo = 0;

I have also changed the line

//SerialModuleRadio::SerialModuleRadio() : SinglePortModule(“SerialModuleRadio”, PortNum_SERIAL_APP){

to

SerialModuleRadio::SerialModuleRadio() : SinglePortModule(“SerialModuleRadio”, PortNum_TEXT_MESSAGE_APP){

I receive RS232 on pin IO34 and transmit on pin IO2 (These are fine on the board I am using.

When I enter the text ‘11111111111111111111’ in my serial terminal I can see it is correectly received as I added the line

DEBUG_MSG(“**************** {send2} Sending: %s %d %d\n”, p->decoded.payload.bytes, p->decoded.payload.size, p->which_payloadVariant);

to ErrorCode Router::send(MeshPacket *p) in Router.cpp just after the line p->from = getFrom(p);

The console shows

??:??:?? 2180 [SerialModule] **************** {send2} Sending: 11111111111111111111 20 4

modifying perhapsEncode to read

Routing_Error perhapsEncode(MeshPacket *p){
// If the packet is not yet encrypted, do so now
if (p->which_payloadVariant == MeshPacket_decoded_tag) {
static uint8_t bytes[MAX_RHPACKETLEN]; // we have to use a scratch buffer because a union

   size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), Data_fields, &p->decoded);
   DEBUG_MSG("{perhapsEncode} numbytes payload.bytes %d %s\n", numbytes, p->decoded.payload.bytes);

I get

??:??:?? 2180 [SerialModule] {perhapsEncode} numbytes payload.bytes 2 11111111111111111111
Here lies the problem Numbytes is only 2!
For the life of me I cannot see what is wrong and why numbytes is only 2.

My remote node wakes up but does not display anything.

At the very end of perhaps encode I added

   DEBUG_MSG("{perhapsEncode} Encrypted text msg  %s %d\n", p->encrypted.bytes, p->encrypted.size);

which returns > ??:??:?? 2180 [SerialModule] {perhapsEncode} Encrypted text msg ␟� 2

On a side note if I send a message using the android app from another node I see the same message come out of the serial port.

Please help. Thanks

1 Like

looks like you’re on firmware 1.3. if so, it is not ready yet.

Ah, ok. How do I tell what firmware verion I have pulled from Git hub. Any idea how long it will be before it is ready?

check your ./version.properties.

Meshtastic-device master branch is 1.3, 1.2-legacy branch is 1.2. the plan is a public 1.3 release in about 3 weeks, but no guarantees.

1 Like

Thank you. I have worked through the code and drilled down to pb_common.c where there is a comment ‘problem with RS232’ so I guess it all stop there as I cannot figure out what the code is trying to do.

I look forward to the working code.

Keep well