3

I am trying to transfer data between a chess board (see attached pic) and a cordova based Android chess game(lichess). Both the devices will be connected via USB cable. Is it possible that a cordova app for android can have access to the USB controller APIs of the android device and communicate via it with the microcontroller?

p.s - i am new to cordova apps so my confusion can an app build with cordova interact with device hardware/sensors.

enter image description here

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
Suny
  • 1,175
  • 1
  • 10
  • 27

1 Answers1

1

To do what you're trying to do you will have to use a plugin to provide the USB communication capability. Either you can build your own plugin and code your functions in java (for that I suggest you have a look at how existing plugins are made and read some online tutorials like this one for example)

Or you can find an existing plugin that would allow to do what you need.

I found for example two projects about usb communication:

  • cordova-plugin-usbserial seems unfinished, not sure it's usable or not, more details on this page.
  • cordovarduino more specific about communication between an android device and a arduino board via USB, maybe that's what you need if your chessboard is based on an arduino.
QuickFix
  • 11,661
  • 2
  • 38
  • 50
  • thank you for answering! The board is NOT an arduino board (sorry for not mentioning it). And i would really wanting to be using an already developed plugin (of course if available?) The board has "SiliconLabs chipset 2103" which manages RS32/USB -UART on either sides. Do you think the "cordovaarduino" could still work? – Suny Mar 04 '19 at 15:43
  • well, have a look at cordova-plugin-usbserial plugin then. The link https://www.npmjs.com/package/cordova-plugin-usbserial is the one where you will have the more explanations. But again I'm not sure if it's fully functionnal. But you can try to get in touch with the author via github (even if the sample is also about arduino, maybe you can use it to communicate with other controlers). – QuickFix Mar 04 '19 at 15:54
  • I had a quick look at cordovarduino sample and you could try to use it and just translate the arduino code to what you need for your board and see if you manage to communicate (the cordova plugin handles the serial communication on the android side, so it should be able to talk to anything on the other side I guess, as long as you setup the same speed and protocol on both sides) – QuickFix Mar 04 '19 at 16:03