Hello @qingyunliu,
We are glad you found an explanation for question 1. As you mentioned, the dataLen is determined by the device you are connecting.
About question 2, it depends how are you reading the variable dataLen. If you read it in Global Variables while debugging the value changes. Meanwhile, if you read it in the Serial Console, you might notice that the variable is not changing. This happens because to see the Global Variables you need to stop the program producing these changes in values in the variable, but if you let the program to run freely the value of dataLen is the same value.
Best regards, Raul.