title: Core Bluetooth - Peripheral cannot be written to by central
body: <p>I have two applications, one as a peripheral (on iPad 4th Gen running iOS 7) and one as central (iPhone 5c running iOS7).</p>
  
  <p>I wish to have a writable characteristic within the peripheral device that the central writes a handful of bytes to (approx 4 bytes but could vary from execution to execution).</p>
  
  <p>I am configuring the peripheral as follows:</p>
  
  <pre><code>-(void)startPeripheral
  {
      CBMutableService *service = [[CBMutableService alloc]initWithType:[CBUUID UUIDWithString:kMyServiceUUID] primary:YES];
      CBMutableCharacteristic *ch = [[CBMutableCharacteristic alloc]initWithType:[CBUUID UUIDWithString:kMyWriteUUID] properties:CBCharacteristicPropertyWrite value:nil permissions:CBAttributePermissionsWriteable];
      service.characteristics = @[ch];
  
      NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@[[CBUUID UUIDWithString:kMyServiceUUID]], CBAdvertisementDataServiceUUIDsKey, @"My Peripheral", CBAdvertisementDataLocalNameKey, nil];
  
      [self.peripheralManager addService:service];
      [self.peripheralManager startAdvertising:dict];
  
      NSLog(@"Service = %@",service);
  }
  </code></pre>
  
  <p>This all appears to work at first, the peripheral advertises the service and my central can scan, find, discovers service and characteristics and find the characteristic it's interested in.   The problem comes when I try to write to the characteristic.</p>
  
  <p>On the central I have the following method:</p>
  
  <pre><code>-(void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
  {
      NSLog(@"Service/Characteristics = %@",service.characteristics);
      for(CBCharacteristic *ch in service.characteristics)
      {
          NSLog(@"Characteristic properties = %x",ch.properties);
          NSLog(@"Characterisctic = %@",ch.UUID);
          if([ch.UUID isEqual:[CBUUID UUIDWithString:kMyWriteUUID]])
          {
              // We've found our write characteristic
              NSLog(@"Writing data to characteristic %@",ch.UUID);
              NSData *data = [NSData dataWithBytes:(Byte[]){1,2,3,4} length:4];
              [peripheral writeValue:data forCharacteristic:ch type:CBCharacteristicWriteWithResponse];
          }
      }
   }
  </code></pre>
  
  <p>I get a callback to didWriteValueForCharacteristic which indicates the error:</p>
  
  <p>Error Domain=CBATTErrorDomain Code=14 "Unlikely error."</p>
  
  <p>Which is not very helpful.</p>
  
  <p>Can anyone spot and issues or suggest any solutions?</p>
  
  <p>Thanks, Rich</p>