Page 5 of 17

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 10 2019 11:06am
by Zelenaar
Casainho, Nick,

I created a wiki page to describe the L1, L2/L3 data structure
https://github.com/OpenSource-EBike-fir ... aStructure

I tried my best to grep it out of the 850c code (and motor firmware)
But can you review and correct if needed.
I don't know the meaning of the fields (I can assume a lot out of the names) => can somebody complete the short description.

Next step : determine which ones need to be available on BLE ( and in which modus read/readwrite ....)
Once we agree on the (BLE) datafields I can try to create a POC of a custom Gatt server code and start on the android app

Casainho,
In a previous post you mentioned you will be focusing on the 850c, but aren't there parts that can be in common ?
If we take the L1, L2/L3 as a common structure I would assume that the uart handling is the same for both.

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 10 2019 11:41am
by sidmodi
Hi Guys,

I am interested in helping with development for the SW102. Step 1 for me would be to purchase the display. What's the best source you would recommend to purchase from? I am located in Canada so is there a preferred North American supplier?

While I wait for the display, I will try and get up my development environment set up using the information here:

https://github.com/OpenSource-EBike-fir ... -(Windows)

Thanks for providing such a detailed guide for setting up the env! If I have any questions or anything is unclear, I will post my questions.

Cheers,
Sid

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 10 2019 12:35pm
by casainho
Zelenaar wrote:
May 10 2019 11:06am
Casainho, Nick,

I created a wiki page to describe the L1, L2/L3 data structure
https://github.com/OpenSource-EBike-fir ... aStructure

I tried my best to grep it out of the 850c code (and motor firmware)
But can you review and correct if needed.
I don't know the meaning of the fields (I can assume a lot out of the names) => can somebody complete the short description.

Next step : determine which ones need to be available on BLE ( and in which modus read/readwrite ....)
Once we agree on the (BLE) datafields I can try to create a POC of a custom Gatt server code and start on the android app

Casainho,
In a previous post you mentioned you will be focusing on the 850c, but aren't there parts that can be in common ?
If we take the L1, L2/L3 as a common structure I would assume that the uart handling is the same for both.
Seems strange to me to design the app from bottom to top. If you design from top, you would understand (I can explain more easily) the mean of each variable as they are for specific functionality.

850C does all the functionality while SW102 may share some with mobile app so I think it is important to understand the details of which functionality goes only or both to mobile app. After that, I think is easier to define the which structure needs to be sent and received to/from mobile app. For instance: Assist level, should it be read and written(increase/decrease) on mobile app? or only on SW102??

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 12 2019 4:47am
by bart1006
I am trying to get my sw102 up and running. I connect the sw102 to my stlinkv2 and setup my Eclipse env.

I try to flash something tho the sw102 but I am pretty new to this so I have some issues.

I tried to flash_program and my stlink was blinking red and blue and no errors. I tried again and ran into some troubles also tried to flash the flash_softdevice but now I get errors:

Flashing: _build/nrf51822_sw102.hex
blaat
C:/Eclipse/nrf5/Eclipse/Toolchain/GNUMCUEclipse/OpenOCD/0.10.0-12-20190422-2015/bin/openocd.exe -f ../scripts/interface/stlink.cfg -f ../scripts/target/nrf51.cfg -c "init; reset init; flash write_image erase _build/nrf51822_sw102.hex; verify_image _build/nrf51822_sw102.hex; reset halt; resume; shutdown"
GNU MCU Eclipse OpenOCD, 64-bitOpen On-Chip Debugger 0.10.0+dev-00593-g23ad80df4 (2019-04-22-20:25)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
Info : clock speed 1000 kHz
Info : STLINK V2J17S4 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.230159
Error: init mode failed (unable to connect to the target)


make: *** [Makefile:226: flash_program] Error 1
"make VERBOSE=1 -j4 flash_program" terminated with exit code 2. Build might be incomplete.


Do you have any idea what is going wrong? What should be the right way to flash?
I use the SDK_12.3.0 branch or should i use the master?

Do you only connect the lcd to the stlink (i use the 3.3v) or do you also need to hook it up to the tsdz2?

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 12 2019 5:53am
by casainho
bart1006 wrote:
May 12 2019 4:47am
Error: init mode failed (unable to connect to the target)
Seems your OpenOCD is working correctly however the communication to the target is failing.

Check the wiring.

