Unexplained Bluetooth issue

One of my students found some odd behavior with a Bluetooth sketch on an Arduino 101. I can duplicate the issue but I can't explain why it's happening.

Can someone else try this?

Writing Diagram
Sketch

Connect with LightBlue Explorer (iOS) or nRF Connect (Android)

Write 0x01 to the switch characteristic
Light turns on
Write 0x00 to the switch characteristic
Light turns off

Write 0xFF to the dimmer characteristic
Light turns on
Write 0x80 to the dimmer characteristic
Light goes to 50%
Write 0x40 to the dimmer characteristic
Light goes to 25%
Write 0x00 to the switch characteristic
You'll see a log messages the LED is off, but the light will still be on

Serial output

Characteristic event, written: LED on
Characteristic event, written: LED off
Dimmer set to: 255
Dimmer set to: 128
Dimmer set to: 64
Characteristic event, written: LED off

I'm compiling on OS X 10.12.3 with Arduino 1.8.1. The Arduino 101 is running v1.0.7.

Maybe this is related to analogWrite issue · Issue #334 · arduino/ArduinoCore-arc32 · GitHub or digitalWrite and analogWrite do not work in combination · Issue #280 · arduino/ArduinoCore-arc32 · GitHub?

If I change the switch characteristic to always use analogWrite it works OK.

I expected digitalWrite after analogWrite to work like it does on the Arduino Uno. Last year we used RedBear Blend boards (AVR + nRF8001) with BLEPeripheral and didn't see this.

Hi @doncoleman,

I just tried this out with the Github master version of the 101 core, everything seems fine with that version.