Problem
I have the CC2540 development boards. These are working beautifully with all of the examples. so far. I am trying to create a peripheral application that uses the joystick. I have copied the simpleBLEPeripheral application and it is working perfectly as the simple BLE peripheral application. However the joystick seems to operate strangely. I tried to copy the correct setup and initialization from the simpleBLECentral example since it uses the joystick correctly. I have attached the output in the steps to recreate the problem.
summary:
I have added the register for keys in the init function
I have added a print statement in KEY_CHANGE handler
after a reset I get two KEY change events. The first is the correct joystick movement (left, right, etc.) and the second is a KEY_CHANGE event of 0. at this point all joystick touches are ignored except UP. that causes two KEY_CHANGE events. the first being UP event and the second being a 0. The UP position on the joystick will work forever with two change events but no other KEY_CHANGE events are seen.
In addition when I hit the joystick I am disconnected if I have BLE connection active.
I am sure there is something simple that I overlooked. Any help would be appreciated. I need to simulate a peripheral application where various buttons/switches are toggled. I want to keep the connections alive and just respond to the joystick in the peripheral application like the central application does.
********* example output ************
shift: 0 keys: 08 <-- after a reset first hit of joystick LEFT (or any other joystick position) causes two KEY_CHANGE events seen here shift: 0 keys: 00 after this the only KEY_CHANGE event is joystick UP this causes two KEY_CHANGE events as shown below all other hits on joystick do not cause a KEY_CHANGE event shift: 0 keys: 01 shift: 0 keys: 00 ***** KEY Handling **** static void IC2MBLEPeripheral_HandleKeys( uint8 shift, uint8 keys ) { VOID shift; // Intentionally unreferenced parameter printf("shift: %d keys: %02X\n",shift,keys); if(keys & HAL_KEY_UP) { } if(keys & HAL_KEY_LEFT) { } if(keys & HAL_KEY_RIGHT) { } if(keys & HAL_KEY_DOWN) { } if(keys & HAL_KEY_CENTER) { } } ************** added to init function ****** // Register for all key events - This app will handle all key events RegisterForKeys( IC2MBLEPeripheral_TaskID );