Skip to content

Commit

Permalink
Merge pull request #5 from YeapGuy/fix-uid-calculation
Browse files Browse the repository at this point in the history
Correct lower/higher byte calculation
  • Loading branch information
Matrixchung authored Apr 24, 2023
2 parents b097737 + 1216ce5 commit 1f13fe1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ uint8_t SFM_Module::setRingColor(uint8_t startColor, int8_t endColor, uint16_t p
@note Please check example for how to register using 3C3R method.
*/
uint8_t SFM_Module::register_3c3r_1st(uint16_t uid){
return _getCmdReturn(0x01, uid >> 8, uid << 8, SFM_DEFAULT_USERROLE);
return _getCmdReturn(0x01, (uid >> 8) & 0xFF, uid & 0xFF, SFM_DEFAULT_USERROLE);
}
/*!
@brief 3C3R Register step #2
Expand Down Expand Up @@ -100,7 +100,7 @@ uint8_t SFM_Module::register_3c3r_3rd(uint16_t &returnUid){
@return SFM_ACK_XXX
*/
uint8_t SFM_Module::deleteUser(uint16_t uid){
return _getCmdReturn(0x04, uid >> 8, uid << 8);
return _getCmdReturn(0x04, (uid >> 8) & 0xFF, uid & 0xFF);
}
/*!
@brief Delete ALL user(s)
Expand All @@ -116,7 +116,7 @@ uint8_t SFM_Module::deleteAllUser(){
@return SFM_ACK_SUCCESS if matched
*/
uint8_t SFM_Module::recognition_1v1(uint16_t uid){
return _getCmdReturn(0x0B, uid >> 8, uid << 8);
return _getCmdReturn(0x0B, (uid >> 8) & 0xFF, uid & 0xFF);
}
/*!
@brief Search the database and find matched uid
Expand Down Expand Up @@ -262,4 +262,4 @@ uint8_t SFM_Module::_getCmdReturn(uint8_t cmdType, uint8_t p1, uint8_t p2, uint8
q3 = sendCmd(cmdType, p1, p2, p3, ackType, q1, q2);
if(ackType == cmdType) return q3;
return SFM_ACK_FAIL;
}
}

0 comments on commit 1f13fe1

Please sign in to comment.