 Hello, if this is your first time watching a deep dive and you're watching it after it's been recorded, please check the description for time codes. We're gonna take a few minutes here to get going. So time codes are a great way to take a look at what we talked about and skip around in the video to find out what you're interested in. So, Mr. Certainly says live on Twitch. Thank you, Mr. Certainly. I'm trying something new with the Discords. Let me pause my windows. And I'm not entirely sure if we're gonna get time codes. Nobody's objects anymore, hopefully. That's why I was, I guess I'm still early. You catch you about a minute in your pre-inter. Yeah, it looked like Restream was getting going. I think, I love the factory. I'm gonna try not to mess with this Discord window even though my brain wants to make it larger. Hey, Johnny, hey, Dave. Hi, Patrick. I think I could turn timestamps. But the timestamps are just times. Trying to figure out how to be able to have the time codes on here so people can help with the time codes. I'm not sure whether David's gonna be able to make it because we're on a different day, so. If folks wanna help out, I posted the note stock in the Discord. If folks wanna join the Discord, please do. Go to adafru.it slash discord. I'll drop in there. And for those of you who wanna be notified, I know last week I said it'd be on Friday, but my partner reminded me that this weekend is a holiday weekend in the US and she has Friday and Monday off, so I'm taking tomorrow off. We're gonna go hike. And so yeah, that's why we're on Thursday. So if you wanna be notified, I realized that for a circuit python, we have the circuit pythonesis role, but I don't really have a great way of reaching out to everyone and saying like, oh, by the way, I said it was on Friday, but I changed my mind on Thursday. So if folks wanna be notified for those things, I started a deep divers role on Discord. So if you're on Discord now, I see a couple of you aren't in that group yet. You'll be blue if that's the only role you've got. So if you wanna be in there, let me know and we'll get you on that role so that I can ping you if times change or things get canceled, that sort of stuff. And I think Mr. Certainly can help tag roles as well if folks want it. Yeah, thank you, Mr. Certainly. Hugo says, maybe I should take up hiking. Everyone's always telling me I should take one. Let's see, Yanni's in there, Johnny's in there. Gary Z, good afternoon. Love the factory. Hello, hello, Hugo. Hey, Naradak. Oh yeah, and you can even see me scrolling up. Good, that should be helpful. And if you DM me, I'm not gonna read it. At least on the air. Although it's good and you can't see. I just say that you wanna be added and we can just add you. The reason, it makes it easier we can click your name. I hear I'll show you. You click the name and say, deep, deep. What, why isn't it showing up? Or maybe it's, oh, it's too late. Anyway, that's how we add it. You can just click names and add roles there. Right, I don't think you can add a role that someone already has. Yeah, Mr. Certainly's on top of things. Thank you, Mr. Certainly. Okay, I'm gonna try to remember to take some time codes here because I think David is, David usually can't do Thursdays, so. Let me just do a time code and I will do housekeeping. So, hello everyone, my name is Scott and I work for Adafruit on Circuit Python. Circuit Python is a, oops, Mr. Certainly's gonna be busy. Circuit Python is an open source version of Python, regular Python is open source as well, but it's a version of Python, Circuit Python is a version of Python geared for microcontrollers, which are little inexpensive computers that are all in one chip. The black chip there is a microcontroller and they're really inexpensive, so they're a great way to get started and they're really useful for, what about opening the live broadcast channel in a browser window? Yeah, I could do that. It's just, it's my regular Discord. It's fine. I'll answer questions in just a bit, but let me talk about Adafruit. Adafruit pays me to work on Circuit Python. They're an open source software and hardware company based out of New York City. So if you wanna support me and support others paid by Adafruit to work on Circuit Python and a lot of other things, please go to Adafruit.com and purchase some hardware there. I'll also check the YouTube. There's lots of other streams that go on. Thank you to JP, John Park, who just had his workshop an hour ago. So thanks to him. And if you wanna join me and a bunch of others, I've got my proper Discord window here right now. Go to the URL adafru.it slash discord. You can also go there. If you're on the Discord, there's a new deep divers role that Mr. Certainly will add you to. Thank you. And that'll be in case I need to notify you about time changes like this week had. That'll just be used for that. And maybe I'll do one a week or something. So I promise you no more than two pings a week if I announce something and then have to take it back. But I'll use it very sparingly, I promise you. So deep dyes happen every week. Normally at Fridays at 2 p.m. Pacific, but occasionally like today shifted to Thursday because of me taking the day off. It's a holiday weekend in the U.S. this weekend, which I forgot last weekend. It wasn't on my calendar. And I tend to take days off that my partner has off because she works for a proper company. And so she has Friday off. And so we're taking Friday and Monday off, which would be good. Nice long weekend. And like I said earlier, we're going for a hike, which should be really nice. It typically goes for two hours or more. Questions are welcome. I see Andre's question in the YouTube chat already. So thank you for that. I'll get to that in just a second. So happy to start there. More details about timing next week's gonna be on Friday. I looked and I don't think it's another holiday weekend. But I'm then taking two weeks off after that. So I'm fully vaccinated as of next Monday. And so my partner is fully vaccinated two weeks from this Tuesday. So we're gonna go visit her family in Michigan. So I'm gonna be taking some time off. So the plan is is that next week we'll all stream and then the next two Fridays, I will not. And then I'll be back on the 25th streaming again. So that's the details about that. Last up in the category of housekeeping. The kitty up in the top corner is he's like back here to my left. And he is epileptic, which means he has seizures from time to time. So if I'm standing here looking at something on the floor and muted, that's what's happening. He's been doing really well though. So I don't expect that to happen. But just a heads up, because it has happened before. All right. Cool. So, I said my partner works for a proper company. So my partner works at Google, so a much bigger company. And I'm actually technically a contractor with Adafruit as well. So I have more flexibility on the days that I take off. Adafruit proper, the folks that work in New York, they get Monday off, but I don't think they get Friday off, but I'm a contractor. So I just tell Phil a little more, like I'm taking the day off. So yeah. What Dave asks, what happens to the kitties when you're away? So I actually have two cats. This is just Spook. He's okay with me talking. The other one, the other one is kicked out of the room usually because she gets upset for me talking. They're gonna stay at my parents' house. And actually I'm gonna be there as well. So I'm not going to Michigan as long as my partner is. So I'll spend a few days with my family as well here in the Seattle area. Yeah, occasionally Vin, so the two cats are Vin and Spook. They're named after characters from Brandon Sanderson's Mistborn trilogy. So Vin is the more outgoing, but doesn't like it when I talk. That's why there's two beds there. I don't just have like two beds for one cat, although I definitely have more beds than cats. They're just not in this room. Anyway, okay. So people are debating whether Google's a proper company. So I used to work for Google as well before I worked for Adafruit. It's all good. Okay, so Andre had a question. Let's answer that. Let me take a time code. 1105. So the question is, does Circuit Python have something with Bluetooth mesh? I believe that, well, Circuit Python does not have Bluetooth mesh support, but I do believe that the NRF 5240 can do it. It's just that in Circuit Python, we haven't added it yet. So that's the short answer. I'd like to look at it at some point, but, and I've done like related to that sort of principle, like there's the broadcast net library and learned guide that just uses advertising back to a base station. It doesn't do any sort of like rebroadcasting sorts of things, but it does do, it just does blanket advertising. So if you want something kind of that model, that's what broadcast net is geared towards. All right. Any more questions? Or otherwise, we might just dive pretty deep here quickly, see where I'm at in terms of what I'm working on. It's been like really rainy. I might have to open the window anyway. Ooh, AJRed05, let me take another time code. AJRed05 says, I wanna get started with robotics. Where should I start? We'll pose that question to folks in a bit. Well, other folks will have opinions, I'm sure, but generally the answer is, let me issue the desktop. Generally the answer is, I would just go to learn, and then we have robot. I think it depends on what kind of robots you wanna do, but learn guides are a great place to start. You can take a look at all these different ones and pick the one that's kind of like most similar to what you're trying to do. Or what you could do is if you have existing hardware, you could try to find the hardware that it uses. But if you wanted to just like, you can click to an individual one and it has like a list of all the parts that you need to put it together. So I think generally learn guides are a great place for folks to start because they're kind of all in one sorts of things. And Mr. certainly says, yes, circuit playground express plus cricket. I might do circuit playground blue fruit plus cricket if you can. I tend to like favor the blue fruit over the express at this point. Dexter, Starboard, I'm gonna try to be good about timestamps here. Wait a file. Could WAV file plays slices of an audio file? We could add it, it can't currently. You would need to read the start of the file but then seek past it into a particular portion of it. But I don't think like because WAV files are pretty raw, there's like no need. I think as long as you seek like aligned with the samples, you could start in the middle of the samples. But we don't have that currently. Dexter, Starboard says offset and duration. Is there, does it actually have that? Have we added it and I don't know? I don't think so. Okay, so Andre, a different Andre asks, I'm interested in the Adafruit Atec 608 breakout board for a secure U-boot for IoT and Bitcoin hardware wallet. Any cool projects? I think what you're asking is like what projects use that? So let me show you the way that I find a lot of learn guides if I have a particular product I want. So if I wanna see the Atec 608, right? I can pick that here. And then because like I showed, oh, Dexter says enhancement request. Because I showed the other side of it from the learn guide, it has all the products that are related to it. The products themselves have the reverse. So if you pull up what you want and then scroll down, there's this list of learn guides here. So these are the two learn guides that we have right now for the Atec chip. So that's where I would start if you wanna start with a particular product. And this is really helpful for, this is really helpful for if you wanna find schematics and stuff for things. So the primary guide is the guide that usually has the schematics. So you go there and you hit downloads. And then you can see that like here's the chips data sheet, the Eagle CAD files, which you actually need to make available to be open source, the fab print, and then the schematic as well. And it's a real simple just for this breakout. And in fact, like all these things at the top here, those are common STEMA things. So the only things for the chip itself is here, which is pretty wild. So yeah, I don't know of any full projects having to do with hardware wallets and stuff, but this will get you started with the Atec chip. I've never actually used it myself. Good question, folks. So Love the Factory asked, which CP target is the most feature rich and or mature? That's a good question. I think what I would point to is I would point to the release notes. This is something that we've started to do relatively recently, but if you look at the release notes, we have this port status thing. And so it says like stability varies on a per port basis, Atmel, SAMD, Spresence, NRF, STM for the F4 family are all stable. Interesting. ESP32, S2, Raspberry Pi and STM for other STM chip families are being actively improved, but may be missing functionality and have bugs. I would actually, I think the S2 and the Raspberry Pi probably need to be promoted to stable as well. So that gives you kind of an idea of like how mature the individual ports are. It's not really done per board because like a lot of the code that we write is like on a per chip basis and the board just renames the pins at the kind of the outside edge of the design of the design. The feature rich question is more a more difficult one to address because it has to be, it really, you really need to know like a bit more specifics about what you want to do because like the SAMD 51 is quite good but it's not connected at all. So if you wanna do Wi-Fi, the ESP32, S2 is the obvious choice. If you wanna do Bluetooth, the NRF 52840 is like the way to go. This presence is really powerful but the APIs I think are pretty limited. I don't know how many of the APIs are actually implemented. So those are kind of the three that I would pick between is like S2, the ESP32, S2, NRF and the SAMD 51. Although I just realized that I hadn't talked about the Raspberry Pi Pico or the RP2040. I would consider like the RP2040 is great because it's inexpensive and it's got a lot of RAM. It's not gonna perform quite as well as the SAMD 51 I don't think because the SAMD 51 is a Cortex M4 and has floating point but the coolest bit of the RP2040 is the PIO functionality. So if you're doing things in Neopixels, the RP2040 is gonna be really good because it uses PIO under the hood or if you wanna do any sort of like weird digital interfacing you can do the PIO stuff yourself. So I don't know, I think whenever we add or create a product to Adafruit we try to have an understanding about like what makes a particular chip useful. There's certainly a baseline of like APIs like I squared C by Pulse in, Pulse out, PWM out. Those are kind of all kind of there, I guess. Those are kind of the baseline that we would hope all of the things have. And then more recently we've also added sleep functionality and that's not on every port which I guess what I should show also is if you wanna do this kind of like comparison matrix, a good way to do it is if you go to the docs, and I forgot who did this, who tuned this up? Was it Neradoc who tuned this up? I think it's if you click the libraries and stuff. Or is it core modules? Ah, support matrix. I forget who I should thank for this. But if you ever wanna know what boards have what you can like type in a particular module. So if you wanna know everything that supports everything that supports a particular API. Yay, Neradoc, thank you. Like these are all the boards that support sleep for example. So what you can do is just type in the module name of the thing that implements what you wanna do and it will give you all the boards. And you could even do like multiple on here as well, I think, so storage I saw. Or vector IO, I don't know. But yeah, so that's a great way to whittle it down as well to figure out what board you wanna do. Oh yeah, and FOMI guy points out that there's this how to choose a microcontroller thing as well. So this will walk you through that too. Doctor asks, I mean, time code again. So doctor asks, does time sleep put the device in low power mode or just wait to do a thing? So it puts it in a lower power mode if it can, if it's implemented, it puts it in, it's a pretty light sleep. So it does take power still because the contract with time.sleep is that it continues, everything that's running continues running. So it's generally a light sleep, which means usually that the CPU is put into like an on arm. It's a wait for interrupt sort of state. So instead of like looping forever in a forever loop, what you do is you just say like, stop running until you get interrupted by something. So it does sleep a little bit. Everything else will continue running and the RAM will stay on and stuff. So it's not a super deep sleep. It's the same thing as light sleep. If you wanna save a lot of power, you should take a look at deep sleep. So deep sleep is like, it exits your Python code and restarts it back all up. And it can be a lot more aggressive about turning things off then. I thought about calling it nap, Mr. Certainly I think that was funny. The circuitpython.org downloads page has filters as well, but those are maintained separately and they're not done on a module by module basis. Going back to the ATEX stuff, Anton says, I would not use the ATEX 608A for crypto wallet. Look for the ATEX 608B revision. I'm pretty sure Adafruit will move for those soon. The lead times are quite long though with all the craziness nowadays. Thanks for the tip, Anton. All right, next question. This is one we've gotten before. Will there be interrupts in circuitpython? So I thought if somebody wants to add interrupt support to circuitpython, I will review and merge that in. I don't think that it's worth Adafruit's time to put interrupts into circuitpython and I'll tell you why. It's primarily that it's complicated. Concurrency is really hard for everyone to program, particularly beginners. So our model in what the APIs that we have in circuitpython is that we do interrupts within the C code to achieve particular things that people are going for. So I would say we have no plans on adding interrupt support to circuitpython. If somebody wants to, you're welcome to. And we'd be open to that. But we don't have a plan to do it ourselves. And there are more than just us that, there are more people than just us that work on circuitpython as well. It's actually been quite awesome to see more and more people get digging into the core of circuitpython, besides the folks that are paid by Adafruit to do so. Yeah. And it's just not like not a huge priority for us. There's other stuff that's more interesting. All right. I think I'm caught up on questions. So I think what we'll do is if folks have questions, feel free to ask them. But I think I will move on to showing kind of where I'm at with Beely workflow stuff. And maybe I can better explain my answer to the interrupt question is like, you're welcome. I think it's Hyun. You're welcome for the answer. I'm always happy to field that. It is really a trade-off, right? Like it's not that I don't want to in circuitpython, it's that there are other things that are more important for us to work on in my opinion than that. And one of the things is what I've been working on is the Beely workflow stuff. So for those of you who haven't watched a previous deep dive, the Beely workflow stuff is so circuitpython as it is today, the way that it works is you take a circuitpython board, a board that already has it loaded. If it's not loaded, you plug it in, you double tap. Usually you load circuitpython on it. And then what you do, what you do once you plug it in and the software is loaded is you get a circuitpy drive. And on that drive is code.py file. What you do is you double click that, you open it in whatever text editor that you want and then you edit that file and save to it. And as you save to it, the circuitpython code detects that a write has been done to the disk drive and it will auto reload your code, which means that it's like super quick to get going. And that's been a really powerful paradigm and that's something that we've had kind of in circuitpython from the beginning. In the first few versions, we did actually have ESP8266 support as well. And we removed that in three, I think, because the 8266 only has a USB to serial converter. It does not have a native USB device. Now, what this be least stuff is doing is for a long, long time, I've had this idea. And I think, like I said, I used to work for Google and when we were at Google, there was this very big push for mobile first. And that's still the case. And the idea is that there are way more people who have computers in the form of a phone or a tablet. Oh, it's plugged in, did not realize it was plugged in. There's way more people with phones and tablets than there are who have access to desktops and laptops. So what this be-lead workflow thing is, it's trying to get that circuit Python experience of you just connect and you talk to it and you can edit your code from a device like this. So when I say be-lead workflow, it's kind of like three pieces. It's the first piece is how do I discover the device and how do I connect to it? And we'll talk about that today because I was changing it a little bit. The second piece is the file transfer stuff. Yeah, looks like we're getting rated, just good. Yeah, welcome folks. So I'm Scott and I work for Adafruit on Circuit Python. Circuit Python is a beginner friendly version of Python designed for microcontrollers little pieces of electronics. I deep dive usually Fridays at 2 p.m. but Thursday I do it if I'm gonna take the day off. Yeah, S-Rig says, wow, I have to work from a laptop. Yeah, so I'm really excited to experiment with this stuff. Nice, is it Toto N95 or Toto N95? A bunch of products from Adafruit. Awesome, that's great. That's Swiffer says, I'm Swiffer. I'm an IoT developer for a smart home company. That's awesome, welcome. Welcome folks. We got the memes from the Discord. If you wanna join the Discord, you can go to adafru.it slash discord as well. We're in the live broadcast chat there. Okay, so yeah, BLE workflow, three pieces. There's the discovery piece, the file transfer piece, which is the piece that I'm working on right now. So sending a file over Bluetooth to the device, reading a file back off of it, listing a directory, making a directory, deleting a file, a directory. Kind of all of those really core functionality of file stuff. And we're doing that in an open protocol. The app that we're working on called Glider is open source and will be on the iOS app store to start. And that will work with anything that implements this open API for file transfer stuff. So that's something, a piece that I felt is missing in the BLE land for a while. It's certainly not gonna be the fastest way that you can transfer a file, but it will be well-documented, simple, and we'll have an app for it. So that's the piece that we're working on now. Then the final piece is the kind of like, if you've ever used Circuit Byte on already, you know that there's like two pieces. There's the open the file, hit save. And then there's the like, your file doesn't work. How do you figure out what's going on? And the way that you do that is you have a serial connection. So yeah, in your code, you can put prints. And if you crash your code, it will print out an error message. And so having serial access is the other piece of the puzzle. And that's true for USB as well. So that's like the third piece for the BLE workflow stuff is having that serial link as well, which currently I'm not working on. So doing the file transfer piece here first. So let me go, let me show you my setup. BLE file transfer is better than no file transfer. Yeah. And for those of you who didn't hear earlier, we do have a new Discord role for deep divers. So if you want to be notified when the days shift or I cancel it, please ask to say like, hey, I want to be a deep diver on the Discord. And Mr. certainly or I or one of the other mods will add you. I felt bad because last week I said I'd be in Friday and then decided not to be in Friday. So it would be nice for me to just be able to like, let you all know that things had changed. Okay. So what is my setup here? Let me go to the overhead. Oh, and let me, I had to scooch all my boxes around because I had switched how I do Discord. Did not lead you to a Discord link. Oh, there's no WWW, I don't think. It's just Mr. certainly beat me to it again. Okay. So it's, it's blurry. Let me see if I can, come on. There we go. Okay. So what I've got here is I've got, this is an NRF 52 840 feather. There's kind of two versions of this. There's this version, which has the nice SWD header here for debugging. I have a J-Link kind of off the screen here connected to that. And then there's also a blue fruit feather, blue fruit sense, I think is what it's called. Basically like this area here where this plug is, is filled up with sensors instead. So they're very two similar boards. And so if you're interested in like trying one, for one, this is great for debugging, but the other one would work too. And then I've actually got a second one here. This is not connected to the debugger. It's just connected over USB. And I think this one, if we look at my file system, this one is called feather, and then this other one is just called circuit pi, I think. So what I'm trying to do here is I'm trying to use this feather to communicate with this feather. So this, I have two feathers. The feather feather, this feather here has a test code. This test code is initiating a connection with the second one and trying to do a series of file system manipulations. So I'm using that for testing. It's not working. So we're actually gonna debug why this one's not working. But we made some progress and actually let me unplug, I'm gonna unplug the other feather. And what this one should do if it's running is that it should start broadcasting so that I can use my phone here. I've got feather wings as well. So here's my phone. And what I'm gonna do is I'm gonna do settings, Bluetooth. And see, there's a circuit pi one here. I'm gonna forget that because I've been having trouble with the bonding stuff. So I'm gonna forget that and then I'm gonna go to glider here. And it's scanning. And this is some debug information here. But it's not finding the other one. So let's see why it's, whether it's running or what state it's in. I did restart my computer. Let's do desktop overhead. So I'm doing this in the Bealee workflow to bridge and I'll just push it as a backup. I just rebased it. So I don't know if you noticed but the LED pattern here is the new one. So it's two blinks for an error. My phone's name is the like Tadah emoji. It throws my car off. My car just shows a little box. I was thinking about changing it. Okay, so we're gonna J-Link to this one. And now we're gonna do arm. Oh, you know what? I think I need arm. I just installed GCC 11 and I don't think it's working. I'm actually gonna downgrade it. I have the like Kimmit. I've been doing it a number of times. Oh, the Tandit role device. I think we've been trolled. That's the like Bluetooth speaker thing, like a UE roll. I think it's what it's called. Bold move to use non-asky for wireless device names. I know. All right, I downgraded GCC. And now I'm gonna do GDB. And gonna do reload debug. So reload debug is like a function that I have in my GDB init, which rebuilds and then it rebuilds the binary and then loads it again. Oh, congrats doctor. Doctor says I learned how to build circuit by bones as well as show. Nice. All right, so it's loaded. Let's hit C. Let's see here. It still says it's scanning. Did I totally just type my passcode on screen, didn't I? So nrf connect is the other really useful app. It can show you everything. So it doesn't look like it's working. But you know what? I just, right before I was doing this, I switched it to, I think this is correct. So let me take a look at the code. It's not my bank pin. It's only used on my phone. And I could change it if I wanted to. But you'd actually have to get to my phone, I think. All right, let's pull up sublime text. Let me show you what I added. So last week, the advertising wasn't even working. So I fixed that. The issue with that was that I needed to like do one call to the background thing to kind of get it kicked off. So what I did is I just added a bunch of stuff to this Supervisor Bluetooth and Net. And what's interesting here is with the debugger, we're actually hitting this first case. So what this is doing is it's waiting a second for you to hit reset in case you want to go to like a newly discovery mode. And if that's the case, what we do is we erase the bonding and say, yeah, start in discovery mode. And so that, what starts the advertising is this start advertising call. And this happens quite often because like code may run and we shut down Bluetooth and then we start advertising again. And so this piece of code is gonna run a lot. So what we have here, and this is the logic I just added so it's totally possible it's broken. Common hall is bonded to central, I just added. So what I wanted to know is like has basically has my phone paired with it before. And if that's the case, then I do wanna advertise. So I now have two different types of average. Well, I'm getting ahead of myself. So if the board has USB, just me or is YouTube fuzzy, make sure that your quality is high. It should be okay. So if the board has USB, if we're not bonded, so meaning like we never connected to a phone before and we're not booting in discovery mode then just don't start advertising. So that's in the case of the USB. So the goal here is like, we really don't wanna, we don't wanna be connectable if people don't expect us to be connectable. So either you have, if you have USB, you just, we don't think you want it until you tell, until you tell us you want it. If the board doesn't have USB, so I'm thinking ahead to this micro bit V2. It has USB, but the USB is not connected to the chip natively. So this would be the case of a board that's really only for a circuit by bond. So if it's, if it's, if that's the case, if it's never been bonded, like we're always gonna want to advertise in that case because that's the only way to communicate to it. Although we may actually wanna stop advertising for like sleeping or something. We'll have to think about that. So I just added that. And now what we do is we're, I'm actually doing two different types of advertising depending on whether we're already bonded. So if we're, if we are bonded, the private advertising data here is actually like very terse. It's just the connection flags to say that we do like BLE and then our transmit power. And the transmit power, we're actually gonna just leave at the default of like zero. And then now we have this public advertisement. This is what we covered last week. One thing I've changed though is since I re-based all the changes, I now have, I can change the TX power. So I'm actually doing it as a minus 40 TX power. And the idea with that is that the signal won't go as far, meaning it will be harder for people to, it'll be harder for somebody who's like far away to connect to your device. We kind of want to limit who can connect to it by simple like proximity. So we're gonna just advertise really closely. So that's what this TX power thing here is. To false zero minus 40 is as quiet or it was like as low power as the NRF can go. And if that's the case, we do these like advertisements that have more data about who we are. So I just all added all this stuff. So I think what might be happening is that because we're starting up in this debug mode, we're like never getting to this, we're never saying boot in discovery mode. So what I think I wanna do is I just want to cheat it a little bit and just say boot in discovery mode equals true. Because we are a USB capable device. The other way, and maybe I should just show this cause I have the overhead here. Let's actually just test it. We'll break our, yay, welcome. Let's break our debug connection here briefly. Let's get TO going. That is, nope. If I get dots back, I know that's my keyboard. What is the other USB device? It must not be this feather. It's not working. Okay, so if you watch the blinks, it's two red blinks. That's for, that is for the exception that's being thrown. And USB is not coming up for some reason. So, you know, great. What I'm gonna do is I'm gonna click reset. And what we should see is we should see some slow yellow blinks for save mode and then faster blue blinks for BLE mode. And in fact, let me, let me move my phone off screen in case I get like a text message or an email. So here's the LED acrylic. Yeah, that makes it a little easier to see. So let me, I'm gonna hit reset. So, ah, somebody points out there's a default blue LED for BLE connection. Blink equals not bonded, still equals bonded. Yeah, I don't necessarily want that. I don't want it on perpetually. And the USB is popping up now, but let's see if, let's put it into BLE mode. And maybe we should have a like confirmation of this. So if I hit reset, we're gonna get yellow, blue, and I hit blue. And we didn't get blue again. We got yellow again. But that should have put us in BLE mode. So if I go back here, the peripheral's number is not changing. Let's just do, like theoretically it should be going. Let's see. I'm in the discord. Maybe it's one. Oh, there we go. We got something. Kind of seems like it was hanging, didn't it? It says start advertising, so it should be going. I wonder if it's just like too quiet. Maybe I need to turn that up. Let's see if there's a circuit pi. Pretty quiet too. Look at it, it's like minus 80. I wonder if, like it's possible the app, oh yeah, maybe it's paired already? I don't, I thought I deleted it. Yeah, it's not paired, but it's like super quiet. I wonder if just the like transmit strength is too low for it to even be picked up. Like NRF Connect is showing it, but maybe it's like 80 is just too quiet for iOS to even care, maybe? I mean, I can try to connect. Yeah, that was the right device. Did you see it go? So I was able to connect to it. That's funny though. It doesn't show here. Right, we're not paired. We are connected, so I would expect it to show here. Like we can see all of the services and stuff. That's weird though. I wonder if it is the TX. It's not Android. Some scanners don't show devices that are already paired. It's not paired. I think it might be the transmit power. What I can do is I can, well, maybe it thinks it's already paired. Let's add some debugging here. And by debugging, I mean print statements. Okay, it's MP print F. I'm gonna open the window. It's getting kind of hot. Even though it's rainy. Okay, so let's say skipping advertising there. And then let's say, this way we'll know what we're doing. This is good. This is something I can fix on the stream today. Pierre says, is TX power at minus 40? That's really low. Yes, it is. That's what I was experimenting with. And I think you're right. I think the first thing that I should try is not setting it that low. But I do want it to be like part of the problem is that the app right now, I think expects a pretty high signal strength. And so it's possible that the app will, like the app should say, I heard this. Now let's figure out what it's doing. I'm just gonna load over USB. I just built it. Didn't I? I wanna make sure it's the latest. Oh, it lied to me. I have not tested the minus 40 value with real distance yet. Yeah, I think I might actually just try zero. I think I'll just like stop messing with the TX power. I'll just set it back to zero and see if like everything else works. PR asks, why so low save battery? So my theory is that if we're publicly broadcasting, meaning our real MAC address, like if we're broadcasting a way that somebody can bond to us, I want it to be limited in who can connect to us because I want it to be like you have both devices in your hands in order to actually bond to it. And then once you're bonded, we can broadcast stronger so that you can reconnect well. But the scenario I'm picturing is like, and I talked a little bit about this last week was like imagine you're at a conference and everyone has one, right? So how do you make sure that you're bonding with your own and that like other people aren't potentially maliciously bonding with yours as well? And then though like classroom case as well, like you have a classroom full of kids that are all doing this process. Like how do you, that's why I was thinking like if the TX power is really low then maybe that will mean that like it really needs to be great like in your hands next to each other. But yeah, I haven't tested that value yet. So I think it's definitely a suspect value that I should just try to, I does this say it's saying it was built an hour ago and I just build it. That seems wrong to me. Two minutes ago, like it usually just says just now. Clean, what does it say now? I think it's broken. Another RP2040. What? Something's not right with it. NRF. Okay, so it's not there. Minus 40 is remapped to minus 30. That's an NRF 51 SDK. So maybe it's different. I think we're using S140 on the NRF 52, 840. I mean, it's pretty low. We heard it with the, let's do this. So this just has the prints and we should see them here. I think I'll just uncopying. So it's connected now to the boot loader and then it will disconnect and should reconnect. Oh, it's unhappy. We're in the boot loader again. Did I break it? Power cycle, my USB is unhappy. The blue light is blinking there. Should we copy it one more time? I don't have, I didn't do it with a new GCC, did I? That's the right one. Huh, that's no good. It's possible I'm breaking it because this code might be called before USB exists but that doesn't really make sense. Here we'll change the TX power to all at once. I'm excited to get this stuff worked out though. Pierre, it's not a 51, it's a 52, 840, you're right. Somebody linked in the Discord to docs for the 51. Let's try it again. It's weird if I single press it, it goes. It's writing, restarted, blank. No LEDs. What did I do? Let's see if I click it. It's read briefly. I don't know what's going on. How did I bust this? Boot loader still works. All right, well, you know, if only we had a debugger. Maybe we're crashing for some reason. Let's connect the JLink server. There's a fun bug in this GDB right now. If I reset into safe mode as your friend, because that's where hard fault handlers go. No, oh, oh, now it's running. Do you like that you can see the memes on the stream? The other one's not plugged in. Broadcast the serial number, then have the serial number on the device. Use the console to output some message for each block. It's running, but the USB didn't come up. I was having USB problems before, but, well, before I get too far into it, let me see, but I can see. I realize this is why I should be using this Android. So it does show circuit pi there. Let's connect to it. Tx power 0. And I don't know how do we see the full advertisement. It seems like this is the private advertisement to me. Log, device scanned. Kind of like see the spook. Now is not a time for you to get on my lap. He got out of bed and now he's sitting underneath me. So yeah, it just says circuit pi. So I think the circuit pi is a name that iOS is like remembered from it. It's weird that it doesn't show up here, but there is, I think, some caching that's done. I think that. Well, the one trick I like is we think it's, oh, look, I said private advertising in both cases. This one's public. Oh, and you know what? I don't actually set. That might be the problem. I'm not changing what I'm advertising if I'm trying to be public about it. That would totally be it. OK, there, let's have a cat cam interlude. Oh, there, kitty butt. Spook, you're on camera. Say hi. He's like, well, you pet me, dad. You pet me. Kitty. He's just looking at me. OK, let's see. Thanks, Dave. Have a good night. When I want to be on your lap is the perfect time to be on your lap. Uh-huh. I didn't even realize a car went by. Maybe you can hear it better than I think. Better than I can. Oh, look at that. Wait, what is that? We did not have success. Quick, what does seven mean? Come on. You can't see me, but I'm letting the cat get on my lap. Jump. I have a kitty on my lap. All right, what is the seven response for that? So what we do is we like to look at nrf success. See, I forget where it is in the files. There it is. That's what I want. It's an nrf error. Reports, nrf Bluetooth 7 API include error. Error base number seven, invalid parameter. So what do we think the invalid parameter is? Where are you going? Whoa, big kitty jump. He decided my lap was not worth it. Oh, no. Invalid parameter. Oh, you know what I think this is? I think I figured out that this advertisement is too long, which I think I could do like 2, 3, 4, or 5, 6. Let's just make this. Let's figure out. So what we have here is the short name. I think it's telling me it's too long. So let's make it just the first four letters. So what will happen is that the first advertisement will have CIRC as the name, and then it will get the scan response that has the whole thing. So let's see if that works. I like this ASM breakpoint trick when I had the debugger on, which actually could have been my problem earlier as well as. Yes, and now it didn't. So I had one too many bytes. Here we go. We're connecting. And we want a pair. Yay. So we're now connected. And we can, I think, write a file works. And what it does is when after the device has a file written to it, it does reload. And it looks like that reload is broken. USB didn't come up. Well, we had a good run. Now it's not working again. I forced it to do a particular type of broadcast, didn't I? So now it should be, I don't know why USB stopped working. Theoretically, when we boot in this discovery mode, we should set it to false after we're bonded. But it doesn't really matter yet. Oh, actually, no, that's not true. Because we'll say, are we bonded? And it will say yes at that point. So that should be the private advertisement then. So it should be private advertising right now. But this app is looking for Adafruit stuff. So this app code might not be compatible with it. But let's see. We go here. We can see that we've remembered the device. And now I wonder if we just hit that. Oh, it doesn't look like it's working. So I think the device does have to be, oh, it worked. Right, so now we're connected. So this is a thing that we have to do for the Glider app, of just handling that reconnect phase. It's not smart enough to be like, I'm already connected to a device that I know I have it. It's not finding it because we're doing the private broadcast now. So I am just kind of curious. I'm going to forget the device. I want to try the minus 40 again and just see where that puts us. So I think it was here. So I want to change the broadcast to say minus 40 and publicly minus 40. I can never remember how to ban people on. How do I ban people on Twitch? I never remember. Oh, there it is, ban. No, I don't want followers. Like, stop spamming. All right, this has certainly got one of them. I mean, it's not bad. It's just like, follower spam. And I pride myself in having moderated chat. OK, so I set it to minus 40 and let's see what happens. Let's see if we can actually connect to it still. Now that we figured out that the public advertisement wasn't being set and then wasn't working it at all, anyway. So I deleted it. So here's the scan. And it is seeing devices, but it's not seeing any Adafruit ones. I would hope that it would show up. It just wouldn't show nearby. Let's see what NRF Connect shows. So the app, as it is right now, is trying to enforce it to be close. But the problem is that I'm not worried about the app device. I'm worried about the other device being, oh, interesting. So see all these little ones? I suspect all these random ones could be actually the Circuit Python device doing the anonymous advertising. Because I haven't forgotten. I haven't erased the bonding information there. These are all the secret advertisements that would be sent out if you were bonded to something. So this is the case where I actually need to do the double-click trick again. Let me see the lights. So error message, so we get yellow, blue. And we do yellow, but no blue, which means we're there. Maybe what we do, what do you think about we do? Oh, we got USB that time. We could do yellow and blue. And if it's being enabled, we do solid, yellow for a second, or a solid blue for a second if we're turning it on. I don't really want to leave it on forever, but maybe that would be good to have. OK, so that should have reset us. And it looks like that's the case. It's not reading it as nearby. Why isn't it nearby? Oh, you know what, this is the public. This is exactly what we thought would happen. This is the, we're broadcasting too quiet for the app to think that it's close. Let's see. OK, I'm curious. NRF Connect. It spams with stuff. OK, so let's see what we see here. So there's the board. And interesting, we set it at minus 40 is coming through, so that's correct. And we're seeing it at minus 80 dBm. So all I want to do is actually, I'm going to click this. And I think it's, is it scanning still? Yeah, I'm actually just going to go like this. So I'm an arms length away. And it missed it. Yeah, so it doesn't see it anymore. I don't know, I think it'll, I think it will scan forever. Or it will advertise forever. OK, now I see it. Oh, you can't see me, can you? So here's what I'm doing. I'm, I've got NRF pulled up. And I'm watching, I'll show you. So I'm watching, I'm watching the TX power. So that's the device. And maybe if I get close enough, you'll be able to see it. Like pop up with one advertisement. But basically, I think I'm achieving one out. See, there's like one red blip. And it's probably like two feet away. So like, I think this is going to manage to do kind of what I want is like, you got to be close. Hi, Bruce. You'll have to be pretty close to even pick it up if it's doing that like minus 40 power, which is what I want. Pierre says, maybe raise it up by 10 dB and see if that's enough for the app to be happy. I don't know, the app was tuned I think at, you know, we can just pull up the app source and see if we can't see it. Let's see how it's doing it. Here for Glider for iOS. And I haven't looked in here. I do not know my way around. Auto connect view, that sounds right. Status, file transfer service nearby. Oh, it's model view controller stuff. All right, let's go back to view models. Auto connect view model nearby. Matching peripherals. A is manufacturer, Adafruit, non-peripherals. Connect to the closest. Yeah, my guess is that's an RSSI filter. Where is the scan started? I do not know iOS Swift stuff. RSSI running average filter. Start scanning, update scan peripherals. Peripheral list dot filtered peripherals will connect. I guess what I'm getting at Pierre is I think I'd rather change the app to be OK with how quiet it is than change how the broadcasting stuff. But overall, I'm pretty happy. We fixed those bugs. And what I actually want to do, we've got more time. I usually go until 4, right? So we've got like 40 minutes. Instead of worrying about enigma paradoxes, can I get something for free, please? You can get advice. I'm happy to answer questions. But we haven't, Adafruit hasn't given away devices in a while. Can you show slash measure RSSI on the mobile side so you can adjust the TX power? Yeah, you mean just like what it is? Let's just, like if it's right next to it, it's still like minus 77 when it's real close, 80. Yeah, I mean, I'm curious to know what that number is. Minus 95, nothing. Nada, which is good. Free things are available. Adafruit.com slash free. That's if you buy something. Tralamazza says, hey, what you doing? I'm debugging Bluetooth stuff. And I just realized that now you can't see the overhead. So what we've got here, this is the LED acrylic. We've got a blue NRF 52A40 feather that I'm working on. Since you have access to both, that's fine. Minus 80 is not too far from the sensitivity. Can't be sure. Yeah, we'll experiment with it. So the minus 80 is only for the advertising. Once we're connected, like once we initiate a connection, then it will be full power. The minus 80 is only for the average, or the minus 40 setting. Debugging, what exactly? So we were playing around with, there's two modes of the advertisements for this. There's a public mode and a private mode. And the public mode is like, you have a new device and you wanna initiate the connection for the first time. What we're talking about is like, I set the signal strength when it broadcasts in that public mode to minus 40 dB. And I was testing how far away until my phone didn't pick it up anymore. But then in the private mode where it's rotating its address a lot and only advertising that it's connectable, it doesn't say like I'm a certified device or it doesn't say I have this service. In that case, then it's broadcasting at zero dB. So like the idea being that like, in order to do that first connection, you have to be really close, but once you've done that pairing that the bonding process specifically, bonding is the process of saving the pairing information for later. So once you do that one, like you have to be real close, then if I embed it in a project or something and I wanna reconnect, it's okay. Can you please tell your friends at Eight of Root, we need a user friendly DSM module with 4G the size of an ESP8266D1 mini. I'd recommend, if you wanna talk with Lady Aida, who does a lot of the designs, she does Desk of Lady Aida on Sunday nights and then Wednesday they do Ask an Engineer. So that's a better time to put hardware requests in. I do software. Is this a normal peripheral? I don't know what you mean by normal, but yes. I mean that, yeah, like the phone is acting as a central and the feather is acting as a peripheral. TQN, I don't know how to pronounce your username, but it says when the TX power is default zero, you should be able to measure RSSI at one meter and then recompute the DB reduction to reduce the distance. Yeah, we'll play around with this. This is all like, ah, by normal, I mean you're advertising indirect, direct, connectable, et cetera. So I'm doing RSSI is a very, very poor proxy for distance. Yeah, I understand that. I know it's gonna take some tuning. We've talked about other ways of doing that verification that the correct things are talking to one another. But I think we're kind of heading towards this idea that it's better to just require proximity. But we'll play around with it. This is just a first pass. This is some code I wanted to write and so I was kind of doing that today. But we have this anonymous switch. The sniffer's telling me it's like around minus 80 if I put my phone right next up to it, right up next to it. Okay, that's not what I wanna do for the, the other thing I wanna work on is getting, so I have this other feather that I showed at the start. So I've got this feather here that is doing my test code using the CircuitPython internals. And then I have the second feather that is in, from like in CircuitPython user code, trying to connect to the other one and do the file transfer stuff. And at Negba says, besides being easier, time codes are not gonna be that great. Cause David's going, oh yeah, it is raining. I was gonna say it was just the, just the palm trees bit. Enigma says, besides being easier to read and learn, does MicroPython have any other real benefits over C++ since run speed is slower? Generally the trade off for Python, and this is true for MicroPython at CircuitPython as well, is that you trade execution speed for development speed. So it's much quicker to iterate on than it is for C, cause you don't need to recompile everything. And I could just show you real quick, like I think, yeah, so we have the CircuitPyDrive and code.py is the file that you have. And if I open the serial connection, so there's the serial connection. If I just type print hello and I hit save, and I hit save, oh, and it's broken. This is the other thing I have to figure out. I have to figure out sharing. I have to figure out, okay, we can go into this. Let me take a time code. This is the other thing I had to figure out. I was trying to show how easy it was. Oh, somebody's taking time codes, thank you. So the other thing that we need to figure out is we have this policy. I'm sure people who have used CircuitPyDrive have run into this where the way that the drive works over USB is that the host OS, so in this case, my Linux computer, manages the manipulation of the file system data structures. And what you don't want is you don't want two different systems trying to do those manipulations at the same time. So usually what CircuitPython will do is it will allow you to read and write the file system from USB, but not from the CircuitPython code yourself because that would require CircuitPython to be managing the metadata structures for the file system at the same time that the host OS could be. Now the challenge is that with the BLE workflow, now you have this case where the BLE stuff is a file level protocol, which means that CircuitPython is doing the manipulations of the file systems itself. So the question is how do we switch from, like how do we decide whether we're gonna let USB write or CircuitPython write and never the two at the same time because that increases the risk of things going poorly. So maybe actually I should do this. What I was gonna do is get the other one working, but this is also something I need to do and now that we're talking about it, maybe I should do that. Pierre argues C++ versus Python, but I like compiling and linking gives me time to drink up some more coffee. Another question from enigma paradox is, from your experience, what is the hardest part, hardest board to get up and running? Mine is definitely the AT-Tiny85 or any clone from China. I generally don't work at the board level. I mean, it's weird that like most of the boards I work on are Adafruit boards. And then when I'm doing development, it's usually on a like per microcontroller basis. Some of the challenges with those are like any of these connected ones, they can make debugging trickier. Like I was doing some printf debugging earlier and the reason to do that is that like BLE is time sensitive. So if you have a debugger attached and you're breaking, like you break the timing requirements of BLE and the soft device will be mad at you. So like USB is that way as well. So like if you're connected over USB or BLE, it can make it really tough. It can make it really tough to do debugger level development, which is why I ended up doing printf debugging a lot. The other challenging thing you can find on some microcontrollers is the boot ROMs. So any microcontroller with the boot ROM can be trickier because there's like more than a, more than a little code that's running before you. And some of those also have, those chips usually have boot ROMs because they have external flash that needs to get going. So that could be the other thing is that if your code's running off of external flash using execute in place, like if that's not a solid link, then you can end up crashing where you didn't, where you didn't, where you didn't expect just because like some bits didn't go over that. Yeah. Chalamaza says MicroPython is fine, especially for IO heavy stuff like BLE. Yeah. Yeah, if you're doing generally simple things like and you don't need that super speed, then it's fine. But also like the thing is you can write C code and have it in CircuitPython or MicroPython. Like that's what I do all day is like making those libraries that for things that are making libraries for things that are timing sensitive and see so that people can use that from Python and it's like kind of what I do all day. Pierre says, yep, soft device faulting on trying to debug been there. It's lucky I'm like totally a printf debugger at heart. Anyway, I've been debugging a Python chat bot and I switched all the example libraries CircuitPython which has made it way easier. TQuinn says, oh, is that Hien from earlier? Ah, yes, I see. Hien says, CircuitPython can also manipulate files. C++ and Arduino is harder for that I think. Yeah, that's true. And also strings in general, string manipulation in Python is much, much easier. Welcome to Discord. If you wanna be part of the deep divers role please say so and we'll add you. I don't wanna add people without asking. So yeah, right. Neurodox says, I believe AT makers mentioned that having wheelchairs code being accessible as a drive made it possible to access it with standard text editing accessibility tools. Yeah, it can be really helpful for just like key maps and stuff, configuration files. I think AT makers has actually tried to do it for like having a separate file for config so that people don't have to edit the code itself. Esraic says, deep diver please. I like the diving mask emoji. Enigma paradox, that's all the questions. What do you think is the hardest sensor slash module to interface with for beginners or advanced creators? What's a good question? I, you know, Adafruit's in the business of making things easier. So I think generally sensors are easy. I think where beginners can get themselves in the weeds is if they're trying to do co-processor stuff. This is something that's come up a lot with the RP2040, like the Pico. The deep diver role is ranked below circuit Python needs. I think so. If you're in circuit Python needs is Johnny, you'll stay purple. But yeah, so I think the hardest thing that beginners try to do is try to get co-processors up and running. And we have tutorials and stuff for that, but that's like, it's not a great experience. So I've seen people come to the RP2040 and say like, oh, I want to do Wi-Fi and Bluetooth. And my reaction to that is always just like, really what you want is you want a chip that does that. You want a chip that does Wi-Fi or Bluetooth on its own. You don't need an RP2040 if that's what you want. So I wonder what I should do. Going back to this file system sharing stuff, I wonder how I should do that because I am connected. So what I was thinking is that it would be first to connect. So let me know if this makes sense. Imagine you have a board like the Feather where it has USB and it has BLE. Imagine if you have it bonded already and plug in the USB. What do you expect to work? And then the other thing is is like, maybe we actually want to know like that the file, like that the phone has like talked to the file system already. So like it's not enough to be connected over BLE, but you actually have to like initiate, like there's a characteristic for the transfers for the file, file transfer stuff. Like maybe you actually have to like write to that. It's like, yeah, I don't know what the right thing to do is. Cause like, maybe the right thing to do is just like, what's the connection here between file system and BLE? Chalamaza asks on Twitch. So the connection here is that there's two, there's two ways to write to the file system and the way that the USB writes to the file system requires the hostOS to manage the file system versus BLE. Whereas the nice thing is, if you have a BLE only workflow, it's circuit by them that's managing the file system. So we can actually do things like, if we do the BLE workflow, you'll be able to write to the file system from circuit Python as well, which will be really nice. Yeah, your BLE app is saving something to this generically. Yes, we have a file transfer protocol, which is different than FTP, but you could abbreviate that as well. So yeah, you're on your phone, you have an FTP, you have an FTP, you're on your phone, you have an app, like there's ideally gonna be multiple apps that can send files over. And what you're doing is you're gonna send a file, all of the contents of the file kind of all in one go. So you're connected in BLE, then how's your board powered? Well, a feather has the battery port too, right? You plug the USB, but it's already powered another way. What is your scenario? Where does the file come from? You know, I wonder what we do is, whenever you plug in USB, USB wins, because yeah, that's the way we could do it, is Pierce says, I check USB state and head to enable and disable BLE. No, we're not gonna do that. Hugo says, this may be way too out there, but have a host process running on the device which presents the OS over USB BLE, but it's just a proxy. That is a process of what handles reason rights. Yeah, so that's, yeah, I think that's what, so there's a thing called GhostFS that we could do that Microsoft did for tiny UF2, I think, for UF2, I think, which is like faking. It sounds really gross to me. It's like, it fakes, I don't know where it is. What it does is it fakes FATFS on top of something else. Would it be difficult when connected to serial, let the serial win and disconnect the BLE? I don't think we can do it when serial's connected because we tell the computer that it's read only earlier. So we have to be able to say, I think what we should do is we should say, oh, then we have to think about user code. So what if user, well, we already have existing APIs and those APIs should win, I think. Yeah, there's another protocol called MTP, but it doesn't have universal support like the mass storage device stuff does. David says, you already had a fight between OS and CP that could write to the file system and you decided it's one or the other. Now you add BLE. Yeah, so BLE is on the same side as the circuit Python side. So at least it's not a three-way fight. It's just like, we have another thing on there. Mr. Certainly, thanks for deep-divering people. What we could do is we could say, if from circuit Python, you want to write, if from user code on circuit Python, you must say the storage thing that we have right now. However, over BLE, BLE will allow you to write until USB is connected and then it will fail after that. So when USB is connected, what we'll do is we'll flush all of our file system stuff and then switch into the mode that disallows it. Pierre switched computers and says, I check USB state and enable slash disable notifications through BLE, but USB state switches too often and causes issues. Jaisen Tamara is saying hi in many different ways. I'm curious I would handle selecting one. If I became super blurry, it's likely YouTube's fault. It's hard to tell that there must be user code to make the file system read only for the host to let BLE work. So I think what I'm arriving at is, now I'm good again, good. Maybe it was a blip in restream. So I think what I'm thinking is, you start up, BLE is available, user code is not until USB is connected and then when USB connected is we flush and we cut BLE off. If you start up and then boot.py I say, I wanna write to it, then BLE and circuit pi think are right even if USB is connected. Does anyone ever copy and paste perfectly fine code that doesn't work and then wonder why I got hate you? Sometimes I have to tell myself to, sometimes I have to tell myself to test code before I stop copying and pasting it. I did that. Would the flush and disconnect for BLE only be for file transfers? So we wouldn't disconnect BLE, we would just stop letting you write if USB was active. Yeah, you'd be able to read still. Do you need to serve files through USB? Yeah, I think you do. Cause I just, like it just ran into this, right? I was like, I wanna show this person how easy it is. And it was blocked right now cause I like hacked the code to allow me to write. So yeah, I think in the case of a circuit Python device as both BLE and USB, I think people when it's plugged in USB are going to expect USB to work. And so I think that's the crux of it. I think that USB has to win unless you've explicitly done the existing API to say, don't let USB change this. Yes, correct. USB data, not power. Yeah. David D says, and now I've destroyed all my power only micro USB cables and now I need some. So what you can do is there are these great cables that allow you to switch the data on and off that Adafruit carries. So if you do want that, those are great USB switch. So these are really handy. This one here, this is a power switch, I think. So beware, this is power only as well. But then this is the data charge switch is what you want. If you want to be able to switch on and off. So that's what I recommend if you're worried about this. Yes, otherwise it might be a fight. Okay, that's good. I'm happy with this idea. USB data switch. Yeah, the USB data switch allows you to change the cable like to connect and disconnect the data lines. It's really handy. What is the OS doing with the file system when you plug in USB? It is presenting as a mass storage device, right? So it's showing up as circuit pie. And at the time that it's plugged in, we have to say whether the drive is read only or not. And generally, like permissions, it's not right. I mean, it could be broken too. But like I just tried to write to it and it said it was read only. So like this is the classic. This is the classic. This is the classic kind of circuit Python use case, which is why I think that's the case. Yeah, so it's writes on its own on the flash memory. So circuit Python won't write the flash memory unless the user code tries to write to it. And as it is today, we have an API that you have to use to say I want to be able to write to it. And so what I'm thinking is that the only way to write from user code will be to set that thing. But if you're not connected on USB and Beely is active, Beely will be able to write. We are gonna have to have a lock. Like imagine that you're in the middle of a file transfer and USB is connected. It's complicated. That's why Windows can't be the owner or such manager of mass storage. But that's how mass storage works, right? Like the mass storage protocol works at the block level. It doesn't work at the file system level. YouTube's messing up. Oh no. Yeah, we don't have web data or file system. We use mass storage because mass storage works for everyone. And that's why Android's doing the extra protocol. Yep. Yeah, but the thing is that like the extra protocol is called MTP, the media transfer protocol. And it's nice because it works above the file system. The problem is that Mac in particular does not support it well. Of course, now maybe like we just added, like Dan just added the flexible USB descriptors. So maybe we should consider like allowing you to switch between mass storage and MTP. Like that could be a thing that we could do. But by default, we're gonna do mass storage. Like you will not convince me otherwise. Like we've taught people that when you take a circuit Python device and plug it in, it shows up as USB drive. Like I'm concerned about like boards like this micro bit, right? Like where it'll be BLE only, but it has a USB plug on it. So like we're gonna have to be very careful to tell people this is BLE only for circuit Python. Charlie Mazza says, so you either patch circuit Python to share some underlying HAL with USB with the file system or you prevent someone from accessing like you mentioned. Yeah, so right now we have this. Let's take a look at what we've got right now. We're just about out of time. So if you have any more questions, ask them. But if we look in main here. So circuit Python knows a shared main and we have this, what's it called? Set internal writable by USB. Right now we just have this one flag that's like yes or no. But I think we're gonna need a little bit more complexity. Hi, John Franco. I haven't tested micro Python in years. Well, maybe you'll come back to it. Yeah, so there's this flag right now that we have. Micro Python, by the way, does not do this. Only circuit Python does this. Micro Python, for the ports that allow you to write over mass storage, does not make sure that you don't conflict. It just tells you, be careful. Which is not the philosophy of circuit Python. We wanna circuit Python tries to give you guardrails so you can't mess things up, even though it does happen. So let's figure out how this works. This is a shared file system, shared module. Supervisor shared file system. So when you set internal writable by USB, we call file system set writable by USB, which gives the particular file system. And then what we do is we have this flag for the block device. So, and we actually do have this separate flag for concurrent writes, which is the like, I want the micro Python behavior of like, don't worry about it, I've got this. And so I'm wondering, be careful, is not the philosophy of circuit Python. Right, and this is really interesting. It's something that Lady Aida found when she started doing the circuit Python stuff after coming from Arduino. It's like, I think she found it very freeing that the idea of like, if she writes bad code, the like micro controller doesn't completely crash, right? Like in Arduino, because you're at the C level, like when it crashes, you get, you know, serial output and then it disappears. Whereas like circuit Python is like higher level. So like all of the like serial link stays up, the USB stays up. Of course, that's if we've coded everything right. And if we haven't coded everything right, we've got safe mode to back us up. But, yeah, so I think like this is the code that we're gonna have to rework in order to be able to say, I guess what we do is we just say, we leave this all the same and then when we're doing a write in BLE land, we just verify that USB is not connected. I think that's it. And we could also flush after every write to make sure that it's in a known state. I think that's it. I think I could actually hammer that out right now in the next two minutes. So how do we know whether USB is connected? USB, I think we have a USB. Is that what USB enabled is? Disconnect, sounds reasonable. Good, good, good. Trying to think of where we do that check. And, you know, we do it in main connected. Although this is serial connected, it's not USB connected. The other place to check is we have, I mean, we could go directly, but if we can go indirect, that's better. What does this have? What is USB enabled? Is that like it's connected and shared USB? Let's see what it does in tiny USB and initialized. That is not what we would want. What is the USB underscore MSC ejected thing? It's worded like a getter. Fine, I will fork this. Yay, play around with it. I feel like there's this, invoked when the device is mounted and that mounted is not mass storage. That's the confusing bit, vendor connected. That's for web serial. I thought it was called connected. USB connected sleep delay. Oh, let's look at that. Maybe that's wrong. I wonder if that's using serial connected. Make sleeping. The workflow active thing. Well, not that. The workflow active thing is meant to cover BLE as well. All right, well, it's just to do ready. Let's just use that. Okay, so in here, you know, we might still have to override it. Maybe Bluetooth in right. Start Bluetooth. I do want to add reads are okay. In right, wait for the full path because we don't want to reply until it's too late. So here we can say, if circuit pi USB, this code is a nightmare. It's not my best written code. If USB is active, then we respond with an error. Which is what this does. You just want this lap, don't you kitty? I'm gonna have to pick you up. He's like, you're freezing me out, dad. For now, we'll just do that error, but I think we're gonna want a custom error to say read only. Okay, I'm gonna call it. So much open loop coding, fun for days. I missed the MSC thing you were talking about. Where are you going? Kitty tail. All right, let's wrap up and call it. G3 holiday says I'm loving CP and Python. Awesome, glad to hear it. All right, folks, thank you all for joining me for this deep dive. Sorry, I told you the wrong day last week. So if you wanna be notified later, and by later I mean, if in the future I end up changing my mind, I will ping the deep divers group on Discord. So if you're not a part of that, if you're not part of that role, please say like, hey, add me to the deep divers and I'll add you or Mr. Certainly will add you so that you can be notified later on. So that's a heads up there. Thank you all for hanging out with me. If you wanna support me, please support Adafruit by going to Adafruit.com and purchasing some hardware there. If this be at least that's interesting, make sure you've got an NRF 5280 device of some sort to be able to follow along at home. Yeah, this has been another deep dive. The plan is for the next few weeks. Next week we'll be on Friday and then I'm taking two Fridays off after that. Yeah, so if you wanna join the Discord, John Franco, go to adafru.it.discord. I cannot connect with you if you're on YouTube. So join the Discord, adafru, actually I'll type it in. There's the link to the Discord. Just pop up and say, hey, please let me to the deep diver's group and then we'll be able to pin you. I did get my blog post out earlier this week as well so you can watch the Adafruit blog for that too. And the Discord's where we do a lot of different development for a Circle Python. So we have Monday meetings, that are community meetings in the voice channel. That's Monday at 11 a.m. Pacific. So that's welcome to everybody as well. And I think that's it. It's been wonderful hanging out and I'm glad that we like, these are a couple of things, like the advertising strength thing and switching to different advertisements was something I wanted to get to. And then thinking about this USB stuff, I feel like you just watched me and you helped me work through that. So I think we have a plan, which is basically, Billy will write to the file system if it can. If USB is not on. So with that, thank you all. I usually pet the cat at the end but he's up and about right now. So we'll just skip that. And we'll talk to you all next week and on the Discord's before then. Thanks all.