Also I think the nrf51 is locked/write protected and usually there are some commands to unprotect the first time before get it ready to flash firmware. This is something I don't know how is done on the "tools" that Nick prepared for Windows. I usually do using the telnet console access to send the needed commands to OpenOCD (on Linux).

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 12 2019 12:44pm
by bart1006
casainho wrote:
May 12 2019 5:53am
bart1006 wrote:
May 12 2019 4:47am
Error: init mode failed (unable to connect to the target)
Seems your OpenOCD is working correctly however the communication to the target is failing.

Check the wiring.

Also I think the nrf51 is locked/write protected and usually there are some commands to unprotect the first time before get it ready to flash firmware. This is something I don't know how is done on the "tools" that Nick prepared for Windows. I usually do using the telnet console access to send the needed commands to OpenOCD (on Linux).
It was indeed a bad connection of one of the wires. Now everything is working!! :-) and got the example running.

@Nick:
We are missing the file nRF5_SDK_12.3.0\components\softdevice\s130\hex\s130_nrf51_2.0.1_softdevice.hex in the 12.3.0 branch can you add that to the branch?

I had some troubles with building because of spaces in the installation path GNU MCU Eclipse\OpenOCD after renaming it to
nrf5\Eclipse\Toolchain\GNUMCUEclipse\OpenOCD everthing worked. Can I add that to the wiki or is this only my setup ;-)

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 12 2019 1:31pm
by Nick
Ah, yes. That is because of the .gitignore no hex files were uploaded. Will fix this soon!
I update the wiki too.

BTW:
Flashing the examples need the Softdevice to be flashed too (at least once). The order of flashing is important:
1) flash_softdevice (only once or if you want to begin from sratch, all flash memory will be erased)
2) flash_program

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 12 2019 3:26pm
by Nick
casainho wrote:
May 12 2019 5:53am
bart1006 wrote:
May 12 2019 4:47am
Error: init mode failed (unable to connect to the target)
Seems your OpenOCD is working correctly however the communication to the target is failing.

Check the wiring.

Also I think the nrf51 is locked/write protected and usually there are some commands to unprotect the first time before get it ready to flash firmware. This is something I don't know how is done on the "tools" that Nick prepared for Windows. I usually do using the telnet console access to send the needed commands to OpenOCD (on Linux).
As far as I know, unlocking is done by a full erase of the chip. This is done when programming the softdevice.
I extend the projects Makefile with some targets which uses openOCD in command line mode (-c) to flash hex files on the chip. F.i. flashing the program hex (flash_program):

Code: Select all

$(OPENOCD) -c "init; reset init; flash write_image erase $<; verify_image $<; reset halt; resume; shutdown"
with $(OPENOCD) pointing to your existing installation on your system (you have to edit the Makefile to set this path btw!).

I think we also need a standalone version (of openOCD) to flash the bootloader/softdevice hexfile to the chip for all people who just want to flash (with ST-Link clones) and don't need the whole Eclipse install/GIT cloning/Tools install procedure for that! Any volunteers for that? I think writing a batch file/shell script and packing this together with openOCD in a zip file should do the job? Or are there some smarter solutions?

Greetings
Niklas

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 14 2019 9:36pm
by eyebyesickle
I'm totally out of my depth here... but have been working on the SW102 with people for a while... And have access to info... Let me know if there is anything I can do to help this process... I have the Bluetooth units with working TSDZ2 code for standard programming... Not sure if any of that will help, but I can bring in an associate to handle it if you guys think there is any info I could get to help out...

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 14 2019 11:21pm
by elem
eyebyesickle wrote:
May 14 2019 9:36pm
I'm totally out of my depth here... but have been working on the SW102 with people for a while... And have access to info... Let me know if there is anything I can do to help this process... I have the Bluetooth units with working TSDZ2 code for standard programming... Not sure if any of that will help, but I can bring in an associate to handle it if you guys think there is any info I could get to help out...
do you made test with marcoq code ?

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 15 2019 1:43pm
by bart1006
Nick wrote:
May 12 2019 3:26pm
I think we also need a standalone version (of openOCD) to flash the bootloader/softdevice hexfile to the chip for all people who just want to flash (with ST-Link clones) and don't need the whole Eclipse install/GIT cloning/Tools install procedure for that! Any volunteers for that? I think writing a batch file/shell script and packing this together with openOCD in a zip file should do the job? Or are there some smarter solutions?
Hey Nick,

Just got everythig up and running and did some updating by DFU it really works nice!! :bigthumb:
Also had an look for programming the layout of the lcd. Did you make the battery with je picture and thedotfactory?
If so can you share the picture or how you done it?

I will have a look for making a shell script to flash the bootloader/softdevice hexfile to the chip.

