Grüße, Jeder hier, der XBee-Module verwendet und den Verschlüsselungsschlüssel mit Bascom einstellt.Ich bin seit ein paar Wochen dabei und es wird einfach nicht fest, ich habe es versucht. Wahrscheinlich mache ich in Zeile 189 natürlich etwas falsch.
Greetings, Anyone here using XBee modules who sets the Encryption key using Bascom.
I have been at this for few weeks and it just does not get set, I tried. Likely I am doing something wrong of course on Line 189.
Display All
Greetings, Anyone here using XBee modules who sets the Encryption key using Bascom.
I have been at this for few weeks and it just does not get set, I tried. Likely I am doing something wrong of course on Line 189.
Source Code
- $regfile = "m128def.dat"
- $crystal = 16000000
- $hwstack = 100
- $swstack = 100
- $framesize = 100
- $baud = 19200
- Config Porta = Input 'for address selection switches
- Porta = &B11111111 'enable ALL the PortA internal pull-up resistors
- Config Portb = Output
- Config Portc = Input 'for sensor input
- Portc = &B11111111
- 'Port C
- Dim J3pinstates As Byte
- 'Port A
- Dim Switchstates As Byte ' Inverted and correct format for use
- Dim Address_string As String * 2
- Red_led Alias Portb.7
- Dim Beambroke As Byte
- Config Com2 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
- Open "com2:" For Binary As #2
- '********************************************************************
- '
- ' Main Loop
- '
- '********************************************************************
- Gosub Config_xbee
- Do
- Gosub Getswitches
- 'Gosub Test_for_broken_beam
- 'If Beambroke = 1 Then
- Reset Red_led
- Print #2 , "***";
- Print #2 , Address_string;
- Print #2 , "@@@"
- Print #2 , Chr(13)
- Beambroke = 0
- Gosub Flash_led
- 'Else
- Set Red_led
- 'End If
- Loop
- End
- '************************************************
- '
- ' Just flash a LED
- '
- '************************************************
- Flash_led:
- Waitms 100
- Set Red_led
- Waitms 100
- Reset Red_led
- Return
- '************************************************
- '
- ' Test for a pin going low
- '
- '************************************************
- Test_for_broken_beam:
- ' For now I test the whole port
- J3pinstates = Pinc
- If J3pinstates < 255 Then
- Beambroke = 1
- End If
- Return
- '************************************************
- '
- ' Read the switches
- '
- '************************************************
- Getswitches:
- Switchstates = Pina ' Read the pins of port A
- Toggle Switchstates 'Invert the states
- Select Case Switchstates
- Case 0 : Address_string = "00"
- Case 1 : Address_string = "01"
- Case 2 : Address_string = "02"
- Case 3 : Address_string = "03"
- Case 4 : Address_string = "04"
- Case 5 : Address_string = "05"
- Case 6 : Address_string = "06"
- Case 7 : Address_string = "07"
- Case 8 : Address_string = "08"
- Case 9 : Address_string = "09"
- Case 10 : Address_string = "10"
- Case 11 : Address_string = "11"
- Case 12 : Address_string = "12"
- Case 13 : Address_string = "13"
- Case 14 : Address_string = "14"
- Case 15 : Address_string = "15"
- Case 16 : Address_string = "16"
- Case 17 : Address_string = "17"
- Case 18 : Address_string = "18"
- Case 19 : Address_string = "19"
- Case 20 : Address_string = "20"
- Case 21 : Address_string = "21"
- Case 22 : Address_string = "22"
- Case 23 : Address_string = "23"
- Case 24 : Address_string = "24"
- Case 25 : Address_string = "25"
- Case 26 : Address_string = "26"
- Case 27 : Address_string = "27"
- Case 28 : Address_string = "28"
- Case 29 : Address_string = "29"
- Case 30 : Address_string = "30"
- Case 31 : Address_string = "30"
- End Select
- Return
- '************************************************
- '
- ' Config XBEE
- '
- '************************************************
- Config_xbee:
- ' Flash the red led to indicate the entry of XBEE Config
- Set Red_led
- Waitms 150
- Reset Red_led
- Waitms 150
- Set Red_led
- Waitms 150
- Reset Red_led
- Waitms 150
- Waitms 1200
- Print #2 , "+++"; 'Use ; Semicolon To Not add CR After
- Waitms 100
- Print #2 , "ATCHC";
- Waitms 100
- Print #2 , "ATID1111";
- Waitms 100
- Print #2 , "ATBD4"; ' set to 19200 BAUD
- Waitms 100
- ' 1 = 2400 2 = 4800 3 = 9600 4 = 19200 5 = 38400 6 = 57600 7 = 115200
- 'Print #2 , "ATEE1"; 'Enable AES Encryption
- 'Waitms 100
- 'Print #2 , "ATKYA1A2A3A4A5A6A7A8"; 'Set Encryption KEY
- 'Waitms 100
- Print #2 , "ATWR"; 'Write to NVRam
- Waitms 100
- Print #2 , "ATCN"; 'Exit AT Mode
- Waitms 500
- ' Do some visual stuff on a led to know we ran this code.
- ' Flash the red led to indicate the exit of XBEE Config
- Set Red_led
- Waitms 150
- Reset Red_led
- Waitms 150
- Set Red_led
- Waitms 150
- Reset Red_led
- Waitms 150
- Set Red_led
- Waitms 150
- Reset Red_led
- Waitms 150
- ' Just wait a bit before transmition
- Waitms 1000
- Return