Pages: [1]   Go Down
Author Topic: Setting bluegiga settings on BT  (Read 489 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 81
everywhen
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
 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:
       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.
Logged

Pages: [1]   Go Up
Jump to: