We handed out several hundred Code Cards this year and I’m guessing a few of you are wondering what to do next.
If you got home and pressed one of the buttons you more than likely saw this screen.
Don’t worry, it’s not broken, you just need to get it connected to the internet. There are a few different ways to do this.
Note: The Code Card uses a 2.4 GHz WiFi connection.
Create a WiFi Network
The easiest way to get it connected is to create a WiFi network using the credentials that are already set on the Code Card.
1 2 |
SSID=pmac851 Password=thinkcodetrigger |
One way you can do this is to create guest network on your WiFi router. Please refer to your router manual for instructions on setting this up.
Alternatively, you could create a hotspot on your phone, but make sure you’re OK with any charges from your service provider.
Edit:
At Oracle we like to keep everything patched and up to date. After I published this post, the security certificate for the REST back end was updated. This means you will also need to update the fingerprint settings for the four button options.
This also means that creating a WiFi SSID as in the paragraph above will only work if you also update the following four settings. For that you’ll need to choose one of the methods below. (I have added them to the examples below.)
1 2 3 4 |
fingerprinta1=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47 fingerprinta2=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47 fingerprintb1=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47 fingerprintb2=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47 |
Change the WiFi credentials on the card
If you’d rather just connect the Code Card to your existing WiFi network (2.4 GHz only), you can change the settings on the card.
In order to do this you need to open a serial connection to the card and send the following commands (using your WiFi credentials):
1 2 3 4 5 6 |
ssid=pmac851 password=thinkcodetrigger fingerprinta1=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47 fingerprinta2=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47 fingerprintb1=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47 fingerprintb2=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47 |
A Little Python
If you’d like to use Python:
- Install Python 3 if you don’t already have it.
- Open a terminal and install pyserial.
1python3 -m pip install pyserial - Create a file using the following code. I named mine ccSerial.py.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112import serialimport serial.tools.list_ports as port_listimport timeser = serial.Serial()settings = ['ssid=myHomeSSID','password=myPassword','fingerprinta1=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47','fingerprinta2=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47','fingerprintb1=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47','fingerprintb2=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47']def findPort():ports = list(port_list.comports())cardPort = Nonefor p in ports:if "USB to UART" in str(p):cardPort = p.devicebreakreturn cardPortdef openPort():global serif ser.is_open:print('Closing Port')ser.close()usbPort = findPort()if usbPort:ser.baudrate = 115200ser.timeout = 5ser.port = usbPortprint("Using Port:", ser.port)ser.open()return serdef readAll(ser):response = b''while True:chunk = ser.read(size=200)response += chunkif not len(chunk) == 200:breakreturn response.decode('utf-8', 'ignore')def sendSettings(ser):print("Updating Settings\n")for setting in settings:print(setting)ser.write(str.encode(setting))print(readAll(ser).split('\r\n')[0] + '\n')def cardReady():cardPort = openPort()attempts = 30for attempt in range (1, attempts + 1):print('Attempt %i of %i.' % (attempt, attempts))try:if cardPort.is_open == False:print('CodeCard not detected on USB')cardPort = openPort()time.sleep(2)else:cardPort.write(str.encode('status'))cardStatus = readAll(cardPort).split('\r\n')if cardStatus[0].startswith('IP address: '):cardPort.close()return Trueelif len(cardStatus[0]) == 0:print('****************************************************')print('* Press A and B Buttons on the CodeCard. *')print('* The screen should flash and display the barcode. *')print('****************************************************\n')else:while len(cardStatus[0]) > 0:print('Clearing Card Buffer')# print(cardStatus)cardStatus = readAll(cardPort).split('\r\n')time.sleep(1)time.sleep(1)except serial.SerialException:print('Connection Error. Attempting to re-connect.')cardPort = openPort()time.sleep(1)if cardPort.is_open:cardPort.close()def setDefaults():if cardReady():print('Setting Configuration Values')cardPort = openPort()sendSettings(cardPort)if cardPort:print('Restarting Code Card')print('Please turn it off and on again\n')cardPort.write(str.encode('restart'))cardPort.close()if __name__ == '__main__':setDefaults() - Change lines 7 and 8 to use your WiFi credentials.
- In the terminal run the new module and follow the instructions.
You should see something similar to the following.
12345678910111213141516171819202122232425262728293031323334353637[Projects]$ python3 ccSerial.pyUsing Port: /dev/ttyUSB0Attempt 1 of 30.***************************************************** Press A and B Buttons on the CodeCard. ** The screen should flash and display the barcode. *****************************************************Attempt 2 of 30.Clearing Card BufferClearing Card BufferAttempt 3 of 30.Setting Configuration ValuesUsing Port: /dev/ttyUSB0Updating Settingsssid=myHomeSSIDValue saved for ssid: myHomeSSIDpassword=myPasswordValue saved for password: myPasswordfingerprinta1=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47Value saved for fingerprinta1: 19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47fingerprinta2=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47Value saved for fingerprinta2: 19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47fingerprintb1=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47Value saved for fingerprintb1: 19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47fingerprintb2=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47Value saved for fingerprintb2: 19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47Restarting Code CardPlease turn it off and on again[Projects]$
Arduino IDE
If you have a Serial communication tool that you like, you should be able to use it to change the settings.
If not the Arduino IDE includes a Serial Monitor tool that work great.
- Do not connect your Code Card to the computer yet.
- Download, install and run the Arduino IDE.
- Click on Tools / Port.
- See what Ports are already in use.
- Connect your Code Card and turn it on.
- Click on Tools / Port.
- The newest Port should be your Code Card; select it.
- Click on Tools / Serial Monitor.
- On the bottom of the Serial Monitor, choose 115200 baud.
- Turn your Code Card off and on again.
- Press and release the A and B buttons at the same time.
You should see something like this.
123456789101112131415161718192021222324252627282930rll⸮⸮|⸮l⸮|⸮l⸮b|⸮⸮⸮⸮r⸮blb⸮⸮nn⸮lnn⸮⸮⸮bp⸮lrlrlp⸮n⸮⸮l⸮⸮bn⸮|l⸮⸮b⸮⸮nn⸮l⸮⸮l`⸮nnl`nr⸮⸮⸮nb⸮lr⸮⸮nb⸮l⸮bbb⸮⸮⸮⸮l`⸮⸮n⸮***************************************************************************************Code Card v1.0Oracle Developer Communitydeveloper.oracle.com/codecard***************************************************************************************Commands:ls Show all stored key/valueshelp Show this helpshortpress[a|b] Simulate the press of a buttonlongpress[a|b] Simulate the long press of a buttonconnect Connect to wifidisconnect Disconnect wifirestart Restart wifistatus Show wifi statushome Show home screenreset Reset to factory settingsUsage:Read saved key value:keySave new key value:key=[value]Available keys:ssid, password, buttona1, buttona2, buttonb1, buttonb2, fingerprinta1, fingerprinta2,fingerprintb1, fingerprintb2, methoda1, methoda2, methodb1, methodb2,>>>Connecting to 'pmac851' ....................Could not connect to 'pmac851'. Please check your ssid and password values. Type 'help' for more info.>>> - In the input field at the top enter (use your SSID)
1ssid=myHomeSSID
You should see something like
1234Value saved for ssid: myHomeSSID>>>Use the command 'restart' for changes to take effect.>>> - At the top enter (use your password)
1password=myPassword
You should see something like
1234Value saved for password: myPassword>>>Use the command 'restart' for changes to take effect.>>> - At the top enter (use your password)
1fingerprinta1=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47
You should see something like
12Value saved for fingerprinta1: 19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47>>> - At the top enter (use your password)
1fingerprinta2=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47
You should see something like
12Value saved for fingerprinta2: 19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47>>> - At the top enter (use your password)
1fingerprintb1=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47
You should see something like
12Value saved for fingerprintb1: 19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47>>> - At the top enter (use your password)
1fingerprintb2=19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47
You should see something like
12Value saved for fingerprintb2: 19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47>>> - Unplug your Code Card.
- Turn it off and on again.
- It should now connect to your network and the buttons should work.
What Else Can You Do?
There are a lot of things you can do with your Code Card.
For some ideas check out this GitHub page for some how to guides and other information.
IP address: 192.168.0.103
MAC address: CC:50:E3:CC:**:**
>>>
Button a – short pressed
>>>
Connecting to ‘****’ connected!
IP address: 192.168.0.103
MAC address: CC:50:E3:CC:**:**
>>>
Request:
host: apex.oracle.com
port: 443
url: https://apex.oracle.com/pls/apex/appslab/functions/master
fingerprint: 19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47
method: GET
Unexpected response: HTTP/1.0 200 OK
Oracle Events App ( Code Card Designer) where we could use prebuilt template to configure short/long press button A and B, it is still not working. It was working before but something changed on apex about 2 days ago and then it broke .
I always get A- short pressed, please wait ……
Do you always get the “Unexpected response: HTTP/1.0 200 OK”?
When you set the 4 fingerprints, make sure there are no spaces around the = and no spaces after the end
Also, make sure you turn the card off and on again before pressing A.
Yes, I just copied your python script and ran it ( just changed my ssid and password) and that steps works fine
but still press button a or b, does not bring template on oracle events app.
Yes, I am getting Unexpected response when using screen and giving command shortpressa or shortpessb
screen /dev/cu.SLAB_USBtoUART 115200 -L
>>>
Request:
host: apex.oracle.com
port: 443
url: https://apex.oracle.com/pls/apex/appslab/functions/master
fingerprint: 19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47
method: GET
Unexpected response: HTTP/1.0 200 OK
Button b – short pressed
>>>
Connecting to ‘sg’ connected!
IP address: 192.168.0.103
MAC address: CC:50:E3:**:**:**
>>>
Request:
host: apex.oracle.com
port: 443
url: https://apex.oracle.com/pls/apex/appslab/functions/master
fingerprint: 19 D1 5D 53 82 89 49 F6 92 7F 93 E5 06 EE 6D 40 16 41 4A 47
method: GET
Unexpected response: HTTP/1.0 200 OK
A couple things to check.
1. Make sure when you edit the screen in the Code Card Editor that you sign in using all upper case.
2. Make sure there are no special characters in the text. !@#$%^… Just send text. I think some may work but others will cause an unexpected response.
Sorry, what is Code Card Editor. I did not use any editor.
I have used screen command to connect to card and simulate shortpessa etc. I have also used your python script ( which can do same thing as in screen command e.g. setting up wifi ssid and password etc).
See configuring card section :
https://developer.oracle.com/codecard/
Then there was Mobile app ( Oracle Events) where we can use some which goes to and I can select some template etc http://groundbeakershub.com/codecarddesigner)
correct URL is : I may have mistyped in my previous post
http://groundbreakershub.com/codecarddesigner/
Yes, this is what I meant by Code Card Editor. I’m bad with names.
I just checked and it seems the Security Certificate Fingerprint has changed again.
The current values are:
fingerprinta1=D1 E4 3B A6 23 07 D8 16 81 D4 73 B1 AC E9 AE 55 08 D9 A0 32
fingerprinta2=D1 E4 3B A6 23 07 D8 16 81 D4 73 B1 AC E9 AE 55 08 D9 A0 32
fingerprintb1=D1 E4 3B A6 23 07 D8 16 81 D4 73 B1 AC E9 AE 55 08 D9 A0 32
fingerprintb2=D1 E4 3B A6 23 07 D8 16 81 D4 73 B1 AC E9 AE 55 08 D9 A0 32
After this, if you have setup your WiFi correctly and you still get a hang when pressing a button, you’ll need to get the fingerprint from the APEX service.
– Open a web browser and go to https://apex.oracle.com/en/
– View the security certificate (You’ll have to lookup how to do this for the browser you’re using)
– Find the SHA-1 Fingerprint. Currently it looks like this: D1 E4 3B A6 23 07 D8 16 81 D4 73 B1 AC E9 AE 55 08 D9 A0 32
However in another browser it may be colon deliminated: D1:E4:3B:A6:23:07:D8:16:81:D4:73:B1:AC:E9:AE:55:08:D9:A0:32
If it is using colons, replace them with spaces.
– Use this string for the 4 values in the settings at the top of this comment.
If you decide to try calling your own REST services, you will need to do this with your REST service URI.
Thanks, I will try tonight.
still does not work.
onnecting to ‘sgupta’ ……connected!
IP address: 192.168.0.103
MAC address: CC:50:E3:CC:C0:00
>>>
Request:
host: apex.oracle.com
port: 443
url: https://apex.oracle.com/pls/apex/appslab/functions/master
fingerprint: D1 E4 3B A6 23 07 D8 16 81 D4 73 B1 AC E9 AE 55 08 D9 A0 32
method: GET
Unexpected response: HTTP/1.0 200 OK
Shuting down…
I have changed fingerprint and again ran ccSerial.py but same issue. I checked certificate ssh-a1 and value is correct. This issue started happening only 3 or 4 days ago since it was working after I came back from Oracle Open World. There was some changes on Oracle Apex site and I think it broke afterwards , even oracle apex site was down 3 or 4 days ago.
I found a card that had the “Unexpected response” error.
I tried all of the above to fix it without success. What does fix it is re-flashing the firmware. You can find instructions for that here – https://github.com/cameronsenese/codecard/tree/master/arduino
Let me know if that helps.
Arduino: 1.8.10 (Mac OS X), Board: “Generic ESP8266 Module, 80 MHz, Flash, nodemcu, 26 MHz, 40MHz, DIO, 512K (no SPIFFS), 2, v2
I am getting following when trying to upload
Lower Memory, Disabled, None, Only Sketch, 115200”
Sketch uses 444156 bytes (88%) of program storage space. Maximum is 499696 bytes.
Global variables use 41700 bytes (50%) of dynamic memory, leaving 40220 bytes for local variables. Maximum is 81920 bytes.
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.
Verbose output
Sketch uses 444156 bytes (88%) of program storage space. Maximum is 499696 bytes.
Global variables use 41700 bytes (50%) of dynamic memory, leaving 40220 bytes for local variables. Maximum is 81920 bytes.
/Users/sagupta/Library/Arduino15/packages/esp8266/tools/esptool/0.4.13/esptool -vv -cd nodemcu -cb 115200 -cp /dev/cu.SLAB_USBtoUART -ca 0x00000 -cf /var/folders/nc/x54dnbnx5yggv3mzhsgd0gf4nlmmjp/T/arduino_build_175768/codecard.ino.bin
esptool v0.4.13 – (c) 2014 Ch. Klippel
setting board to nodemcu
setting baudrate from 115200 to 115200
setting port from /dev/tty.usbserial to /dev/cu.SLAB_USBtoUART
setting address from 0x00000000 to 0x00000000
espcomm_upload_file
espcomm_upload_mem
opening port /dev/cu.SLAB_USBtoUART at 115200
tcgetattr
tcsetattr
serial open
opening bootloader
resetting board
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
resetting board
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
resetting board
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
What happened to my previous two comments ?
Is there some issue with APEX Rest URL ? How can I rule out issue with APEX URL https://apex.oracle.com/pls/apex/appslab/functions/master
Here is the issue when uploading firmware image. It gets compiled fine but in the end it fails to upload
sing library SPI at version 1.0 in folder: /Users/sagupta/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.2/libraries/SPI
/Users/sagupta/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-size -A /var/folders/nc/x54dnbnx5yggv3mzhsgd0gf4nlmmjp/T/arduino_build_990181/codecard.ino.elf
Sketch uses 444148 bytes (42%) of program storage space. Maximum is 1044464 bytes.
Global variables use 41700 bytes (50%) of dynamic memory, leaving 40220 bytes for local variables. Maximum is 81920 bytes.
/Users/sagupta/Library/Arduino15/packages/esp8266/tools/esptool/0.4.13/esptool -vv -cd nodemcu -cb 115200 -cp /dev/cu.SLAB_USBtoUART -ca 0x00000 -cf /var/folders/nc/x54dnbnx5yggv3mzhsgd0gf4nlmmjp/T/arduino_build_990181/codecard.ino.bin
esptool v0.4.13 – (c) 2014 Ch. Klippel
setting board to nodemcu
setting baudrate from 115200 to 115200
setting port from /dev/tty.usbserial to /dev/cu.SLAB_USBtoUART
setting address from 0x00000000 to 0x00000000
espcomm_upload_file
espcomm_upload_mem
opening port /dev/cu.SLAB_USBtoUART at 115200
tcgetattr
tcsetattr
serial open
opening bootloader
resetting board
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
resetting board
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem was resolved using, need to press button A on Oracle code card for few seconds when code is done compiling and ready to upload.
Sorry for the delayed response, I’ve been traveling.
I’m glad to see you got it working.
Can you explain how can we upload your own logo/image to apex site used in codecard ?
The images are stored locally on the codecard. https://github.com/cameronsenese/codecard/blob/master/arduino/codecard/icons.h You’ll need to modify the arduino sketch.
I haven’t tried it yet, but I know you need to encode the image somehow. I plan to look into it in the next couple of months, if I can free up some time.
Thanks again Blaine! You made my Card usefull! You are my hero 🙂