Regards,
Bart.

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 16 2019 9:14pm
by eyebyesickle
elem wrote:
May 14 2019 11:21pm
eyebyesickle wrote:
May 14 2019 9:36pm
I'm totally out of my depth here... but have been working on the SW102 with people for a while... And have access to info... Let me know if there is anything I can do to help this process... I have the Bluetooth units with working TSDZ2 code for standard programming... Not sure if any of that will help, but I can bring in an associate to handle it if you guys think there is any info I could get to help out...
do you made test with marcoq code ?
Wow, no... I don't know why I have not tried this yet... finally got the programming smoothed to where it works, and hadn't even thought of it.

------

Ok, Update/Edit - got the new version... I will check it out... hoping it should work fine... since it works with the VLCD-5 programming... but will have to be modified for the lights usage and other options if desired... the one thing I really want to do is set the voltage change from the menu... anyway I will let you know how it goes.

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 16 2019 11:10pm
by elem
eyebyesickle wrote:
May 16 2019 9:14pm
elem wrote:
May 14 2019 11:21pm
eyebyesickle wrote:
May 14 2019 9:36pm
I'm totally out of my depth here... but have been working on the SW102 with people for a while... And have access to info... Let me know if there is anything I can do to help this process... I have the Bluetooth units with working TSDZ2 code for standard programming... Not sure if any of that will help, but I can bring in an associate to handle it if you guys think there is any info I could get to help out...
do you made test with marcoq code ?
Wow, no... I don't know why I have not tried this yet... finally got the programming smoothed to where it works, and hadn't even thought of it.

------

Ok, Update/Edit - got the new version... I will check it out... hoping it should work fine... since it works with the VLCD-5 programming... but will have to be modified for the lights usage and other options if desired... the one thing I really want to do is set the voltage change from the menu... anyway I will let you know how it goes.
Last stable version is 0.16 and configurator 2.0 based, seem 0.18 and configurator 3.3 for fine too !?

i haven t any sw102 to check, i ll command one in future and try too, don t know if those from aliexpress work with BT .

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 17 2019 1:54am
by zappan
eyebyesickle wrote:
May 16 2019 9:14pm
elem wrote:
May 14 2019 11:21pm
eyebyesickle wrote:
May 14 2019 9:36pm
I'm totally out of my depth here... but have been working on the SW102 with people for a while... And have access to info... Let me know if there is anything I can do to help this process... I have the Bluetooth units with working TSDZ2 code for standard programming... Not sure if any of that will help, but I can bring in an associate to handle it if you guys think there is any info I could get to help out...
do you made test with marcoq code ?
Wow, no... I don't know why I have not tried this yet... finally got the programming smoothed to where it works, and hadn't even thought of it.

------

Ok, Update/Edit - got the new version... I will check it out... hoping it should work fine... since it works with the VLCD-5 programming... but will have to be modified for the lights usage and other options if desired... the one thing I really want to do is set the voltage change from the menu... anyway I will let you know how it goes.
Hi, but what are you using for your tests is a sw102 with standard Bluetooth with Bafang cables or a specific version that you made yourself do for TSDZ2 with specific software and cables?

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 17 2019 3:51am
by elem
Can someone suggest me a sw102 on aliexpress to buy ?
pswpower is selling one without usb but seem BLE nordic inside ...

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 17 2019 1:37pm
by Nick
bart1006 wrote:
May 15 2019 1:43pm
Hey Nick,

Just got everythig up and running and did some updating by DFU it really works nice!! :bigthumb:
Also had an look for programming the layout of the lcd. Did you make the battery with je picture and thedotfactory?
If so can you share the picture or how you done it?

I will have a look for making a shell script to flash the bootloader/softdevice hexfile to the chip.

Regards,
Bart.
Good to hear. Would be great if someone is looking into the lcd layout.
The icon-thing include some steps, briefly:
1) Find some nice one on iconfinder.com. Choose "Free" and "Vector" in your search
2) open svg in inkscape and scale to appropriate size
3) open in gimp and export to bmp in 24-bit RGB (extended options)
4) open in TheDotFactory and generate a C-Array. Already mentioned it here. Have a look in fonts.h for an example and the usage in main.c, too.

I zipped all icons and the config for TheDotFactory:
BatteryIcon.zip
(5.85 KiB) Downloaded 33 times

