Go Down

Topic: Setting bluegiga settings on BT (Read 573 times) previous topic - next topic

yerg2k

Hi. I'm trying to include in my sketch a command for the other end (PC) to set the passkey, among other things.

So, in my setup(), the first lines are:

Code: [Select]
 nvAddr = 64;
 nvByte = eeprom_read_byte((unsigned char *) nvAddr);
 dataByte = nvByte;
 Serial.begin(115200);        // open serial  
 if (dataByte != 0) {
   pinMode(7, OUTPUT);
   digitalWrite(7, HIGH);
   delay(10);
   digitalWrite(7, LOW);
   delay(2000);
   for (ioByte=0; ioByte < dataByte; ioByte++) {
     nvAddr++;
     nvByte = eeprom_read_byte((unsigned char *) nvAddr);
     Serial.print(nvByte, BYTE);
   }
   nvByte = 0;
   nvAddr = 64;
   eeprom_write_byte((unsigned char *) nvAddr, nvByte);
   delay(2000);
   digitalWrite(7, HIGH);
   resetbox();
 }


nvByte and tmByte are of type "byte". "resetbox" is a function that sets pin 11 low. Pin 11 is hooked to the reset pin, and works properly.

To load the new stuff into eeprom, the code:

Code: [Select]
       while (Serial.available() < dataByte) delay(1);
       nvAddr = 64;
       nvByte =  dataByte;
       eeprom_write_byte((unsigned char *) nvAddr, nvByte);
       retVal = 1;
       while (retVal <= dataByte) {
         nvAddr++;
         tmByte = Serial.read();
         nvByte = eeprom_read_byte((unsigned char *) nvAddr);
         if (tmByte != nvByte) eeprom_write_byte((unsigned char *) nvAddr, tmByte);
         retVal++;
       }
       delay(1000);
       resetbox();


I was hoping someone could look over this and point me in the right direction. My software sends a string similar to the setup sketch for the bluegiga, lines separated by cr/lf. The code runs, but the passkey doesn't change.

Go Up