Пример #1
0
        private void ResetSx127x(RadioTypeSx127x radio_type)
        {
            switch (radio_type)
            {
            case RadioTypeSx127x.LGW_RADIO_TYPE_SX1276:
                this.FpgaRegisterWrite(Registers.FPGA_CTRL_RADIO_RESET, 0);
                this.FpgaRegisterWrite(Registers.FPGA_CTRL_RADIO_RESET, 1);
                break;

            case RadioTypeSx127x.LGW_RADIO_TYPE_SX1272:
                this.FpgaRegisterWrite(Registers.FPGA_CTRL_RADIO_RESET, 1);
                this.FpgaRegisterWrite(Registers.FPGA_CTRL_RADIO_RESET, 0);
                break;

            default:
                throw new Exception("ERROR: Failed to reset sx127x, not supported (" + radio_type + ")");
            }
        }
Пример #2
0
        private void SetupSx127x(UInt32 frequency, Byte modulation, Sx127xRxbwE rxbw_khz, SByte rssi_offset)
        {
            RadioTypeSx127x radio_type = RadioTypeSx127x.LGW_RADIO_TYPE_NONE;

            RadioTypeVersion[] supported_radio_type = new RadioTypeVersion[2] {
                new RadioTypeVersion(RadioTypeSx127x.LGW_RADIO_TYPE_SX1272, 0x22),
                new RadioTypeVersion(RadioTypeSx127x.LGW_RADIO_TYPE_SX1276, 0x12)
            };

            // Check parameters
            if (modulation != 0x20) //MOD_FSK
            {
                throw new Exception("ERROR: modulation not supported for SX127x (" + modulation + ")");
            }
            if (rxbw_khz > Sx127xRxbwE.LGW_SX127X_RXBW_250K_HZ)
            {
                throw new Exception("ERROR: RX bandwidth not supported for SX127x (" + rxbw_khz + ")");
            }

            // Probing radio type
            for (Int32 i = 0; i < supported_radio_type.Length; i++)
            {
                // Reset the radio
                this.ResetSx127x(supported_radio_type[i].Type);
                // Read version register
                Byte version = this.Sx127xRead(0x42);
                // Check if we got the expected version
                if (version != supported_radio_type[i].Version)
                {
                    Helper.WriteError("INFO: sx127x version register - read: " + version + ", expected: " + supported_radio_type[i].Version);
                    continue;
                }
                else
                {
                    Console.WriteLine("INFO: sx127x radio has been found (type: " + supported_radio_type[i].Type + ", version: " + version + ")");
                    radio_type = supported_radio_type[i].Type;
                    break;
                }
            }
            if (radio_type == RadioTypeSx127x.LGW_RADIO_TYPE_NONE)
            {
                throw new Exception("ERROR: sx127x radio has not been found\n");
            }

            // Setup the radio
            switch (modulation)
            {
            case 0x20: //MOD_FSK:
                if (radio_type == RadioTypeSx127x.LGW_RADIO_TYPE_SX1272)
                {
                    this.SetupSx1272Fsk(frequency, (Int32)rxbw_khz, rssi_offset);
                }
                else
                {
                    this.SetupSx1276Fsk(frequency, (Int32)rxbw_khz, rssi_offset);
                }
                break;

            default:
                // Should not happen
                break;
            }
        }
Пример #3
0
 public RadioTypeVersion(RadioTypeSx127x t, Byte r)
 {
     this.Type    = t;
     this.Version = r;
 }