I do not have the COM.X Zigbee module so I cannot test this myself. However with the following modifications the M5Stack example should work with an M5Core2 too.
Replace #define <M5Stack.h> with #define <M5Core2.h>.
Replace Serial2.begin(38400, SERIAL_8N1, 16, 17); with Serial2.begin(38400, SERIAL_8N1, 13, 14);.
Hardware: in the COM.X Zigbee module set the two dip switches 16 and 17 to on and leave the other four in off position.
Explanation: On the M5Core2 GPIO16 and GPIO17 have been replaced with GPIO13 and GPIO14. But the labeling in most modules still follow the numbering used with M5Stack devices.