uint8_t Connect_receive_IdReport( uint8_t id, uint16_t *pending_bytes, uint8_t uart_num ) { dbug_print("IdReport"); // Check the directionality if ( uart_num == UART_Master ) { erro_print("Invalid IdRequest direction..."); } // Track Id response if master if ( Connect_master ) { info_msg("Id Reported: "); printHex( id ); print( NL ); // Check if this is the highest ID if ( id > Connect_maxId ) Connect_maxId = id; return 1; } // Propagate id if yet another slave else { Connect_send_IdReport( id ); } return 1; }
uint8_t Connect_receive_IdEnumeration( uint8_t id, uint16_t *pending_bytes, uint8_t uart_num ) { dbug_print("IdEnumeration"); // Check the directionality if ( uart_num == UART_Slave ) { erro_print("Invalid IdEnumeration direction..."); } // Set the device id Connect_id = id; // Send reponse back to master Connect_send_IdReport( id ); // Node now enumerated, set current to last received current setting // Only set if this is not the master node if ( Connect_id != 0 ) { Output_update_external_current( Connect_LastCurrentValue ); } // Propogate next Id if the connection is ok if ( Connect_cableOkSlave ) { Connect_send_IdEnumeration( id + 1 ); } return 1; }
void cliFunc_connectCmd( char* args ) { // Parse number from argument // NOTE: Only first argument is used char* arg1Ptr; char* arg2Ptr; CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr ); print( NL ); switch ( numToInt( &arg1Ptr[0] ) ) { case CableCheck: Connect_send_CableCheck( UARTConnectCableCheckLength_define ); break; case IdRequest: Connect_send_IdRequest(); break; case IdEnumeration: Connect_send_IdEnumeration( 5 ); break; case IdReport: Connect_send_IdReport( 8 ); break; case ScanCode: { TriggerEvent scanCodes[] = { { 0x00, 0x01, 0x05 }, { 0x00, 0x03, 0x16 } }; Connect_send_ScanCode( 10, scanCodes, 2 ); break; } case Animation: break; case RemoteCapability: // TODO break; case RemoteOutput: // TODO break; case RemoteInput: // TODO break; case CurrentEvent: dbug_print("Sending current event"); Connect_send_CurrentEvent( 250 ); break; default: break; } }
uint8_t Connect_receive_IdEnumeration( uint8_t id, uint16_t *pending_bytes, uint8_t uart_num ) { dbug_print("IdEnumeration"); // Check the directionality if ( uart_num == UART_Slave ) { erro_print("Invalid IdEnumeration direction..."); } // Set the device id Connect_id = id; // Send reponse back to master Connect_send_IdReport( id ); // Propogate next Id if the connection is ok if ( Connect_cableOkSlave ) { Connect_send_IdEnumeration( id + 1 ); } return 1; }