Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: E22 channel scanner needs help #30297
    Sid
    Participant

      I’m able to scan channels now. Instead of only changing the channel and saving that parameter alone with setConfiguration() in loop() as in the code above, I copied all of the setup() code between e22ttl.begin() and c.close() into the function set_channel() and call it in loop(), iterating through the channels successfully. When I removed all of the parameter assignments except CHAN from the function, it still worked. Now I see that the above code would have worked if I’d included e22ttl.begin() in the function.

      in reply to: E22 channel scanner needs help #30111
      Sid
      Participant

        Sorry to be a pest and grateful for your help so far, still haven’t been able to change E22 channels on the fly. I replaced the inline channel-changing code with a function as you suggested but that didn’t fix it. The sketch receives data when the channel is fixed but doesn’t when I cycle through the channel, as in the code blow. I re-implemented it with a Pi Pico and get the same behaviour. Have you other suggestions?

        /* Look for LoRa transmissions - on Pi Pico, test with sendTester.ino
         * scans channels 0x22 - 0x24 
         * receives in transparent mode
         * writes received channel id, RSSI, message to stdout
         * 
         * E22		  ----- Raspberry Pi Pico
         * M0         ----- 10
         * M1         ----- 11
         * TX         ----- 9 (PullUP)
         * RX         ----- 8 (PullUP)
         * AUX        ----- 2  (PullUP)
        */
        
        #include "Arduino.h"
        #include "LoRa_E22.h"
        #define ENABLE_RSSI true
        #define beeper 25  // led signals LoRa reception
        
        // ---------- Raspberry PI Pico pins --------------
        LoRa_E22 e22ttl(&Serial2, 2, 10, 11); //  RX AUX M0 M1
        // -------------------------------------
        
        int channel = 0x00;
        
        void setup() {
          Serial.begin(9600);
          delay(500);
        
          // Startup all pins and UART
          e22ttl.begin();
        
        //  If you have ever change configuration you must restore It
        	Configuration configuration;
          ResponseStructContainer c;
        	c = e22ttl.getConfiguration();
        	configuration = *(Configuration*) c.data;
        	Serial.println(c.status.getResponseDescription());
          configuration.ADDL = 0x03;
          configuration.ADDH = 0x00;
          configuration.NETID = 0x00;
        
          configuration.CHAN = 23;
        
          configuration.SPED.uartBaudRate = UART_BPS_9600;
          configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
          configuration.SPED.uartParity = MODE_00_8N1;
        
          configuration.OPTION.subPacketSetting = SPS_240_00;
          configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
          configuration.OPTION.transmissionPower = POWER_22;
        
          configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
          configuration.TRANSMISSION_MODE.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
          configuration.TRANSMISSION_MODE.enableRepeater = REPEATER_DISABLED;
          configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
          configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;
          configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
        	e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
          c.close();
        }
        
        void loop() {  
          channel = channel % 0x25;
          if (channel == 0x00) { channel = 0x22; }   // cycle through only 0x22 - 0x24
          set_channel(channel);                      // receives ok if this line commented out
          Serial.print("channel "); Serial.println(channel);
          delay(2000);
        
          if (e22ttl.available()>1) {
        	  // read the String message
        	  ResponseContainer rc = e22ttl.receiveMessageRSSI();
        	// Is something goes wrong print error
        	  if (rc.status.code!=1) {
        	  	Serial.print("0 "); Serial.println(rc.status.getResponseDescription());
          	}
            else if (rc.rssi > 0) {
        // Print the data received
          //  Serial.println(rc.status.getResponseDescription());
              Serial.print(channel);
              Serial.print("\t");
              Serial.print(rc.rssi);
              Serial.print("\t");
              Serial.print(rc.data);
              Serial.print("\n");
            }
          }
          channel++;
        }
        void set_channel(int chan) {
          Configuration configuration;
          ResponseStructContainer c;
          c = e22ttl.getConfiguration();    // change radio to arg channel
          configuration = *(Configuration*) c.data; 
          configuration.CHAN = chan;
          e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
          c.close();
        }
        
        in reply to: E22 channel scanner needs help #30084
        Sid
        Participant

          When I commented out the code that sets the frequency in the iteration through the channels …

           c = e22ttl.getConfiguration(); // change to next channel
          configuration = *(Configuration*) c.data;
          configuration.CHAN = channel;
          e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
          Serial.print("channel "); Serial.println(channel);
          c.close(); 

          the sketch stays on the setup() channel 0x23 and receives the transmission properly. Should I give up on scanning or is there a good way to change the channel on the fly?

          Sid
          Participant

            Thank you Renzo, very helpful.

          Viewing 4 posts - 1 through 4 (of 4 total)