P.S.
I pushed new code to 12.3.0 branch for testing purposes. Please be warned this is all just experimenting with the SDK and the possibilities right now.

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 17 2019 4:30pm
by Nick
elem wrote:
May 17 2019 3:51am
Can someone suggest me a sw102 on aliexpress to buy ?
pswpower is selling one without usb but seem BLE nordic inside ...
Are there different versions? Just grab one, they all have the Nordic SOC with Bluetooth on board.

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 17 2019 10:08pm
by eyebyesickle
Nick wrote:
May 17 2019 4:30pm
elem wrote:
May 17 2019 3:51am
Can someone suggest me a sw102 on aliexpress to buy ?
pswpower is selling one without usb but seem BLE nordic inside ...
Are there different versions? Just grab one, they all have the Nordic SOC with Bluetooth on board.
The way I understand it, it just has to be enabled.... other than EggRider, and Myself, I don't know anyone else that gets them with bluetooth enabled.... when it is enabled... it easy... any program you can transfer with - no lock. if you want to make a lock... im sure you can do that... I just don't know the ins and outs, but these are super easy to update, unless restricted of course

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 17 2019 11:50pm
by elem
eyebyesickle wrote:
May 17 2019 10:08pm
Nick wrote:
May 17 2019 4:30pm
elem wrote:
May 17 2019 3:51am
Can someone suggest me a sw102 on aliexpress to buy ?
pswpower is selling one without usb but seem BLE nordic inside ...
Are there different versions? Just grab one, they all have the Nordic SOC with Bluetooth on board.
The way I understand it, it just has to be enabled.... other than EggRider, and Myself, I don't know anyone else that gets them with bluetooth enabled.... when it is enabled... it easy... any program you can transfer with - no lock. if you want to make a lock... im sure you can do that... I just don't know the ins and outs, but these are super easy to update, unless restricted of course
those you sell on your web site are for bafang only or do you have spare programmed for TSDZ2 unlocked ?

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 18 2019 8:49am
by Pegazus
Hi folks,

Very interested in the SW102 project.

I have a G310 bafang rear hub motor.

I'd like to go with the SW102 display but I can't find any controller to go with that.

Would KT controller work with the SW102? Any other idea ?

Thanks for help :)

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 18 2019 9:25am
by casainho
Pegazus wrote:
May 18 2019 8:49am
Hi folks,

Very interested in the SW102 project.

I have a G310 bafang rear hub motor.

I'd like to go with the SW102 display but I can't find any controller to go with that.

Would KT controller work with the SW102? Any other idea ?

Thanks for help :)
Please ask on the KT OpenSource firmware thread because must be the firmware on KT motor controller to support it. I think their developers like characteristics of SW102 as they are already using a Bluetooth app.

I wish KT OpenSource firmware could adopt SW102 LCD as also the TSDZ2 and so the SW102 coukd be used for broad number of users.

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 18 2019 10:02am
by Pegazus

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 22 2019 12:47pm
by bart1006
Hello guys,

just did some work on the layout for the lcd.
Nothing is working with real data yet but just playing around with some info on the lcd.
IMG_9399 (1).jpg
IMG_9399 (1).jpg (73.46 KiB) Viewed 1712 times

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 22 2019 1:06pm
by casainho
bart1006 wrote:
May 22 2019 12:47pm
Hello guys,

just did some work on the layout for the lcd.
Nothing is working with real data yet but just playing around with some info on the lcd.

IMG_9399 (1).jpg
Nice!!

I see that speed has no decimal number. And so it is 2 digits. But seems that the LCD can hold 3 digits horizontal. Why not put the assist level digit + the speed digits on the same line??
And that would free the next line, and maybe there I would put a graph for the pedal human power.

On top, I would make just like on 850C LCD, battery on left side and time on right side.

And on bottom, where is now the time, I would put symbols like brake and lights.

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Posted: May 22 2019 4:28pm
by casainho
About the mobile app, I bought an Android smartphone specifically to work as a GPS for my bicycle. I will be alone in mountains for 12 hours with a GPS file that I need to follow and I need to survive -- I need a good GPS and I want to keep my main phone only for calling or access Internet in the case of a need.

The bicycles GPSs starts at 200 euros and are locked in a way we can't install and run our apps. I bought a mobile phone (5 inches display) did cost 50 euros on local shop and runs Android Go, a version for cheap low specifications hardware.

The new Smartphones are BIG and with a lot of power. The new ones that are cheap for poor countries (running Android Go), are small (4 inches display) and seems to be ok for being a bicycle GPS.

I found OSMAnd app (OpenStreetMaps Android) to be popular and with the advanced features I am looking for, like import GPX files and doing the navigation, something that Goggle maps don't do:
Image

One limitation I found on Android Go is that I can't run 2 apps on the screen and that means in future we can't run map navigation files AND our TSDZ2 app that communicates with SW102 and shows numeric data and graphs in real time.
On my regular phone I can use 2 apps, as shown here OSMAnd + Youtube on the screen:

Image