If follow the Bafang numbering on your picture:
1, 16, 22 - source of +5V (connected to the 5V output low dropout regulator on the Bafang PCB)
2 - CAN Low (connected to the CAN low pin of the CAN chip on the Bafang PCB)
3 - CAN High (connected to the CAN High pin of the CAN chip on the Bafang PCB)
4, 10, 20 - Ground (connected to the battery ground)
5 - Speed hall sensor output #1
6, 7, 8, 9, 17 - I am sure those pins are not connected to anything on the Bafang PCB because of they are not connected to anything on the harness. Maybe some of them are connected to ground in the Bafang PCB.
11 - Speed hall sensor output #2 (if you combine this signal with speed hall sensor output #1 it works like rotary encoder so you can define rotation direction and probably speed once the manged passed the speed sensor without waiting full turn of the wheel)
12 - Positive terminal of the battery
13 - Signal from POWER and DOWN buttons of the display (Button POWER pressed connects this pin with 500 Ohm resistor connected to ground. Button DOWN pressed connects this pin with 1500 Ohm resistor connected to ground)
14 - Brake sensor
15 - Throttle
18 - Shift sensor
19 - Front Light
21 - Rear Light
Here is a picture DaDo sent to me, I did did not make it
