Xenon example BLE code

I’d put that either into loop() or hook it up to the MODE button via System.on() to trigger on demand.

I tried in the loop() and it didn't print.
I don't know what you mean by hooking it up to the MODE butting via 'System.on()' . I'm new to Particle development.

Also a D7 LED blink pattern can provide continous feedback.

So I should write a code to blink LED on D7? I don't understand this.

I ran particle flash --usb <yourFirmware.bin> -v . What is Invalid DFU suffix signature?
here’s the output:

Opening DFU capable USB device…
ID 2b04:d00e
Run-time device DFU version 011a
Claiming USB DFU Interface…
Setting Alternate Setting #0
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
DfuSe interface name: "Internal Flash "
Downloading to address = 0x000d4000, size = 11920
Download [=========================] 100% 11920 bytes
Download done.
File downloaded successfully
Transitioning to dfuMANIFEST state
Invalid DFU suffix signature
A valid DFU suffix will be required in a future dfu-util release!!!

Flash success!

I also ran binary inspect and it looks like it's built for Xenon:

PS C:\Projects\Code\Particle\FirstProject\FirstProject_1\FirstProject_1\target\1.4.4\xenon> particle binary inspect FirstProject_1.bin
FirstProject_1.bin
CRC is ok (430289ef)
Compiled for xenon
This is an application module number 1 at version 6
It depends on a system module number 1 at version 1406

That can be ignored. This is a message that is emitted by the 3rd party dfu-util but doesn't indicate an actual problem.

However, all these outputs don't seem to suggest an immediate problem, so my next guess would be that your device just doesn't execute the code - probably due to SYSTEM_MODE(AUTOMATIC) (default when not stated otherwise) without SYSTEM_THREAD(ENABLED).

I should probably have asked that earlier:

  • Is this Xenon hooked up to a mesh network?
  • With what gateway?
  • What does the RGB LED do?
  • Can you share your code?

It is not hooked up to a mesh network. I only have a USB cable plugged into it.

RGB LED goes to yellow when it goes to DFU mode and then after it is done flashing it starts blinking BLUE.

Here’s my code:

#include "Particle.h"

// This example does not require the cloud so you can run it in manual mode or
// normal cloud-connected mode
// SYSTEM_MODE(MANUAL);

//SerialLogHandler logHandler(LOG_LEVEL_TRACE);


void setup() {
  Serial.begin();
  Serial.println("Hello World!");
  
}

void loop() {
  Serial.println("Hello World!");
    
}

Also, the BLE chip is advertising all the time and I don’t know if that’s a normal behavior since my code is not telling it to advertise.

This means your application will not run.
You first need to get your device out of Listening/Setup Mode (blinking blue).
The BLE advertising comes from the Setup Mode which expects you to connect to the device via the Particle App for setup.

I'd also suggest using SYSTEM_MODE(MANUAL) and SYSTEM_THREAD(ENABLED).

So I’m suppose to place SYSTEM_MODE(MANUAL) and SYSTEM_THREAD(ENABLED) at the beginning of the file?

I just did that and compiled and BLUE led is blinking still.
So I am not doing something right. What am I suppose to do to get it out of this “listening mode” ?

Since Xenons were not supposed to be running without an "owning" mesh it's not that straight forward.
If you had a gateway device it would be easy. You could just assign it to that dummy mesh and then never reconnect to it again (SYSTEM_MODE(MANUAL)).

Since I don't have any "virgin" Xenons anymore I don't know what exactly is required to do that without assigning it to a mesh.

You could search for Xenon standalone and Xenon without mesh tho'

e.g. this might help

Before I continue with Xenon let me first ask if I should even be using Xenon for my application since it looks like it wants to be connected to the mesh to work. I want to change BLE advertising and have custom characteristics, is this possible on Xenon ? Is there another product that might be better/easier for this application?

It is possible to have Xenons run standalone entirely - it just requires some initial persuasion to do what it’s not voluntarily doing :wink:

The bad thing about having done so much with these devices is that I just tend to throw all tools I know of at it and at the end it usually does what I want, but I haven’t got any wiser which of the actions of what combination thereof did the trick :blush:

Not sure if that will help but i had the same struggles as you seem to have and made a small post explaining how i fixed things some weeks ago :

Also, the original post explains things quite clearly :slight_smile:

As long as it can be done I’m willing to figure it out :slight_smile:

Thanks Durss, that post is very helpful !!

1 Like