Author: valerauko

Some notes on iOS BLE

Dealing with Bluetooth Low Energy (BLE) through Swift can be pretty tricky. The interfaces and delegation are straightforward, but there is an implicit “right way” of doing things that (as far as I could find) is not documented anywhere.

I don’t know if the way you have to hold on to references to things or they get immediately discarded and cleaned up was surprising only for me with zero Swift background, but it took some time to get used to. For example CBPeripheral and CBL2CAPChannel objects require that you keep a reference to them, or the connection will be terminated, resulting in interesting behaviors.

Another thing is that I couldn’t find any details about error patterns in the documentation, but I figured out the following:

  • the input and output streams that come with a CBL2CAPChannel are not opened when you get your hands on them, and result in a pretty obscure 0x0122 failure if you try to use them without opening them first
  • you have to read/write those streams from the same DispatchQueue where they are scheduled, or the operations will silently just do nothing. Logging Thread.current can help debugging this.
  • error 436 means the local (you) severed the connection. This usually happens when you forget to hold on to the CBPeripheral instance
  • error 431 means the remote peer severed the connection. I’m not entirely sure what triggers this, since usually the disconnect is very graceful with a delegate callback. Maybe sometimes closing the streams doesn’t make it in time and this error gets logged first?
  • error 582 means the PSM used to initiate the CBL2CAPChannel is incorrect.

Az a fránya orr

Tegnap este úgy kifárasztott a műszak, hogy nem volt energiám még egy számjegyű “melegben” és csepergő esőben elindulni kondiba, inkább nekiálltam és összeraktam a polcot a hálószobámba. Közben rendet is raktam, és ekkor történt a baleset: újra hajtogattam a meleg pokrócot, amit amúgy nem használok, és úgy tűnik gyűjtötte a port. Nekem meg van egy szexi poratka-allergiám.

Öt percre rá fullra be volt már állva az orrom, bár nálam szerencsére az allergia kimerül ennyiben. A duguláson segít az orrspré, és reméltem, hogy a brutálisabb gyógyszer majd megnyugtatja az éjszaka alatt. Ehelyett az történt, hogy míg az orrsprének köszönhetően elaludni el tudtam, reggelre belobban teljesen “megfázásosan” az orrom. Gondolom, hogy felgyülemlett valami az éjszaka, amiben beindultak a bacik. És persze így már egész nap folyt az orrom, mintha megnyitottak volna egy csapot.

Amit persze nem győzök fújni, és ha fújom is, folyik hátrafelé a torkomba, úgyhogy persze az is elkezd kaparni, mert valami szaros fertőzés jobban tudja manipulálni a testem folyamatait egy begyulladt orr-nyálkahártyán át, mint én. Így ma kimaradt persze a kondi, és gyanítom, hogy holnap egy rendelő látogatás is be fog kerülni a napirendbe, mert általában ha már itt tartok, akkor rendes gyógyszer nélkül örökké tart.

Azt a kurva pokrócot meg a következő adandó alkalommal kidobom a fenébe.


Barcelona

Nem is tudom, hogy jött elő, de a múltkor ahogy a főnökömmel beszélgettem, szóba jött az MWC, én meg reflexből rávágtam, hogy “de mennék”. Mire nagy meglepetésemre az volt a válasz, hogy “nem gond, még ki menjen?” Nem kevés szervezés és a hitelkártyáim kimaxolása után (természetesen a cég utólag megtéríti) végül most február végén eljutottam Barcelonába majdnem egy egész hétre.


My new gear

Earlier Reol announced that No title- will get a vinyl release. I love that album, so I ended up preordering it before realizing that I don’t actually have a record player. Well, that changed now.

And while I was at it, I also got a few old Japanese jazz fusion records from Disk Union and Thy Catafalque’s Rengeteg too.


On the boards

Last year I didn’t go snowboarding. Or rather couldn’t: during the season my wallet was dry as something that’s very dry, due to the Karakoram expedition the previous summer (and the insurance company fighting my claim for over half a year). Then the season was over.

This year however a friend kindly invited me along, so I was back in Yuzawa after almost two years. I surprised myself by doing pretty okay by my own standards, not crashing too much and turning okay-ish.

Hopefully I can go snowboarding again a few times before the little snow that this warm winter had disappears.


Moving

I lived in Shakujii for 8 years. It started because of my job at Sunrise, which pretty much required me to live nearby. Then I switched jobs, but moving closer to the office wasn’t really an option, since it’s absolute downtown Tokyo and I’m not willing to pay that much. Then the rona hit and we don’t even have to go to the office anymore (in my case, at all). Furthermore, the small room I rented in Shakujii grew pretty tight since I started climbing mountains. Those sleeping bags and backpacks really take up a lot of space…

Google Maps's idea of highlighting Shakujii-dai.
My old area, Shakujii-dai. The flagged location at Musashi-sakai is the Chinchintei ramen place mentioned in Joshiraku

Longhorn trash weighing me down

Last year I gave Longhorn a try. It was a nice proposition for me: I was using local storage anyway, so the idea that pods would be independent of the nodes sounded delicious. Except the price was way too much.

At the time I thought that the only problem was Prometheus, which in itself is pretty heavy on disk IO, but it turns out the issue was with Longhorn itself. Also, as I found out, I wasn’t thorough enough deleting Longhorn stuff, which resulted in quite a few headaches this year.

white cow statue beside brown tree

Lady Jannath’s Estate

Recently I’ve had the pleasure of playing Baldur’s Gate 3, and in the later half of the game there’s a pretty annoying (tricky?) bit. Of course I’m talking about Lady Jannath’s estate. Spoilers follow.


Kyoukai no Kanata

Time again to watch some anime. I’ve had a pretty offensive gif from the 4chan /a/ era based on the idol dance bit, and since this weekend I felt drained to the bone I watched Kyoukai no Kanata instead of going to the mountains. Not sure if it was worth though. Obviously spoilers galore follows.


Bye Seafile

Operating Seafile was a very frustrating experience. In the first place, setting it up on my Kubernetes (k3s) cluster was quite a ride. It didn’t have a Helm chart or any manifests ready to spin it up, so I had to build my own. This turned out to be pretty difficult because it was clear that the software was not designed with containers in mind and it took significant amount of hacking to even just get it to work. But once it did, then you’d need to manually run garbage collection every few months, because that was a Paid Feature™. I put up with it because of the sunk cost fallacy and because other than that five minutes every 3 months or so, it was working okay. Until it wasn’t.